Beispiel #1
0
    /// <summary>
    /// Update is called once per frame and updates the timer if needed
    /// </summary>
    void Update()
    {
        checkPlayers();

        //Shows and updates Player 1 score
        p1_Score.text = "Player 1:  " + Player1.getKills() + " Kills | " + Player1.getTotalCoins() + " Gold | " + " Points " + Player1.GetFinalScore();
        //Shows and updates Player 2 score
        p2_Score.text = "Player 2:  " + Player2.getKills() + " Kills | " + Player2.getTotalCoins() + " Gold | " + " Points " + Player2.GetFinalScore();
        //Shows and updates Player 3 score
        p3_Score.text = "Player 3:  " + Player3.getKills() + " Kills | " + Player3.getTotalCoins() + " Gold | " + " Points " + Player3.GetFinalScore();
        //Shows and updates Player 4 score
        p4_Score.text = "Player 4:  " + Player4.getKills() + " Kills | " + Player4.getTotalCoins() + " Gold | " + " Points " + Player4.GetFinalScore();
        //time ends new wave starts

        bool playersAlive = false;

        foreach (PlayerPoints child in players)
        {
            if (child.GetComponent <PlayerDamageHandler>().lives > 0)
            {
                playersAlive = true;
            }
        }
        gameLost = !playersAlive;
        if (waveMaster.waveCount == finalWaveNumber + 1 || gameLost)
        {
            bool countingScore = true;
            if (countingScore)
            {
                Player1.FinalScore();
                Player2.FinalScore();
                Player3.FinalScore();
                Player4.FinalScore();
                countingScore = false;
            }
            if (gameLost)
            {
                p1_UI.SetActive(false);
                p2_UI.SetActive(false);
                p3_UI.SetActive(false);
                p4_UI.SetActive(false);
                gameEndText.text = "Game Over";
            }
            else
            {
                p1_UI.SetActive(false);
                p2_UI.SetActive(false);
                p3_UI.SetActive(false);
                p4_UI.SetActive(false);
                gameEndText.text = "Level Complete";
            }

            //gameover
            //gameOver.SetActive(true);
            results.SetActive(true);
            if (!pointsShown)
            {
                GameOverPoints();
            }
            //else if(gameEndTimer > 0)
            //{
            //    gameEndTimer -= Time.unscaledDeltaTime;
            //
            //}
            if (XboxCtrlrInput.XCI.GetButtonDown(XboxCtrlrInput.XboxButton.A, XboxCtrlrInput.XboxController.All) || Input.GetKey(KeyCode.Backspace))
            {
                Time.timeScale = 1;
                SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
            }
        }
    }