예제 #1
0
    void Update()
    {
        if (!_battleStarted && !banner.isAnimating)
        {
            _battleStarted = true;

            player1.enable = true;
            player1.UpdateHumanInput();

            if (SelectMode.Instance.isthereP2 == true)
            {
                player2.enable      = true;
                player2.playerIndex = Fighter.PlayerIndex.Player2;
                player2.UpdateHumanInput();
            }
            else if (SelectMode.Instance.isthereP2 == false)
            {
                player2.enable      = true;
                player2.playerIndex = Fighter.PlayerIndex.PlayerAI;
                player2.UpdateAiInput();
            }

            AudioManager.PlaySound(backgroundMusic, musicPlayer);
        }

        if (_battleStarted && !_battleEnded)
        {
            if (roundTime > 0 && Time.time - _lastTimeUpdate > 1)
            {
                roundTime--;
                _lastTimeUpdate = Time.time;

                if (roundTime == 0)
                {
                    ExpireTime();
                }
            }

            if (player1.HealthPercent <= 0)
            {
                banner.showWinner(player2);
                _battleEnded = true;
                StartCoroutine(LoadAfterDelay(6f));
            }
            else if (player2.HealthPercent <= 0)
            {
                banner.showWinner(player1);
                _battleEnded = true;
                StartCoroutine(LoadAfterDelay(6f));
            }
        }
    }