Пример #1
0
    // Update is called once per frame
    void Update()
    {
        switch (currentState)
        {
        case (BattleStates.START):
            battleStateStart.PrepareBattle();
            break;

        case (BattleStates.PLAYER_TURN):
            currentTurnOwner = BattleStates.PLAYER_TURN;
            break;

        case (BattleStates.ENEMY_TURN):

            if (!_hasStun && !_hasSleep)
            {
                currentTurnOwner = BattleStates.ENEMY_TURN;
                battleStateEnemyTurn.TakeTurn();
            }
            else
            {
                CheckForStatusEffect();
            }
            //enemyCompletedTurn = true;
            //CheckTurnOwner ();
            break;

        case (BattleStates.CALCULATE_DAMAGE):
            sm.PlaySingleEfx(1);
            if (currentTurnOwner == BattleStates.PLAYER_TURN)
            {
                if (battleCalculations.GetPlayerAbilityCost(playerAbility) <= battleScreenManager._playerAmbition)
                {
                    ApplyStatusEffect(playerAbility.AbilityStatusEffect);

                    playerAnimator.SetTrigger("isAttacking");
                    battleScreenManager._enemyHealth    -= battleCalculations.CalculateTotalPlayerDamage(playerAbility);
                    battleScreenManager._playerAmbition -= battleCalculations.GetPlayerAbilityCost(playerAbility);
                }

                if (_hasStun || _hasSleep)
                {
                    enemyCompletedTurn = true;
                }

                if (battleScreenManager._enemyHealth <= 0)
                {
                    currentState = BattleStates.WIN;
                    Debug.Log("Won the battle!");
                    break;
                }
            }
            if (currentTurnOwner == BattleStates.ENEMY_TURN)
            {
                if (!_hasStun && !_hasSleep)
                {
                    enemyAnimator.SetTrigger("isAttacking");
                    battleScreenManager._playerHealth  -= battleCalculations.CalculateTotalEnemyDamage(enemyAbility);
                    battleScreenManager._enemyAmbition -= battleCalculations.GetEnemyAbilityCost(enemyAbility);
                }
                else
                {
                    break;
                }

                if (battleScreenManager._playerHealth <= 0)
                {
                    currentState = BattleStates.LOSE;
                    battleScreenManager.LoseDebate();
                    break;
                }
            }
            CheckTurnOwner();
            break;

        // case (BattleStates.ADD_STATUS_EFFECTS):
        //  battleStateAddStatusEffectsScript.CheckAbilityForStatusEffect (playerUsedAbility);
        //  break;
        case (BattleStates.END_TURN):
            totalTurnCount = totalTurnCount + 1;
            Debug.Log(totalTurnCount);
            playerCompletedTurn = false;
            enemyCompletedTurn  = false;

            if (battleStateStart._playerEloquence > battleStateStart._enemyEloquence)
            {
                currentState = BattleStates.PLAYER_TURN;
            }
            else
            {
                currentState = BattleStates.ENEMY_TURN;
            }
            break;

        case (BattleStates.LOSE):
            //battleScreenManager.LoseBattle();
            break;

        case (BattleStates.WIN):
            Debug.Log(BattleScreenManager.isQuest);
            if (BattleScreenManager.isQuest)
            {
                battleScreenManager.WinBattleFromQuest();
            }
            else
            {
                battleScreenManager.WinBattleFromEvent();
            }
            break;
        }
    }