/// <summary> /// Update unit positions and move to attack phase /// </summary> void EndOfMovementUpdates(Transform unit) { unitsManager.PopulateUnitDicts(); unitPos = new Vector3Int(Mathf.RoundToInt(unit.position.x), Mathf.RoundToInt(unit.position.y), 0); stateManager.phase = GameStateManager.GameState.AttackSelection; //Debug.Log(stateManager.phase); playerHasControl = true; }
void UnitDestroyed(Unit dead) { unitsManager.RemoveUnit(dead); dead.Die(); unitsManager.PopulateUnitDicts(); }
/// <summary> /// Filters gamestate and AIState to determine what action the AI should be doing in this moment, if any. /// </summary> void TakeAppropriateActions() { //Swap to player's turn if all units in queue have been used. if (stateManager.ai == GameStateManager.AIState.Switching && units.Count == 0) { SwitchTurn(); return; } //Get the next unit to be moved and initiates movement if (stateManager.ai == GameStateManager.AIState.Switching && units.Count > 0) { unitsManager.PopulateUnitDicts(); current = units.Dequeue(); if (current == null) { return; } stateManager.ai = GameStateManager.AIState.Moving; StartCoroutine(MovementAction()); } if (stateManager.ai == GameStateManager.AIState.SwitchingToAttack) { stateManager.ai = GameStateManager.AIState.Attacking; StartCoroutine(AttackAction()); } //Should only run at the very start of the AI's turn if (stateManager.turn == GameStateManager.Turn.Enemy && stateManager.ai == GameStateManager.AIState.Waiting) { InitiateTurn(); /*//Unit currentUnit; * while (units.Count > 0) * { * unitsManager.PopulateUnitDicts(); * current = units.Dequeue(); * if (current == null) * continue; * yield return MovementAction(); * * yield return AttackAction(); * yield return new WaitForEndOfFrame();//Makes sure race conditions are cleaned up * }*/ } }