Beispiel #1
0
    public void OnGUI(bool mainMenuOption)
    {
        if (mainMenuOption)
        {
            m_pausedMenuState = PausedMenuState.Options;
            OnOptionsMenu(true);
            return;
        }

        switch (m_pausedMenuState)
        {
        case PausedMenuState.Main:
            OnMainPausedMenu();
            break;

        case PausedMenuState.Options:
            OnOptionsMenu(false);
            break;

        case PausedMenuState.MainMenu:
        case PausedMenuState.Quit:
        case PausedMenuState.Restart:
            AreYouSureMenu();
            break;
        }
        ;

        if (m_isController)
        {
            GUI.FocusControl(m_highlighted);
        }
    }
Beispiel #2
0
    private void OnMainPausedMenu()
    {
        const float BUTTON_WIDTH = 256;

        float yPosition = 100;

        string  pausedText      = "Paused";
        Vector2 textDimensions  = GUI.skin.label.CalcSize(new GUIContent(pausedText));
        Rect    pausedLabelRect = new Rect((Screen.width * 0.5f) - (textDimensions.x * 0.5f), yPosition, textDimensions.x, textDimensions.y);

        GUI.Label(pausedLabelRect, pausedText);

        yPosition += 96;
        Rect continueRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 32);

        if (GUI.Button(continueRect, "Continue"))
        {
            m_playerEntity.CurrentGameState = GameState.Running;
            Time.timeScale = 1.0f;
            return;
        }

        yPosition += 42;
        Rect restartRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 32);

        if (GUI.Button(restartRect, "Restart Level"))
        {
            m_pausedMenuState = PausedMenuState.Restart;
            return;
        }

        yPosition += 42;
        Rect optionsRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 32);

        if (GUI.Button(optionsRect, "Options"))
        {
            m_pausedMenuState = PausedMenuState.Options;
            return;
        }

        yPosition += 84;
        Rect mainMenuRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f) - 5, yPosition, BUTTON_WIDTH * 0.5f, 32);

        if (GUI.Button(mainMenuRect, "Main Menu"))
        {
            m_pausedMenuState = PausedMenuState.MainMenu;
            return;
        }

        Rect quitRect = new Rect((Screen.width * 0.5f) + 5, yPosition, BUTTON_WIDTH * 0.5f, 32);

        if (GUI.Button(quitRect, "Quit"))
        {
            m_pausedMenuState = PausedMenuState.Quit;
            return;
        }
    }
Beispiel #3
0
    private void OnOptionsMenu(bool mainMenuOption)
    {
        const float BUTTON_WIDTH = 256;
        float       yPosition    = 100;

        if (!mainMenuOption)
        {
            string  pausedText      = "Options";
            Vector2 textDimensions  = GUI.skin.label.CalcSize(new GUIContent(pausedText));
            Rect    pausedLabelRect = new Rect((Screen.width * 0.5f) - (textDimensions.x * 0.5f), yPosition, textDimensions.x, textDimensions.y);
            GUI.Label(pausedLabelRect, pausedText);
        }

        yPosition += 96;

        GUI.skin.button.fontSize = 22;
        string[] graphicsLevels = QualitySettings.names;
        Rect     selectionRect  = new Rect((Screen.width * 0.5f) - 256, yPosition, 512, 64);

        if (mainMenuOption)
        {
            selectionRect = new Rect((Screen.width * 0.3f) - 256, yPosition + 120.0f, 512, 64);
        }

        GUI.SetNextControlName("graphics");
        int selected = GUI.SelectionGrid(selectionRect, QualitySettings.GetQualityLevel(), graphicsLevels, graphicsLevels.Length);

        if (selected != -1)
        {
            QualitySettings.SetQualityLevel(selected);
            ApplyOptions();
        }

        GUI.skin.button.fontSize = 48;

        yPosition += 64;
        yPosition += 42;

        Rect backRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 48);

        if (mainMenuOption)
        {
            backRect = new Rect((Screen.width * 0.3f) - (BUTTON_WIDTH * 0.5f), yPosition + 120.0f, BUTTON_WIDTH, 48);
        }

        GUI.SetNextControlName("back");
        if (GUI.Button(backRect, "Back") || (m_pressedOK && m_highlighted == "back"))
        {
            m_pressedOK       = false;
            m_highlighted     = "options";
            m_pausedMenuState = PausedMenuState.Main;
            return;
        }
    }
