Exemple #1
0
    /**
     * Handles drawing of game over popup menu
     */
    void OnGUI()
    {
        float scale       = 234f / 489f;
        float buttonWidth = Screen.width * 0.1591796875f;


        // draw the game over popup box in the middle of the screen
        GUI.DrawTexture(new Rect(Screen.width * 0.26953125f,
                                 Screen.height * 0.18359375f,
                                 Screen.width * 0.4609375f,
                                 Screen.height * 0.6328125f), gameOverPopup);

        // draw restart button
        if (GUI.Button(new Rect(Screen.width * 0.3251953125f,
                                Screen.height * 0.66666666666f,
                                buttonWidth,
                                buttonWidth * scale), "", restart))
        {
            // if restart is pressed
            Time.timeScale = 1;                                                                 // unpause the game
            GameObject chooseBackground          = GameObject.Find("ChooseBackground");         // find the background chooser
            SmallIntestineLoadLevelCounter level = chooseBackground.GetComponent <SmallIntestineLoadLevelCounter>();

            // restart from the correct level
            if (level.getLevel() % 2 == 0)
            {
                Application.LoadLevel("SmallIntestineEven");
            }
            else
            {
                Application.LoadLevel("SmallIntestineOdd");
            }
        }

        // draw main menu button
        if (GUI.Button(new Rect(Screen.width * 0.5166015625f,
                                Screen.height * 0.66666666666f,
                                buttonWidth,
                                buttonWidth * scale), "", mainMenu))
        {
            // if main menu is selected
            Time.timeScale = 1;                                                         // unpause the game
            GameObject chooseBackground          = GameObject.Find("ChooseBackground"); // find the background chooser
            SmallIntestineLoadLevelCounter level = chooseBackground.GetComponent <SmallIntestineLoadLevelCounter>();
            level.resetLevel();                                                         // reset the small intestine current level to 1 for next time
            Application.LoadLevel("MainMenu");                                          // load the main menu
        }
    }
Exemple #2
0
    /**
     * Handles drawing of game over popup menu
     */
    void OnGUI()
    {
        // draw the game over popup box in the middle of the screen
        GUI.DrawTexture(new Rect(Screen.width * 0.3193359375f,
                                 Screen.height * 0.28515625f,
                                 Screen.width * 0.3603515625f,
                                 Screen.height * 0.248697917f), gameOverPopup);

        // draw restart button
        if (GUI.Button(new Rect(Screen.width * 0.41015625f,
                                Screen.height * 0.41927083f,
                                Screen.width * 0.0654296875f,
                                Screen.height * 0.06640625f), "", restart))
        {
            // if restart is pressed
            Time.timeScale = 1;                                                                 // unpause the game
            GameObject chooseBackground          = GameObject.Find("ChooseBackground");         // find the background chooser
            SmallIntestineLoadLevelCounter level = chooseBackground.GetComponent <SmallIntestineLoadLevelCounter>();

            // restart from the correct level
            if (level.getLevel() % 2 == 0)
            {
                Application.LoadLevel("SmallIntestineEven");
            }
            else
            {
                Application.LoadLevel("SmallIntestineOdd");
            }
        }

        // draw main menu button
        if (GUI.Button(new Rect(Screen.width * 0.53125f,
                                Screen.height * 0.41927083f,
                                Screen.width * 0.0654296875f,
                                Screen.height * 0.06640625f), "", mainMenu))
        {
            // if main menu is selected
            Time.timeScale = 1;                                                         // unpause the game
            GameObject chooseBackground          = GameObject.Find("ChooseBackground"); // find the background chooser
            SmallIntestineLoadLevelCounter level = chooseBackground.GetComponent <SmallIntestineLoadLevelCounter>();
            level.resetLevel();                                                         // reset the small intestine current level to 1 for next time
            Application.LoadLevel("MainMenu");                                          // load the main menu
        }
    }
Exemple #3
0
    private bool confirmUp;             //!< flag whether or not the confirm box should be shown

    /**
     * Draws the return button plus the associated pop up box
     */
    void OnGUI()
    {
        GUI.depth = GUI.depth - 100;

        // this just handles the menu button in the corner
        if (Time.timeScale != 0)
        {
            if (GUI.Button(new Rect(Screen.width * .89f,
                                    Screen.height * 0.01822916f,
                                    Screen.width * .09f,
                                    Screen.height * .06f), "", mainMenuStyle))
            {
                Time.timeScale = 0;                             // pause the game
                confirmUp      = true;                          // throw flag
            }
        }

        // if the menu button has been pressed
        if (confirmUp)
        {
            GUI.depth--;

            // draw gui texture that holds box with buttons
            GUI.DrawTexture(new Rect(Screen.width * 0.3193359375f,
                                     Screen.height * 0.28515625f,
                                     Screen.width * 0.3603515625f,
                                     Screen.height * 0.248697917f), confirmPopup);

            // draw yes button
            if (GUI.Button(new Rect(Screen.width * 0.41015625f,
                                    Screen.height * 0.41927083f,
                                    Screen.width * 0.0654296875f,
                                    Screen.height * 0.06640625f), "", confirmYes))
            {
                // if the "yes" button was pressed
                Time.timeScale = 1;                                             // unpause the game
                GameObject chooseBackground = GameObject.Find("ChooseBackground");

                // reset the level for the si game for next time it is loaded
                if (chooseBackground != null)
                {
                    SmallIntestineLoadLevelCounter level = chooseBackground.GetComponent <SmallIntestineLoadLevelCounter>();
                    level.resetLevel();
                }

                // load the main menu
                Application.LoadLevel("MainMenu");
            }

            // draw no button
            if (GUI.Button(new Rect(Screen.width * 0.53125f,
                                    Screen.height * 0.41927083f,
                                    Screen.width * 0.0654296875f,
                                    Screen.height * 0.06640625f), "", confirmNo))
            {
                // if the "no" button was pressed
                Time.timeScale = 1;                                     // unpause the game
                confirmUp      = false;                                 // throw the flag to indicate not to show the confirm box anymore
            }
        }
    }