void Update() { if (!alive) { currentState = TurnState.DEAD; } switch (currentState) { case TurnState.PROCESSING: UpdateProgressBar(); break; case TurnState.ADDTOLIST: battleSM.heroesToManage.Add(this.gameObject); currentState = TurnState.WAITING; break; case TurnState.WAITING: //idle if (regen) { HealDamage(hero.currREGEN); } if (activeTurn) { //full opacity text on active turn timerText.color = new Color(255, 255, 255, 1f); heroBarBG.color = activeColor; UpdateDelayTimer(); } else { timerText.color = new Color(255, 255, 255, 0.5f); heroBarBG.color = inactiveColor; } break; case TurnState.ACTION: StartCoroutine(TimeForAction()); regen = true; break; case TurnState.DEAD: if (!alive) { break; } //change tag to dead this.gameObject.tag = "DeadHero"; //cannot be targeted battleSM.heroesInBattle.Remove(this.gameObject); //disable the selector selector.SetActive(false); timerText.color = new Color(255, 255, 255, 0.5f); heroBarBG.color = inactiveColor; //reset GUI battleSM.ClearAttackPanel(); if (battleSM.heroesInBattle.Count > 0 && battleSM.performList.Count > 1) { for (int i = 0; i < battleSM.performList.Count; i++) { if (i > 0) { if (battleSM.performList[i].attackerGameObject == this.gameObject) { battleSM.performList.Remove(battleSM.performList[i]); } if (battleSM.performList[i].targetGameObject == this.gameObject) { battleSM.performList[i].targetGameObject = battleSM.heroesInBattle[Random.Range(0, battleSM.heroesInBattle.Count)]; } } } battleSM.UpdateTurnOrder(); } //change color / play death animation this.gameObject.GetComponent <MeshRenderer>().material.color = new Color32(150, 150, 150, 255); Vector3 deadPosition = new Vector3(startPosition.x + 2f, startPosition.y, startPosition.z); transform.position = deadPosition; battleSM.heroInput = BattleStateMachine.HeroGUI.DONE; battleSM.heroesToManage.Remove(this.gameObject); //reset heroInput battleSM.battleState = BattleStateMachine.PerformAction.CHECKALIVE; alive = false; break; default: break; } }