Beispiel #4
0
    void Options(int hit)
    {
        switch (hit)
        {
        case 0:
            currentPausedMenuState = PausedMenuState.inputMenu;
            optionsMenu.UnClickAll();
            break;

        case 1:
            currentPausedMenuState = PausedMenuState.soundMenu;
            optionsMenu.UnClickAll();
            break;

        case 2:
            currentPausedMenuState = PausedMenuState.graphicsMenu;
            optionsMenu.UnClickAll();
            break;
        }
    }
Beispiel #5
0
    void Pause(int hit)
    {
        switch (hit)
        {
        case 0:
            currentPausedMenuState = PausedMenuState.optionsMenu;
            mainPauseMenu.UnClickAll();
            break;

        case 1:
            Application.LoadLevel("MainMenu");
            paused         = false;
            Time.timeScale = 1;
            mainPauseMenu.UnClickAll();
            break;

        case 2:
            Application.Quit();
            paused         = false;
            Time.timeScale = 1;
            mainPauseMenu.UnClickAll();
            break;
        }
    }
Beispiel #6
0
    private void AreYouSureMenu()
    {
        string labelText = "Are you sure you want to ";

        switch (m_pausedMenuState)
        {
        case PausedMenuState.MainMenu:
            labelText += "return to the main menu?";
            break;

        case PausedMenuState.Quit:
            labelText += "quit the game?";
            break;

        case PausedMenuState.Restart:
            labelText += "restart the current level?";
            break;
        }
        ;

        const float BUTTON_WIDTH = 256;
        float       yPosition    = 100;

        Vector2 textDimensions = GUI.skin.label.CalcSize(new GUIContent(labelText));
        Rect    labelRect      = new Rect((Screen.width * 0.5f) - (textDimensions.x * 0.5f), yPosition, textDimensions.x, textDimensions.y);

        GUI.Label(labelRect, labelText);

        yPosition += 96;

        Rect yesRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f) - 5, yPosition, BUTTON_WIDTH * 0.5f, 48);

        GUI.SetNextControlName("yes");
        if (GUI.Button(yesRect, "Yes") || (m_pressedOK && m_highlighted == "yes"))
        {
            m_pressedOK   = false;
            m_highlighted = "continue";

            if (m_pausedMenuState == PausedMenuState.Quit)
            {
                Application.Quit();
            }
            else if (m_pausedMenuState == PausedMenuState.MainMenu)
            {
                Time.timeScale = 1.0f;
                Application.LoadLevel("Main_Menu");
                m_pausedMenuState = PausedMenuState.Main;
            }
            else if (m_pausedMenuState == PausedMenuState.Restart)
            {
                string currentLevel = CEntityPlayer.GetInstance().CurrentLevel;
                Time.timeScale = 1.0f;
                Application.LoadLevel(currentLevel);
                m_pausedMenuState = PausedMenuState.Main;
            }

            return;
        }

        Rect noRect = new Rect((Screen.width * 0.5f) + 5, yPosition, BUTTON_WIDTH * 0.5f, 48);

        GUI.SetNextControlName("no");
        if (GUI.Button(noRect, "No") || (m_pressedOK && m_highlighted == "no"))
        {
            m_pausedMenuState = PausedMenuState.Main;
            m_pressedOK       = false;
            m_highlighted     = "continue";
            return;
        }
    }
    public void OnGUI(bool mainMenuOption)
    {
        if (mainMenuOption) {
            m_pausedMenuState = PausedMenuState.Options;
            OnOptionsMenu(true);
            return;
        }

        switch (m_pausedMenuState)
        {
        case PausedMenuState.Main:
            OnMainPausedMenu();
            break;

        case PausedMenuState.Options:
            OnOptionsMenu(false);
            break;

        case PausedMenuState.MainMenu:
        case PausedMenuState.Quit:
        case PausedMenuState.Restart:
            AreYouSureMenu();
            break;
        };

        if (m_isController)
        {
            GUI.FocusControl (m_highlighted);
        }
    }
    private void OnOptionsMenu(bool mainMenuOption)
    {
        const float BUTTON_WIDTH = 256;
        float yPosition = 100;

        if (!mainMenuOption) {
            string pausedText = "Options";
            Vector2 textDimensions = GUI.skin.label.CalcSize(new GUIContent(pausedText));
            Rect pausedLabelRect = new Rect((Screen.width * 0.5f) - (textDimensions.x * 0.5f), yPosition, textDimensions.x, textDimensions.y);
            GUI.Label(pausedLabelRect, pausedText);
        }

        yPosition += 96;

        GUI.skin.button.fontSize = 22;
        string[] graphicsLevels = QualitySettings.names;
        Rect selectionRect = new Rect((Screen.width * 0.5f) - 256, yPosition, 512, 64);
        if (mainMenuOption)
            selectionRect = new Rect((Screen.width * 0.3f) - 256, yPosition + 120.0f, 512, 64);

        GUI.SetNextControlName ("graphics");
        int selected = GUI.SelectionGrid(selectionRect, QualitySettings.GetQualityLevel(), graphicsLevels, graphicsLevels.Length);
        if (selected != -1)
        {
            QualitySettings.SetQualityLevel(selected);
            ApplyOptions();
        }

        GUI.skin.button.fontSize = 48;

        yPosition += 64;
        yPosition += 42;

        Rect backRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 48);
        if (mainMenuOption)
            backRect = new Rect((Screen.width * 0.3f) - (BUTTON_WIDTH * 0.5f), yPosition + 120.0f, BUTTON_WIDTH, 48);

        GUI.SetNextControlName ("back");
        if (GUI.Button(backRect, "Back") || (m_pressedOK && m_highlighted == "back"))
        {
            m_pressedOK = false;
            m_highlighted = "options";
            m_pausedMenuState = PausedMenuState.Main;
            return;
        }
    }
    private void OnMainPausedMenu()
    {
        const float BUTTON_WIDTH = 256;

        float yPosition = 100;

        string pausedText = "Paused";
        Vector2 textDimensions = GUI.skin.label.CalcSize(new GUIContent(pausedText));
        Rect pausedLabelRect = new Rect((Screen.width * 0.5f) - (textDimensions.x * 0.5f), yPosition, textDimensions.x, textDimensions.y);
        GUI.Label(pausedLabelRect, pausedText);

        yPosition += 96;
        Rect continueRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 48);
        GUI.SetNextControlName ("continue");
        if (GUI.Button(continueRect, "Continue") || (m_pressedOK && m_highlighted == "continue"))
        {
            m_pressedOK = false;
            m_highlighted = "continue";
            CEntityPlayer.GetInstance().CurrentGameState = GameState.Running;
            Time.timeScale = 1.0f;
            CEntityPlayer.GetInstance().Physics.SkipNextJump();
            return;
        }

        yPosition += 42;
        Rect restartRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 48);
        GUI.SetNextControlName ("restart");
        if (GUI.Button(restartRect, "Restart Level") || (m_pressedOK && m_highlighted == "restart"))
        {
            m_pressedOK = false;
            m_highlighted = "no";
            m_pausedMenuState = PausedMenuState.Restart;
            return;
        }

        yPosition += 42;
        Rect optionsRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 48);
        GUI.SetNextControlName ("options");
        if (GUI.Button(optionsRect, "Options") || (m_pressedOK && m_highlighted == "options"))
        {
            m_pressedOK = false;
            m_highlighted = "graphics";
            m_pausedMenuState = PausedMenuState.Options;
            return;
        }

        yPosition += 84;
        Rect mainMenuRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 48);
        GUI.SetNextControlName ("mainmenu");
        if (GUI.Button(mainMenuRect, "Main Menu") || (m_pressedOK && m_highlighted == "mainmenu"))
        {
            m_pressedOK = false;
            m_highlighted = "no";
            m_pausedMenuState = PausedMenuState.MainMenu;
            return;
        }

        yPosition += 42;
        Rect quitRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 48);
        GUI.SetNextControlName ("quit");
        if (GUI.Button(quitRect, "Quit") || (m_pressedOK && m_highlighted == "quit"))
        {
            m_pressedOK = false;
            m_highlighted = "no";
            m_pausedMenuState = PausedMenuState.Quit;
            return;
        }
    }
    private void AreYouSureMenu()
    {
        string labelText = "Are you sure you want to ";
        switch (m_pausedMenuState)
        {
        case PausedMenuState.MainMenu:
            labelText += "return to the main menu?";
            break;
        case PausedMenuState.Quit:
            labelText += "quit the game?";
            break;
        case PausedMenuState.Restart:
            labelText += "restart the current level?";
            break;
        };

        const float BUTTON_WIDTH = 256;
        float yPosition = 100;

        Vector2 textDimensions = GUI.skin.label.CalcSize(new GUIContent(labelText));
        Rect labelRect = new Rect((Screen.width * 0.5f) - (textDimensions.x * 0.5f), yPosition, textDimensions.x, textDimensions.y);
        GUI.Label(labelRect, labelText);

        yPosition += 96;

        Rect yesRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f) - 5, yPosition, BUTTON_WIDTH * 0.5f, 48);
        GUI.SetNextControlName ("yes");
        if (GUI.Button(yesRect, "Yes") || (m_pressedOK && m_highlighted == "yes"))
        {
            m_pressedOK = false;
            m_highlighted = "continue";

            if (m_pausedMenuState == PausedMenuState.Quit)
            {
                Application.Quit();
            }
            else if (m_pausedMenuState == PausedMenuState.MainMenu)
            {
                Time.timeScale = 1.0f;
                Application.LoadLevel("Main_Menu");
                m_pausedMenuState = PausedMenuState.Main;
            }
            else if (m_pausedMenuState == PausedMenuState.Restart)
            {
                string currentLevel = CEntityPlayer.GetInstance().CurrentLevel;
                Time.timeScale = 1.0f;
                Application.LoadLevel(currentLevel);
                m_pausedMenuState = PausedMenuState.Main;
            }

            return;
        }

        Rect noRect = new Rect((Screen.width * 0.5f) + 5, yPosition, BUTTON_WIDTH * 0.5f, 48);
        GUI.SetNextControlName ("no");
        if (GUI.Button(noRect, "No") || (m_pressedOK && m_highlighted == "no"))
        {
            m_pausedMenuState = PausedMenuState.Main;
            m_pressedOK = false;
            m_highlighted = "continue";
            return;
        }
    }
    private void OnMainPausedMenu()
    {
        const float BUTTON_WIDTH = 256;

        float yPosition = 100;

        string pausedText = "Paused";
        Vector2 textDimensions = GUI.skin.label.CalcSize(new GUIContent(pausedText));
        Rect pausedLabelRect = new Rect((Screen.width * 0.5f) - (textDimensions.x * 0.5f), yPosition, textDimensions.x, textDimensions.y);
        GUI.Label(pausedLabelRect, pausedText);

        yPosition += 96;
        Rect continueRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 32);
        if (GUI.Button(continueRect, "Continue"))
        {
            m_playerEntity.CurrentGameState = GameState.Running;
            Time.timeScale = 1.0f;
            return;
        }

        yPosition += 42;
        Rect restartRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 32);
        if (GUI.Button(restartRect, "Restart Level"))
        {
            m_pausedMenuState = PausedMenuState.Restart;
            return;
        }

        yPosition += 42;
        Rect optionsRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 32);
        if (GUI.Button(optionsRect, "Options"))
        {
            m_pausedMenuState = PausedMenuState.Options;
            return;
        }

        yPosition += 84;
        Rect mainMenuRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f) - 5, yPosition, BUTTON_WIDTH * 0.5f, 32);
        if (GUI.Button(mainMenuRect, "Main Menu"))
        {
            m_pausedMenuState = PausedMenuState.MainMenu;
            return;
        }

        Rect quitRect = new Rect((Screen.width * 0.5f) + 5, yPosition, BUTTON_WIDTH * 0.5f, 32);
        if (GUI.Button(quitRect, "Quit"))
        {
            m_pausedMenuState = PausedMenuState.Quit;
            return;
        }
    }
    private void AreYouSureMenu()
    {
        string labelText = "Are you sure you want to ";
        switch (m_pausedMenuState)
        {
        case PausedMenuState.MainMenu:
            labelText += "return to the main menu?";
            break;
        case PausedMenuState.Quit:
            labelText += "quit the game?";
            break;
        case PausedMenuState.Restart:
            labelText += "restart the current level?";
            break;
        };

        const float BUTTON_WIDTH = 256;
        float yPosition = 100;

        Vector2 textDimensions = GUI.skin.label.CalcSize(new GUIContent(labelText));
        Rect labelRect = new Rect((Screen.width * 0.5f) - (textDimensions.x * 0.5f), yPosition, textDimensions.x, textDimensions.y);
        GUI.Label(labelRect, labelText);

        yPosition += 96;

        Rect yesRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f) - 5, yPosition, BUTTON_WIDTH * 0.5f, 32);
        if (GUI.Button(yesRect, "Yes"))
        {
            if (m_pausedMenuState == PausedMenuState.Quit)
            {
                Application.Quit();
            }
            else if (m_pausedMenuState == PausedMenuState.MainMenu)
            {
                Time.timeScale = 1.0f;
                Application.LoadLevel("Main_Menu");
            }
            else if (m_pausedMenuState == PausedMenuState.Restart)
            {
                CCheckPoint cp = m_playerEntity.LastCheckPoint;
                CCheckPoint startCp = cp;
                while (cp.IsLevelStart == false)
                {
                    cp = cp.NextCheckPoint;
                    if (cp == startCp)
                    {
                        Debug.LogError("No check points in list where marked as level start");
                        return;
                    }
                }

                m_playerEntity.LastCheckPoint = cp;
                m_playerEntity.OnDeath();
                m_pausedMenuState = PausedMenuState.Main;

                Time.timeScale = 1.0f;
                m_playerEntity.CurrentGameState = GameState.Running;
            }

            return;
        }

        Rect noRect = new Rect((Screen.width * 0.5f) + 5, yPosition, BUTTON_WIDTH * 0.5f, 32);
        if (GUI.Button(noRect, "No"))
        {
            m_pausedMenuState = PausedMenuState.Main;
            return;
        }
    }
