private void ExecuteEnemyTurn() { // One last check that the current combatant is an enemy Debug.Assert(CurrCombatant.Allegiance == Allegiance.ENEMY); EnemyController enemy = (EnemyController)CurrCombatant; // Carry out the enemy's turn enemy.DoTurn(); // If the next turn is an enemy too, recursively execute their turn CombatantTurnQueue.Dequeue(); if (CurrCombatant.Allegiance == Allegiance.ENEMY) { ExecuteEnemyTurn(); } else { // The next combatant is player controlled, so let's wait for // PlayerMenuController to execute the turn State = BattleState.PLAYERCHOICE; } }
private void Update() { // If the combatant is involved in an animation currently, we have to // wait for that to finish if (!ResolvedAurasThisTurn) { if (CurrCombatant.Allegiance == Allegiance.ENEMY) { if (currentlyAnimatingCombatants.Count > 0) { return; } } else { if (currentlyAnimatingCombatants.Contains(CurrCombatantID)) { return; } } } // Resolve all auras affecting the current combatant if (!ResolvedAurasThisTurn) { Debug.Log("~~~~~~~~~~~"); Debug.Log(CurrCombatant.Name + "[" + CurrCombatantID + "]'s turn!"); CurrCombatant.ResolveAuras(); ResolvedAurasThisTurn = true; } if (CurrCombatant.Allegiance == Allegiance.ENEMY) { // For enemies, execute their turn straight away ((EnemyController)CurrCombatant).DoTurn(); } else { // For players, we've got to wait until PlayerMenuController takes // the player turn // // This is pretty grim (why are we running update cycles if nothing's // happening?) but whatever, sue me if (WaitingOnPlayerTurn) { return; } } // The turn has been executed; prepare for the next one CombatantTurnQueue.Dequeue(); ++TurnNum; if (CurrCombatant.Allegiance == Allegiance.PLAYER) { State = BattleState.PLAYERCHOICE; WaitingOnPlayerTurn = true; } else { State = BattleState.ENEMYCHOICE; WaitingOnPlayerTurn = false; } ResolvedAurasThisTurn = false; GenerateNewTurnEntry(); }