// Update is called once per frame void Update() { Debug.Log(currentState); switch (currentState) { case (TurnState.PROCESSING): updateProgressBar(); break; case (TurnState.CHOOSEACTION): if (BSM.PlayerCharacters.Count == 0) { Debug.Log("all players dead"); break; } else { chooseAction(); currentState = TurnState.WAITING; } break; case (TurnState.WAITING): break; case (TurnState.ACTION): StartCoroutine(actionTimer()); break; case (TurnState.DEAD): if (!alive) { return; } else { //change tag this.gameObject.tag = "DeadEnemy"; //make not attackable BSM.EnemyCharacters.Remove(this.gameObject); //disable selector if enabled selector.SetActive(false); //remove enemies attacks if (BSM.EnemyCharacters.Count > 0) { for (int i = 0; i < BSM.TurnList.Count; i++) { if (i != 0) { if (BSM.TurnList[i].attackerGO == this.gameObject) { BSM.TurnList.Remove(BSM.TurnList[i]); } if (BSM.TurnList[i].attackTarget == this.gameObject) { BSM.TurnList[i].attackTarget = BSM.EnemyCharacters[Random.Range(0, BSM.EnemyCharacters.Count)]; } } } } //change colour/play death animation this.gameObject.GetComponent <MeshRenderer>().material.color = new Color32(155, 155, 155, 255); //set alive false alive = false; //reset target buttons BSM.TargetButtons(); //check if battle has been won/lost BSM.battlestate = BattleStateMachine.PerformAction.CHECKALIVE; } break; } }