Beispiel #13
0
    private void AreYouSureMenu()
    {
        string labelText = "Are you sure you want to ";

        switch (m_pausedMenuState)
        {
        case PausedMenuState.MainMenu:
            labelText += "return to the main menu?";
            break;

        case PausedMenuState.Quit:
            labelText += "quit the game?";
            break;

        case PausedMenuState.Restart:
            labelText += "restart the current level?";
            break;
        }
        ;

        const float BUTTON_WIDTH = 256;
        float       yPosition    = 100;

        Vector2 textDimensions = GUI.skin.label.CalcSize(new GUIContent(labelText));
        Rect    labelRect      = new Rect((Screen.width * 0.5f) - (textDimensions.x * 0.5f), yPosition, textDimensions.x, textDimensions.y);

        GUI.Label(labelRect, labelText);

        yPosition += 96;

        Rect yesRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f) - 5, yPosition, BUTTON_WIDTH * 0.5f, 32);

        if (GUI.Button(yesRect, "Yes"))
        {
            if (m_pausedMenuState == PausedMenuState.Quit)
            {
                Application.Quit();
            }
            else if (m_pausedMenuState == PausedMenuState.MainMenu)
            {
                Time.timeScale = 1.0f;
                Application.LoadLevel("Main_Menu");
            }
            else if (m_pausedMenuState == PausedMenuState.Restart)
            {
                CCheckPoint cp      = m_playerEntity.LastCheckPoint;
                CCheckPoint startCp = cp;
                while (cp.IsLevelStart == false)
                {
                    cp = cp.NextCheckPoint;
                    if (cp == startCp)
                    {
                        Debug.LogError("No check points in list where marked as level start");
                        return;
                    }
                }

                m_playerEntity.LastCheckPoint = cp;
                m_playerEntity.OnDeath();
                m_pausedMenuState = PausedMenuState.Main;

                Time.timeScale = 1.0f;
                m_playerEntity.CurrentGameState = GameState.Running;
            }

            return;
        }

        Rect noRect = new Rect((Screen.width * 0.5f) + 5, yPosition, BUTTON_WIDTH * 0.5f, 32);

        if (GUI.Button(noRect, "No"))
        {
            m_pausedMenuState = PausedMenuState.Main;
            return;
        }
    }
