Exemplo n.º 1
0
    void OnGUI()
    {
        // displays wave counter
        GUI.skin = retryButton;
        GUI.Label(new Rect(20, 20, 170, 20), "WAVE: " + currentWave);

        // displays retry + how long player survived
        if (GameObject.Find("Player") == null)
        {
            playerMovement.whiteShip  = true;
            playerMovement.redShip    = false;
            playerMovement.yellowShip = false;
            playerMovement.blueShip   = false;
            waveSurvived = currentWave;
            GUI.skin     = retryButton;
            storeHighscore(currentWave);
            if (gameModeSelectGUI.level == "level1")
            {
                GUI.Label(new Rect(Screen.width / 2 - 200, Screen.height / 2 - 180, 400, 100), "HIGHEST WAVE: " + PlayerPrefs.GetInt("shootHighScore"));
            }
            if (gameModeSelectGUI.level == "level2")
            {
                GUI.Label(new Rect(Screen.width / 2 - 200, Screen.height / 2 - 180, 400, 100), "HIGHEST WAVE: " + PlayerPrefs.GetInt("smashHighScore"));
            }
            if (gameModeSelectGUI.level == "level3")
            {
                GUI.Label(new Rect(Screen.width / 2 - 200, Screen.height / 2 - 180, 400, 100), "HIGHEST WAVE: " + PlayerPrefs.GetInt("standardHighScore"));
            }
            GUI.Label(new Rect(Screen.width / 2 - 200, Screen.height / 2 - 80, 400, 100), "YOU SURVIVED UNTIL WAVE: " + waveSurvived);
            if (GUI.Button(new Rect(Screen.width / 2 - 100, Screen.height / 2, 200, 100), "RETRY"))
            {
                Application.LoadLevel(gameModeSelectGUI.level);
                currentWave = 0;
            }
            if (GUI.Button(new Rect(Screen.width / 2 - 100, Screen.height / 2 + 150, 200, 100), "QUIT"))
            {
                Application.LoadLevel("mainMenu");
                Time.timeScale            = 1;
                playerMovement.whiteShip  = true;
                playerMovement.redShip    = false;
                playerMovement.yellowShip = false;
                playerMovement.blueShip   = false;
            }
        }

        // displays colour change buttons if in suitable gamemode
        if (gameModeSelectGUI.level != "level3")
        {
            GUI.skin = whiteButton;
            if (GUI.Button(new Rect(Screen.width - 100, 0, 100, Screen.height / 4), ""))
            {
                ship.changeShipTexture(whiteShip);
                playerMovement.whiteShip  = true;
                playerMovement.redShip    = false;
                playerMovement.yellowShip = false;
                playerMovement.blueShip   = false;
            }
            GUI.skin = redButton;
            if (GUI.Button(new Rect(Screen.width - 100, Screen.height / 4, 100, Screen.height / 4), ""))
            {
                ship.changeShipTexture(redShip);
                playerMovement.whiteShip  = false;
                playerMovement.redShip    = true;
                playerMovement.yellowShip = false;
                playerMovement.blueShip   = false;
            }
            GUI.skin = yellowButton;
            if (GUI.Button(new Rect(Screen.width - 100, Screen.height / 2, 100, Screen.height / 4), ""))
            {
                ship.changeShipTexture(yellowShip);
                playerMovement.whiteShip  = false;
                playerMovement.redShip    = false;
                playerMovement.yellowShip = true;
                playerMovement.blueShip   = false;
            }
            GUI.skin = blueButton;
            if (GUI.Button(new Rect(Screen.width - 100, Screen.height / 4 * 3, 100, Screen.height / 4), ""))
            {
                ship.changeShipTexture(blueShip);
                playerMovement.whiteShip  = false;
                playerMovement.redShip    = false;
                playerMovement.yellowShip = false;
                playerMovement.blueShip   = true;
            }
        }

        // displays pause button
        GUI.skin = pauseSkin;
        if (GUI.Button(new Rect(10, Screen.height - 50, 40, 40), ""))
        {
            if (paused == true)
            {
                paused         = false;
                Time.timeScale = 1;
            }
            else
            {
                paused = true;
            }
        }
        if (paused == true)
        {
            Time.timeScale = 0;
            GUI.skin       = retryButton;
            GUI.Label(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 80, 200, 100), "PAUSED");
            if (GUI.Button(new Rect(Screen.width / 2 - 100, Screen.height / 2, 200, 100), "RETRY"))
            {
                Application.LoadLevel(gameModeSelectGUI.level);
                paused                    = false;
                Time.timeScale            = 1;
                playerMovement.whiteShip  = true;
                playerMovement.redShip    = false;
                playerMovement.yellowShip = false;
                playerMovement.blueShip   = false;
            }
            if (GUI.Button(new Rect(Screen.width / 2 - 100, Screen.height / 2 + 150, 200, 100), "QUIT"))
            {
                Application.LoadLevel("mainMenu");
                paused                    = false;
                Time.timeScale            = 1;
                playerMovement.whiteShip  = true;
                playerMovement.redShip    = false;
                playerMovement.yellowShip = false;
                playerMovement.blueShip   = false;
            }
        }
    }