Exemple #1
0
 public void StartTurnLogic()
 {
     currentState = BattlefieldStateMachine.PRESTART;
 }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        switch (currentState)
        {
        case (BattlefieldStateMachine.WAIT):
            // idle
            break;

        case (BattlefieldStateMachine.PRESTART):
            FillActiveCharsByInitiative();
            currentState = BattlefieldStateMachine.PERFORMTURN;
            break;

        case (BattlefieldStateMachine.PERFORMTURN):
            if (CharactersByInitiative.Any() && checkIfEnemiesLeft(battlefield.characters) &&
                checkIfAlliesLeft(battlefield.characters))
            {
                battlefield.UIManager.updateOrderQueue(CharactersByInitiative);
                battlefield.UIManager.updateUIToChosenCharacter(CharactersByInitiative[0]);
                lastActiveCharacter = CharactersByInitiative[0];
                currentState        = BattlefieldStateMachine.WAIT;

                if (CharactersByInitiative[0].playerControlled)
                {
                    CharactersByInitiative[0].characterState = Character.CharacterStateMachine.CHOOSEACTION;
                }
                else
                {
                    CharactersByInitiative[0].performAITurn();
                }
            }
            else
            {
                currentState = BattlefieldStateMachine.ENDTURN;
            }
            break;

        case (BattlefieldStateMachine.ENDTURN):
            if (checkIfEnemiesLeft(battlefield.characters) && checkIfAlliesLeft(battlefield.characters))
            {
                Debug.Log("<color=green>-----NEW TURN HAS STARTED-----</color>");
                UIM.updateTurnCounter(++currentTurn);
                //UpdateCharactersStats();
                FillActiveCharsByInitiative();
                currentState = BattlefieldStateMachine.PERFORMTURN;
            }
            else
            {
                currentState = BattlefieldStateMachine.RESULTSCREEN;
            }
            break;

        case (BattlefieldStateMachine.RESULTSCREEN):
            MSM.currentMouseState = MouseStateManager.MouseStateMachine.IDLE;
            Debug.Log("GAME FINISHED");

            if (!checkIfEnemiesLeft(battlefield.characters))
            {
                UIM.battleOutcome.text            = "VICTORY";
                UIM.battleOutcomeDescription.text = "All enemies has been defeated!";
            }
            else
            {
                UIM.battleOutcome.text            = "LOSE";
                UIM.battleOutcomeDescription.text = "You have been defeated!";
            }
            UIM.ResultScreenWindow.SetActive(true);

            currentState = BattlefieldStateMachine.WAIT;
            break;
        }
    }