Beispiel #14
0
    private void OnOptionsMenu()
    {
        const float BUTTON_WIDTH = 256;
        float       yPosition    = 100;

        string  pausedText      = "Options";
        Vector2 textDimensions  = GUI.skin.label.CalcSize(new GUIContent(pausedText));
        Rect    pausedLabelRect = new Rect((Screen.width * 0.5f) - (textDimensions.x * 0.5f), yPosition, textDimensions.x, textDimensions.y);

        GUI.Label(pausedLabelRect, pausedText);

        yPosition += 96;
        string[] graphicsLevels = QualitySettings.names;
        Rect     selectionRect  = new Rect((Screen.width * 0.5f) - 256, yPosition, 512, 96);
        int      selected       = GUI.SelectionGrid(selectionRect, QualitySettings.GetQualityLevel(), graphicsLevels, graphicsLevels.Length);

        if (selected != -1)
        {
            QualitySettings.SetQualityLevel(selected);

            Water      water       = null;
            GameObject waterObject = GameObject.Find("Nighttime Water");
            if (waterObject != null)
            {
                water = waterObject.GetComponent <Water>();
            }

            SSAOEffect ssao = GetComponent <SSAOEffect>();

            switch (selected)
            {
            case 0:
            case 1:
            {
                if (water != null)
                {
                    water.m_WaterMode   = Water.WaterMode.Simple;
                    water.m_TextureSize = 64;
                    ssao.enabled        = false;
                }
            }
            break;

            case 2:
            case 3:
            {
                if (water != null)
                {
                    water.m_WaterMode   = Water.WaterMode.Reflective;
                    water.m_TextureSize = 128;
                    ssao.enabled        = false;
                }
            }
            break;

            case 4:
            case 5:
            {
                if (water != null)
                {
                    water.m_WaterMode   = Water.WaterMode.Refractive;
                    water.m_TextureSize = 256;
                    ssao.enabled        = true;
                }
            }
            break;
            }
        }

        yPosition += 96 + 42;
        Rect backRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 32);

        if (GUI.Button(backRect, "Back"))
        {
            m_pausedMenuState = PausedMenuState.Main;
            return;
        }
    }
