//void StartTurn() //{ // //Debug.Log("StartTurn"); // //bool canStart = false; // // Verify if battle has not ended yet, if there are still units which can fight on both sides // if (CanContinueBattle()) // { // // Reset hasMoved flag on all units, so they can now move again; // ResetHasMovedFlag(); // // Reset turn phase to main // SetTurnPhase(TurnPhase.Main); // // loop through all units according to their initiative // // Activate unit with the highest initiative // ActivateNextUnit(); // //canStart = ActivateNextUnit(); // } // else // { // Queue.Run(EndBattle()); // } // //return canStart; //} void StartTurn() { // Reset hasMoved flag on all units, so they can now move again; ResetHasMovedFlag(); // Reset turn phase to main BattleTurnPhase = BattleTurnPhase.Main; // Activate unit with the highest initiative ActivateNextUnit(); }
public bool GetCanBeGivenATurnInBattle(BattleTurnPhase turnPhase) { switch (turnPhase) { case BattleTurnPhase.Main: return(canBeGivenATurnInBattleDuringMainPhase); case BattleTurnPhase.PostWait: return(canBeGivenATurnInBattleDuringPostWaitPhase); default: Debug.LogError("Unknown turn phase: " + turnPhase); return(false); } }
PartyUnitUI FindNextUnit() { // Find unit with the highest initiative, which can still move during this turn in battle PartyUnitUI playerNextUnitUI = playerPartyPanel.GetActiveUnitUIWithHighestInitiativeWhichHasNotMoved(BattleTurnPhase); PartyUnitUI enemyNextUnitUI = enemyPartyPanel.GetActiveUnitUIWithHighestInitiativeWhichHasNotMoved(BattleTurnPhase); // verify if player and enemy has more units to move if (playerNextUnitUI && enemyNextUnitUI) { // both parties still have units to move return(GetPartyUnitUIWithHighestInitiative(playerNextUnitUI, enemyNextUnitUI)); } else { // some parties do not have units to move // find which party has and which does not have if (playerNextUnitUI) { // player has next unit, return it return(playerNextUnitUI); } else if (enemyNextUnitUI) { // player has next unit, return it return(enemyNextUnitUI); } else { // no any pary has units to move // verify current phase if (BattleTurnPhase.Main == BattleTurnPhase) { // do the same check but for units, which are in waiting status BattleTurnPhase = BattleTurnPhase.PostWait; return(FindNextUnit()); } else { // return null, this should initiate new battle turn return(null); } } } }