Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (!battleStarted)
        {
            if (GameManager.gm.gameMode != "practice")
            {
                banner.Fight();
            }

            battleStarted  = true;
            currentRound  += 1;
            player1.enable = true;
            player2.enable = true;
        }

        if (battleStarted && !battleEnded)
        {
            if (roundTime > 0 && Time.time - lastTimeUpdate > 1)
            {
                roundTime--;
                lastTimeUpdate = Time.time;
                if (roundTime == 0)
                {
                    ExpireTime();
                }
            }

            if (player1.healthPercent <= 0)
            {
                if (GameManager.gm.userAmount == 1)
                {
                    banner.YouLose();
                }
                else if (GameManager.gm.userAmount == 2)
                {
                    banner.P2Win();
                }
                p2Win++;
                battleEnded = true;
            }
            else if (player2.healthPercent <= 0)
            {
                if (GameManager.gm.userAmount == 1)
                {
                    banner.YouWin();
                }
                else if (GameManager.gm.userAmount == 2)
                {
                    banner.P1Win();
                }
                p1Win++;
                battleEnded = true;
            }
        }

        if (GameManager.gm.gameMode == "practice")
        {
            player1.health = 1000;
            player2.health = 1000;
        }

        if (Input.GetButtonDown("Pause"))
        {
            paused = true;
        }
        if (paused)
        {
            Time.timeScale = 0;
            pausePanel.SetActive(true);
        }
        else if (!paused)
        {
            Time.timeScale = 1;
            pausePanel.SetActive(false);
        }

        //Debug
        if (paused)
        {
            if (GameManager.gm.gameMode == "arcade")
            {
                if (Input.GetKeyDown(KeyCode.F12))
                {
                    newHighscore.SetActive(true);
                    noHighscore.SetActive(true);
                }
            }
        }
    }