Beispiel #15
0
    private void OnMainPausedMenu()
    {
        const float BUTTON_WIDTH = 256;

        float yPosition = 100;

        string  pausedText      = "Paused";
        Vector2 textDimensions  = GUI.skin.label.CalcSize(new GUIContent(pausedText));
        Rect    pausedLabelRect = new Rect((Screen.width * 0.5f) - (textDimensions.x * 0.5f), yPosition, textDimensions.x, textDimensions.y);

        GUI.Label(pausedLabelRect, pausedText);

        yPosition += 96;
        Rect continueRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 48);

        GUI.SetNextControlName("continue");
        if (GUI.Button(continueRect, "Continue") || (m_pressedOK && m_highlighted == "continue"))
        {
            m_pressedOK   = false;
            m_highlighted = "continue";
            CEntityPlayer.GetInstance().CurrentGameState = GameState.Running;
            Time.timeScale = 1.0f;
            CEntityPlayer.GetInstance().Physics.SkipNextJump();
            return;
        }

        yPosition += 42;
        Rect restartRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 48);

        GUI.SetNextControlName("restart");
        if (GUI.Button(restartRect, "Restart Level") || (m_pressedOK && m_highlighted == "restart"))
        {
            m_pressedOK       = false;
            m_highlighted     = "no";
            m_pausedMenuState = PausedMenuState.Restart;
            return;
        }

        yPosition += 42;
        Rect optionsRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 48);

        GUI.SetNextControlName("options");
        if (GUI.Button(optionsRect, "Options") || (m_pressedOK && m_highlighted == "options"))
        {
            m_pressedOK       = false;
            m_highlighted     = "graphics";
            m_pausedMenuState = PausedMenuState.Options;
            return;
        }

        yPosition += 84;
        Rect mainMenuRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 48);

        GUI.SetNextControlName("mainmenu");
        if (GUI.Button(mainMenuRect, "Main Menu") || (m_pressedOK && m_highlighted == "mainmenu"))
        {
            m_pressedOK       = false;
            m_highlighted     = "no";
            m_pausedMenuState = PausedMenuState.MainMenu;
            return;
        }

        yPosition += 42;
        Rect quitRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 48);

        GUI.SetNextControlName("quit");
        if (GUI.Button(quitRect, "Quit") || (m_pressedOK && m_highlighted == "quit"))
        {
            m_pressedOK       = false;
            m_highlighted     = "no";
            m_pausedMenuState = PausedMenuState.Quit;
            return;
        }
    }
    private void OnOptionsMenu()
    {
        const float BUTTON_WIDTH = 256;
        float yPosition = 100;

        string pausedText = "Options";
        Vector2 textDimensions = GUI.skin.label.CalcSize(new GUIContent(pausedText));
        Rect pausedLabelRect = new Rect((Screen.width * 0.5f) - (textDimensions.x * 0.5f), yPosition, textDimensions.x, textDimensions.y);
        GUI.Label(pausedLabelRect, pausedText);

        yPosition += 96;
        string[] graphicsLevels = QualitySettings.names;
        Rect selectionRect = new Rect((Screen.width * 0.5f) - 256, yPosition, 512, 96);
        int selected = GUI.SelectionGrid(selectionRect, QualitySettings.GetQualityLevel(), graphicsLevels, graphicsLevels.Length);
        if (selected != -1)
        {
            QualitySettings.SetQualityLevel(selected);

            Water water = null;
            GameObject waterObject = GameObject.Find("Nighttime Water");
            if (waterObject != null) water = waterObject.GetComponent<Water>();

            SSAOEffect ssao = GetComponent<SSAOEffect>();

            switch(selected)
            {
            case 0:
            case 1:
            {
                if (water != null)
                {
                    water.m_WaterMode = Water.WaterMode.Simple;
                    water.m_TextureSize = 64;
                    ssao.enabled = false;
                }
            }
            break;

            case 2:
            case 3:
            {
                if (water != null)
                {
                    water.m_WaterMode = Water.WaterMode.Reflective;
                    water.m_TextureSize = 128;
                    ssao.enabled = false;
                }
            }
            break;

            case 4:
            case 5:
            {
                if (water != null)
                {
                    water.m_WaterMode = Water.WaterMode.Refractive;
                    water.m_TextureSize = 256;
                    ssao.enabled = true;
                }
            }
            break;
            }
        }

        yPosition += 96 + 42;
        Rect backRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 32);
        if (GUI.Button(backRect, "Back"))
        {
            m_pausedMenuState = PausedMenuState.Main;
            return;
        }
    }
