Пример #1
0
    // Update is called once per frame
    void Update()
    {
        switch (currentBattlePhase)
        {
        case BattlePhase.BattleStart:
            if (!startingBattle)
            {
                startingBattle = true;

                for (int j = 0; j < battlers.Length; j++)
                {
                    StartCoroutine(CombatUI.Instance.UpdateHealthBar(
                                       (double)battlers[j].GetComponent <Battler>().battleState.currentHealth,
                                       (double)battlers[j].GetComponent <Battler>().battleState.maximumHealth,
                                       battlers[j].name == "PlayerDuringBattle"));
                }

                StartCoroutine(CombatUI.Instance.DisplayBlockingMessage("The battle has started."));
            }

            if (!blockedByMessage)
            {
                currentBattlePhase = BattlePhase.ChooseAction;
            }

            break;

        case BattlePhase.ChooseAction:     //player always chooses action last
            if (!choosingAction)
            {
                if (!blockedByMessage)
                {
                    choosingAction = true;

                    if (playerTurnChooseAction)
                    {
                        StartCoroutine(playerBattler.ChooseAction(FinishChoosingAction));
                    }
                    else
                    {
                        //skip player until all non-player battlers have chosen their action
                        if (activeBattler == playerBattler)
                        {
                            activeBattlerIndex++;
                            activeBattler = battlers[activeBattlerIndex].GetComponent <Battler>();
                        }

                        StartCoroutine(activeBattler.ChooseAction(FinishChoosingAction));
                    }
                }
            }
            break;

        case BattlePhase.DoAction:
            if (!doingAction)
            {
                doingAction = true;
                StartCoroutine(activeBattler.DoAction(FinishDoingAction));
            }
            break;

        case BattlePhase.BattleEnd:
            if (!endingBattle)
            {
                endingBattle = true;

                BattleState playerBattleState = PlayerStateManager.Instance.PlayerBattleState;
                playerBattleState.statusEffects.RemoveAll(se => se.limitedDuration);
            }

            if (!blockedByMessage)
            {
                if (!exitingBattle)
                {
                    exitingBattle = true;
                    StartCoroutine(SceneTransitionManager.Instance.ExitBattle(lostBattle));
                }
            }

            break;

        default:
            break;
        }
    }