/* * public static void SelectUnit(GameObject u) * { * currentSelect = u; * Debug.Log(u.GetComponent<UnitData>().UnitName); * } */ void ChangeTurns() { isPlayerTurn = !isPlayerTurn; //current turn is done, at this point forward it is the other side's turn unitsDone = 0; doneButton.ResetButton(isPlayerTurn); if (isPlayerTurn) { turnCounter++; //only increments when it is becoming the player's turn turnCountText.DisplayNewTurn(); } //goes through every object of type Unit and readies/exhausts allies or enemies appropriately //Unit[] units = FindObjectsOfType(typeof(Unit)) as Unit[]; UnitData[] units = FindObjectsOfType(typeof(UnitData)) as UnitData[]; foreach (UnitData unit in units) { UnitStateController usc = unit.gameObject.GetComponent <UnitStateController>(); //Debug.Log("finded a unit"); //var unitInfo = unit.GetComponentInParent<Unit>(); if (isPlayerTurn) { if (unit.UnitTeam == Team.HERO) { usc.ReadyUnit(); //Debug.Log("ally is woke"); } else { usc.ExhaustUnit(); //Debug.Log("enemy is exhausted"); } } else { if (unit.UnitTeam == Team.ENEMY) { usc.ReadyUnit(); //Debug.Log("enemy is woke"); } else { usc.ExhaustUnit(); //Debug.Log("ally is exhausted"); } } } }