Beispiel #17
0
    void Update()
    {
        if ((Input.GetButtonDown("Pause") || Input.GetButtonDown("joystick button 7")) && paused == false && Time.realtimeSinceStartup - ltPausedHit > pausedCooldown)
        {       //pause game
            Time.timeScale = 0;
            ltPausedHit    = Time.realtimeSinceStartup;
            paused         = true;
            Debug.Log("pause");
            mainPauseMenu.enabled  = true;
            currentPausedMenuState = PausedMenuState.mainMenu;
        }
        if (Input.GetButtonDown("Pause") && paused == true && Time.realtimeSinceStartup - ltPausedHit > pausedCooldown)
        {       //and unpause
            Time.timeScale = 1;
            ltPausedHit    = Time.realtimeSinceStartup;
            paused         = false;
            Debug.Log("unpause");
            mainPauseMenu.enabled  = false;
            currentPausedMenuState = PausedMenuState.mainMenu;
            mainPauseMenu.UnClickAll();
            optionsMenu.UnClickAll();
            inputMenu.UnClickAll();
        }
        if (paused)
        {
            switch (currentPausedMenuState)
            {
            case PausedMenuState.mainMenu:
                mainPauseMenu.enabled = true;
                optionsMenu.enabled   = false;
                inputMenu.enabled     = false;
                mainPauseMenu.CheckInput();
                break;

            case PausedMenuState.optionsMenu:
                mainPauseMenu.enabled = false;
                optionsMenu.enabled   = true;
                inputMenu.enabled     = false;
                optionsMenu.CheckInput();
                if (InputCoordinator.usingController)
                {
                    if (Input.GetButtonDown("joystick button 1"))
                    {
                        currentPausedMenuState = PausedMenuState.mainMenu;
                        optionsMenu.UnClickAll();
                    }
                }
                if (InputCoordinator.usingMouseAndKeyboard)
                {
                }
                break;

            case PausedMenuState.inputMenu:
                mainPauseMenu.enabled = false;
                optionsMenu.enabled   = false;
                inputMenu.enabled     = true;
                inputMenu.CheckInput();
                if (InputCoordinator.usingController)
                {
                    if (Input.GetButtonDown("joystick button 1"))
                    {
                        currentPausedMenuState = PausedMenuState.optionsMenu;
                        inputMenu.UnClickAll();
                    }
                }
                if (InputCoordinator.usingMouseAndKeyboard)
                {
                }
                break;
            }
        }
    }