示例#1
0
    /**
     * Draws the HighScore menu
     */
    private void drawHighScore()
    {
        Color prev = GUI.color;

        GUI.color = Color.magenta;
        GUIManager.DrawLabel(new Rect(ScreenUtil.ScreenWidth / 2 - 3 * ScreenUtil.ScreenWidth / 16, ScreenUtil.ScreenHeight / 2 - ScreenUtil.getPixelHeight(100),
                                      3 * ScreenUtil.ScreenWidth / 8, ScreenUtil.getPixelHeight(200)), "High Scores", style);
        GUI.color = prev;
        GUI.color = Color.green;
        GUIManager.DrawLabel(new Rect(ScreenUtil.ScreenWidth / 2 - 3 * ScreenUtil.ScreenWidth / 16, ScreenUtil.ScreenHeight / 2,
                                      3 * ScreenUtil.ScreenWidth / 8, ScreenUtil.getPixelHeight(200)), "1)   " + PlayerPrefs.GetInt("highscorePos" + 1), style);
        GUIManager.DrawLabel(new Rect(ScreenUtil.ScreenWidth / 2 - 3 * ScreenUtil.ScreenWidth / 16, ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(70),
                                      3 * ScreenUtil.ScreenWidth / 8, ScreenUtil.getPixelHeight(200)), "2)   " + PlayerPrefs.GetInt("highscorePos" + 2), style);
        GUIManager.DrawLabel(new Rect(ScreenUtil.ScreenWidth / 2 - 3 * ScreenUtil.ScreenWidth / 16, ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(140),
                                      3 * ScreenUtil.ScreenWidth / 8, ScreenUtil.getPixelHeight(200)), "3)   " + PlayerPrefs.GetInt("highscorePos" + 3), style);
        GUIManager.DrawLabel(new Rect(ScreenUtil.ScreenWidth / 2 - 3 * ScreenUtil.ScreenWidth / 16, ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(210),
                                      3 * ScreenUtil.ScreenWidth / 8, ScreenUtil.getPixelHeight(200)), "4)   " + PlayerPrefs.GetInt("highscorePos" + 4), style);
        GUIManager.DrawLabel(new Rect(ScreenUtil.ScreenWidth / 2 - 3 * ScreenUtil.ScreenWidth / 16, ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(280),
                                      3 * ScreenUtil.ScreenWidth / 8, ScreenUtil.getPixelHeight(200)), "5)   " + PlayerPrefs.GetInt("highscorePos" + 5), style);

        //Back Button
        GUI.color = Color.white;
        GUI.SetNextControlName("0");
        if (GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(200)) / 2,
                                ScreenUtil.ScreenHeight - ScreenUtil.getPixelHeight(100), ScreenUtil.getPixelWidth(200), style.fontSize), new GUIContent("Back", "0"), style))
        {
            _displayHighScore = false;
        }
        if (GUI.tooltip == "0")
        {
            _highlightStyle.normal = style.hover;
        }
        if (GameManager.Instance.enableSeebright)
        {
            GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(200)) / 2 + ScreenUtil.ScreenWidth,
                                ScreenUtil.ScreenHeight - ScreenUtil.getPixelHeight(100), ScreenUtil.getPixelWidth(200), style.fontSize), "Back", _highlightStyle);
        }
        _highlightStyle.normal = style.normal;
        //Joystick Menu Navigation
        _focusID = ManageFocus(_focusID, 0);
        if (GameManager.Instance.enableSeebright && SBRemote.remoteStatus)
        {
            if (SBRemote.GetButtonDown(SBRemote.BUTTON_SELECT))
            {
                if (_focusID < 0)
                {
                    return;
                }
                else if (_focusID == 0)
                {
                    _displayHighScore = false;
                }
            }
        }
    }
示例#2
0
 /**
  * For Android Only
  * The Function OnApplicationPause checks to see of the current state of pausedState is true,
  * and if the state is true, it accesses the SBRemote classes function and stops it,
  * otherwise if the pausedStatus is false, then it starts the SBRemote class service.
  */
 void OnApplicationPause(bool pauseStatus)
 {
     if (pauseStatus)
     {
         SBRemote.StopService();
     }
     else
     {
         SBRemote.StartService();
     }
 }
示例#3
0
    private int ManageFocus(int ID, int length)
    {
        if (!GameManager.Instance.enableSeebright || !SBRemote.remoteStatus)
        {
            return(0);
        }
        GUI.FocusControl(ID.ToString());

        _focusTimer += .01f;
        if (SBRemote.GetAxis(SBRemote.JOY_VERTICAL) < -0.5f && ID < length && _focusTimer > _focusTimerMax)
        {
            _focusTimer = 0;
            ID++;
        }
        if (SBRemote.GetAxis(SBRemote.JOY_VERTICAL) > 0.5f && ID > 0 && _focusTimer > _focusTimerMax)
        {
            _focusTimer = 0;
            ID--;
        }
        return(ID);
    }
示例#4
0
 /**
  * This overlays Debug information onto the screen if enabled in the SeebrightSDK. Also checks the remote status and shows whether it's connected or not.
  * Shows both 2D/3D cursor information, the Normalized camera rotation, and the Remote Output.
  */
 void OnGUI()
 {
     if (cursorStyle == null)
     {
         cursorStyle                  = new GUIStyle();
         cursorStyle.fontSize         = 20;
         cursorStyle.fontStyle        = FontStyle.Bold;
         cursorStyle.normal.textColor = Color.white;
     }
     if (enableDebugOutput)
     {
         if (currentCamera.enableGyroCam)
         {
             writeGUI(GUI_LABEL, 25, -200, 100, 100, "NormalizedCamera: \nx:" +
                      SBCamera.normalizedLookRotation.eulerAngles.x + "\ny:" +
                      SBCamera.normalizedLookRotation.eulerAngles.y + "\nz:" +
                      SBCamera.normalizedLookRotation.eulerAngles.z);
         }
                     #if (UNITY_IPHONE || UNITY_ANDROID) && !UNITY_EDITOR
         writeGUI(GUI_LABEL, Screen.width / 4 - 200, 160, 400, 50, "UnityEdit: " + SBRemote.printRemoteControls());
                     #endif
     }
             #if (UNITY_IPHONE || UNITY_ANDROID) && !UNITY_EDITOR
     SBRemote.updateRemoteStatus();
     if (SBRemote.remoteStatus)
     {
         if (sleepTimer <= timeTillSleep)
         {
             writeGUI(GUI_LABEL, (Screen.width / 4) - 200, 100, 400, 50, "Remote Connected");
             sleepTimer += Time.deltaTime;
         }
     }
     else
     {
         sleepTimer = 0.0f;
         writeGUI(GUI_LABEL, (Screen.width / 4) - 200, 100, 400, 50, "Remote Disconnected");
     }
             #endif
 }
示例#5
0
 int ManageFocus(int ID, int length)
 {
     if (!GameManager.Instance.enableSeebright)
     {
         return(0);
     }
     GUI.FocusControl(ID.ToString());
     if (_focusTimer < _focusTimerMax)
     {
         _focusTimer += .01f;
     }
     if (SBRemote.GetJoystickDelta(SBRemote.JOY_VERTICAL) < -2048 * 4 * 2 && ID < length && _focusTimer > _focusTimerMax)
     {
         _focusTimer = 0;
         ID++;
     }
     if (SBRemote.GetJoystickDelta(SBRemote.JOY_VERTICAL) > 2048 * 4 * 2 && ID > 0 && _focusTimer > _focusTimerMax)
     {
         _focusTimer = 0;
         ID--;
     }
     return(ID);
 }
示例#6
0
 /**
  * Calls remote updates and receieves input from the Seebright Blutooth remote.
  * @see SBRemote.remoteLateUpdate()
  */
 void LateUpdate()
 {
     SBRemote.remoteLateUpdate();
 }
示例#7
0
 /**
  * Creates a periscope camera in the SBCursors class for more accurate Ball Tracking.
  * Only works if enableBallTracking is true.
  * @see SBCursors.StartCursors()
  * Starts the Remote functionality by looking for the Seebright Remote by starting bluetooth in native iOS code.
  * @see SBRemote.InitializeRemote()
  */
 void Start()
 {
     SBRemote.InitializeRemote();
 }
示例#8
0
    /**
     * Draws the main menu
     */
    private void drawNormalMenu()
    {
        //Play Game button
        GUI.SetNextControlName("0");
        if (GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2, ScreenUtil.ScreenHeight / 2 - ScreenUtil.getPixelHeight(50),
                                ScreenUtil.getPixelWidth(400), style.fontSize), new GUIContent("Play Game", "0"), style))
        {
            Application.LoadLevel(1);
        }
        if (GUI.tooltip == "0")
        {
            _highlightStyle.normal = style.hover;
        }
        if (GameManager.Instance.enableSeebright)
        {
            GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2 + ScreenUtil.ScreenWidth, ScreenUtil.ScreenHeight / 2 - ScreenUtil.getPixelHeight(50),
                                ScreenUtil.getPixelWidth(400), style.fontSize), "Play Game", _highlightStyle);
        }
        _highlightStyle.normal = style.normal;

        //Tutorial Button
        GUI.SetNextControlName("1");
        if (GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2,
                                ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(50), ScreenUtil.getPixelWidth(400), style.fontSize), new GUIContent("Tutorial", "1"), style))
        {
            Application.LoadLevel(2);
        }
        if (GUI.tooltip == "1")
        {
            _highlightStyle.normal = style.hover;
        }
        if (GameManager.Instance.enableSeebright)
        {
            GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2 + ScreenUtil.ScreenWidth,
                                ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(50), ScreenUtil.getPixelWidth(400), style.fontSize), "Tutorial", _highlightStyle);
        }
        _highlightStyle.normal = style.normal;

        //Credits Button
        GUI.SetNextControlName("2");
        if (GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2,
                                ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(250), ScreenUtil.getPixelWidth(400), style.fontSize), new GUIContent("Credits", "2"), style))
        {
            _displayCredits = true;
        }
        if (GUI.tooltip == "2")
        {
            _highlightStyle.normal = style.hover;
        }
        if (GameManager.Instance.enableSeebright)
        {
            GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2 + ScreenUtil.ScreenWidth,
                                ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(250), ScreenUtil.getPixelWidth(400), style.fontSize), "Credits", _highlightStyle);
        }
        _highlightStyle.normal = style.normal;

        //Options Button
        GUI.SetNextControlName("3");
        if (GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2,
                                ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(150), ScreenUtil.getPixelWidth(400), style.fontSize), new GUIContent("Options", "3"), style))
        {
            _displayOptions = true;
        }
        if (GUI.tooltip == "3")
        {
            _highlightStyle.normal = style.hover;
        }
        if (GameManager.Instance.enableSeebright)
        {
            GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2 + ScreenUtil.ScreenWidth,
                                ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(150), ScreenUtil.getPixelWidth(400), style.fontSize), "Options", _highlightStyle);
        }
        _highlightStyle.normal = style.normal;

#if !UNITY_WEBPLAYER
        //HighScore Display Button
        GUI.SetNextControlName("4");
        if (GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2,
                                ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(350), ScreenUtil.getPixelWidth(400), style.fontSize), new GUIContent("High Scores", "4"), style))
        {
            _displayHighScore = true;
        }
        if (GUI.tooltip == "4")
        {
            _highlightStyle.normal = style.hover;
        }
        if (GameManager.Instance.enableSeebright)
        {
            GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2 + ScreenUtil.ScreenWidth,
                                ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(350), ScreenUtil.getPixelWidth(400), style.fontSize), "High Scores", _highlightStyle);
        }
        _highlightStyle.normal = style.normal;
#endif

        //Joystick Menu Navigation
        if (GameManager.Instance.enableSeebright && SBRemote.remoteStatus)
        {
            _focusID = ManageFocus(_focusID, 4);
            if (SBRemote.GetButtonDown(SBRemote.BUTTON_SELECT))
            {
                if (_focusID < 0)
                {
                    return;
                }
                else if (_focusID == 0)
                {
                    Application.LoadLevel(1);
                }
                else if (_focusID == 1)
                {
                    Application.LoadLevel(2);
                }
                else if (_focusID == 2)
                {
                    _displayCredits = true;
                    _focusID        = -1;
                }
                else if (_focusID == 3)
                {
                    _displayOptions = true;
                    _focusID        = -1;
                }
                else if (_focusID == 4)
                {
                    _displayHighScore = true;
                    _focusID          = -1;
                }
            }
        }
    }
示例#9
0
    /**
     * Draws the credits menu
     */
    private void drawCredits()
    {
        Color prev = GUI.color;

        GUI.color = Color.magenta;
        GUIManager.DrawLabel(new Rect(ScreenUtil.ScreenWidth / 2 - 3 * ScreenUtil.ScreenWidth / 16, ScreenUtil.ScreenHeight / 2 - ScreenUtil.getPixelHeight(100),
                                      3 * ScreenUtil.ScreenWidth / 8, ScreenUtil.getPixelHeight(200)), "Credits", style);
        GUI.color = prev;
        GUI.color = Color.green;
        GUIManager.DrawLabel(new Rect(ScreenUtil.ScreenWidth / 2 - 3 * ScreenUtil.ScreenWidth / 16, ScreenUtil.ScreenHeight / 2 - ScreenUtil.getPixelHeight(60),
                                      3 * ScreenUtil.ScreenWidth / 8, ScreenUtil.getPixelHeight(200)), "Anthony Dao", style);
        style.fontSize /= 2;
        GUI.color       = Color.white;
        GUIManager.DrawLabel(new Rect(ScreenUtil.ScreenWidth / 2 - 3 * ScreenUtil.ScreenWidth / 16, ScreenUtil.ScreenHeight / 2 - ScreenUtil.getPixelHeight(5),
                                      3 * ScreenUtil.ScreenWidth / 8, ScreenUtil.getPixelHeight(200)), "Programming ( Enemies-Menus-GUI ) / Design", style);
        style.fontSize *= 2;
        GUI.color       = Color.green;
        GUIManager.DrawLabel(new Rect(ScreenUtil.ScreenWidth / 2 - 3 * ScreenUtil.ScreenWidth / 16, ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(60),
                                      3 * ScreenUtil.ScreenWidth / 8, ScreenUtil.getPixelHeight(200)), "Chase Khamashta", style);
        style.fontSize /= 2;
        GUI.color       = Color.white;
        GUIManager.DrawLabel(new Rect(ScreenUtil.ScreenWidth / 2 - 3 * ScreenUtil.ScreenWidth / 16, ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(110),
                                      3 * ScreenUtil.ScreenWidth / 8, ScreenUtil.getPixelHeight(200)), "Programming ( Player-Controls-Enemies-Powerups ) / Design", style);
        style.fontSize *= 2;
        GUI.color       = Color.green;
        GUIManager.DrawLabel(new Rect(ScreenUtil.ScreenWidth / 2 - 3 * ScreenUtil.ScreenWidth / 16, ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(180),
                                      3 * ScreenUtil.ScreenWidth / 8, ScreenUtil.getPixelHeight(200)), "Orlando Salvatore", style);
        style.fontSize /= 2;
        GUI.color       = Color.white;
        GUIManager.DrawLabel(new Rect(ScreenUtil.ScreenWidth / 2 - 3 * ScreenUtil.ScreenWidth / 16, ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(230),
                                      3 * ScreenUtil.ScreenWidth / 8, ScreenUtil.getPixelHeight(200)), "Programming", style);
        GUIManager.DrawLabel(new Rect(ScreenUtil.ScreenWidth / 2 - 3 * ScreenUtil.ScreenWidth / 16, ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(260),
                                      3 * ScreenUtil.ScreenWidth / 8, ScreenUtil.getPixelHeight(200)),
                             "( Enemies-Level Generation-Transitions-Tutorial-Menus-Scoring )", style);
        GUIManager.DrawLabel(new Rect(ScreenUtil.ScreenWidth / 2 - 3 * ScreenUtil.ScreenWidth / 16, ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(290),
                                      3 * ScreenUtil.ScreenWidth / 8, ScreenUtil.getPixelHeight(200)),
                             "Art / Music / Design", style);

        style.fontSize *= 2;
        GUI.SetNextControlName("0");
        if (GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(200)) / 2,
                                ScreenUtil.ScreenHeight - ScreenUtil.getPixelHeight(100), ScreenUtil.getPixelWidth(200), style.fontSize), new GUIContent("Back", "0"), style))
        {
            _displayCredits = false;
        }
        if (GUI.tooltip == "0")
        {
            _highlightStyle.normal = style.hover;
        }
        if (GameManager.Instance.enableSeebright)
        {
            GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(200)) / 2 + ScreenUtil.ScreenWidth,
                                ScreenUtil.ScreenHeight - ScreenUtil.getPixelHeight(100), ScreenUtil.getPixelWidth(200), style.fontSize), "Back", _highlightStyle);
        }
        _highlightStyle.normal = style.normal;
        //Joystick Menu Navigation
        _focusID = ManageFocus(_focusID, 0);
        if (!SBRemote.remoteStatus || GameManager.Instance.enableSeebright)
        {
            return;
        }
        if (SBRemote.GetButtonDown(SBRemote.BUTTON_SELECT))
        {
            if (_focusID < 0)
            {
                return;
            }
            else if (_focusID == 0)
            {
                _displayCredits = false;
            }
        }
    }
示例#10
0
    /**
     * Draws the options menu
     */
    private void drawOptions()
    {
        Color prev = GUI.color;

        GUI.color = Color.magenta;
        GUIManager.DrawLabel(new Rect(ScreenUtil.ScreenWidth / 2 - 3 * ScreenUtil.ScreenWidth / 16, ScreenUtil.ScreenHeight / 2 -
                                      ScreenUtil.getPixelHeight(100), 3 * ScreenUtil.ScreenWidth / 8, ScreenUtil.getPixelHeight(200)), "Options", style);
        GUI.color = prev;
        if (!GameManager.Instance.enableSeebright)
        {
            //SFX Volume
            GUI.Label(new Rect((ScreenUtil.ScreenWidth + ScreenUtil.getPixelWidth(200)) / 2, ScreenUtil.ScreenHeight / 2 - ScreenUtil.getPixelHeight(50),
                               ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(200)), "Effects Volume", style);
            GameManager.effectsVolume = GUI.HorizontalSlider(new Rect((ScreenUtil.ScreenWidth + ScreenUtil.getPixelWidth(200)) / 2,
                                                                      ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(50), ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(50)),
                                                             GameManager.effectsVolume, 0f, 1.0f);
            //Music Volume
            GUI.Label(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(1000)) / 2, ScreenUtil.ScreenHeight / 2 - ScreenUtil.getPixelHeight(50),
                               ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(200)), "Music Volume", style);
            GameManager.musicVolume = GUI.HorizontalSlider(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(1000)) / 2,
                                                                    ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(50), ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(50)),
                                                           GameManager.musicVolume, 0f, 1.0f);
#if !UNITY_IPHONE
            //Sensitivity Control
            GUI.Label(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2,
                               ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(100), ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(200)),
                      "Sensitivity", style);
            GameManager.mouseSensitivity = GUI.HorizontalSlider(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2,
                                                                         ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(180), ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(50)),
                                                                GameManager.mouseSensitivity, 0.1f, 0.5f);
#endif
        }
        else
        {
            //SeeBright Enabled
            //SFX Volume
            GUI.SetNextControlName("0");
            GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2, ScreenUtil.ScreenHeight / 2,
                                ScreenUtil.getPixelWidth(400), style.fontSize), new GUIContent("Effects Volume", "0"), style);
            GameManager.effectsVolume = GUI.HorizontalSlider(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2,
                                                                      ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(70), ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(50)),
                                                             GameManager.effectsVolume, 0f, 1.0f);
            if (GUI.tooltip == "0")
            {
                _highlightStyle.normal = style.hover;
            }
            GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2 + ScreenUtil.ScreenWidth, ScreenUtil.ScreenHeight / 2,
                                ScreenUtil.getPixelWidth(400), style.fontSize), "Effects Volume", _highlightStyle);
            _highlightStyle.normal    = style.normal;
            GameManager.effectsVolume = GUI.HorizontalSlider(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2 + ScreenUtil.ScreenWidth,
                                                                      ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(70), ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(50)),
                                                             GameManager.effectsVolume, 0f, 1.0f);

            //Music Volume
            GUI.SetNextControlName("1");
            GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2, ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(120),
                                ScreenUtil.getPixelWidth(400), style.fontSize), new GUIContent("Music Volume", "1"), style);
            GameManager.musicVolume = GUI.HorizontalSlider(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2,
                                                                    ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(190), ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(50)),
                                                           GameManager.musicVolume, 0f, 1.0f);
            if (GUI.tooltip == "1")
            {
                _highlightStyle.normal = style.hover;
            }
            GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2 + ScreenUtil.ScreenWidth, ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(120),
                                ScreenUtil.getPixelWidth(400), style.fontSize), "Music Volume", _highlightStyle);
            _highlightStyle.normal  = style.normal;
            GameManager.musicVolume = GUI.HorizontalSlider(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2 + ScreenUtil.ScreenWidth,
                                                                    ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(190), ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(50)),
                                                           GameManager.musicVolume, 0f, 1.0f);
        }

        if (GameManager.Instance)
        {
            GameManager.Instance.updateMusicVolume();
        }

#if UNITY_IPHONE
        GUI.SetNextControlName("3");
        if (GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(200)) / 2,
                                ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(230), ScreenUtil.getPixelWidth(200),
                                style.fontSize), new GUIContent((GameManager.invertedJoystick) ? "Inverted Joystick: On" : "Inverted Joystick: Off", "3"), style))
        {
            GameManager.invertedJoystick = !GameManager.invertedJoystick;
        }
        if (GUI.tooltip == "3")
        {
            _highlightStyle.normal = style.hover;
        }
        if (GameManager.Instance.enableSeebright)
        {
            GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(200)) / 2 + ScreenUtil.ScreenWidth,
                                ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(230), ScreenUtil.getPixelWidth(200), style.fontSize),
                       (GameManager.invertedJoystick) ? "Inverted Joystick: On" : "Inverted Joystick: Off", _highlightStyle);
        }
        _highlightStyle.normal = style.normal;
        _focusID = ManageFocus(_focusID, 3);

        if (!GameManager.Instance.enableSeebright)
        {
            if (GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(200)) / 2,
                                    ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(330), ScreenUtil.getPixelWidth(200),
                                    style.fontSize), new GUIContent((GameManager.invertedControls) ? "Inverted Controls: On" : "Inverted Controls: Off"), style))
            {
                GameManager.invertedControls = !GameManager.invertedControls;
            }
        }
#endif

        GUI.SetNextControlName("4");
        if (GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(200)) / 2,
                                (GameManager.Instance.enableSeebright) ? ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(330) : ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(430),
                                ScreenUtil.getPixelWidth(200), style.fontSize), new GUIContent("Back", "4"), style))
        {
            _displayOptions = false;
            // update sensitivity when options are closed
            if (GameManager.Instance != null)
            {
                foreach (Player player in GameManager.Instance.CurrentPlayerShips)
                {
                    player.UpdateSensitivity();
                }
            }
        }
        if (GUI.tooltip == "4")
        {
            _highlightStyle.normal = style.hover;
        }
        GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(200)) / 2 + ScreenUtil.ScreenWidth,
                            ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(430), ScreenUtil.getPixelWidth(200), style.fontSize), "Back", _highlightStyle);
        _highlightStyle.normal = style.normal;
        _focusID = ManageFocus(_focusID, 4);



        if (!GameManager.Instance.enableSeebright || !SBRemote.remoteStatus)
        {
            return;
        }
        if (SBRemote.GetButtonDown(SBRemote.BUTTON_SELECT))
        {
            if (_focusID < 0)
            {
                return;
            }
            else if (_focusID == 3)
            {
                _displayOptions = false;
                _focusID        = -1;
            }
        }
        if (SBRemote.GetAxis(SBRemote.JOY_HORIZONTAL) > 0.5f)
        {
            if (_focusID == 0 && GameManager.effectsVolume < 1)
            {
                GameManager.effectsVolume += .01f;
            }
            else if (_focusID == 1 && GameManager.musicVolume < 1)
            {
                GameManager.musicVolume += .01f;
            }
            else if (_focusID == 2 && GameManager.mouseSensitivity < .5f)
            {
                GameManager.mouseSensitivity += .005f;
            }
        }
        if (SBRemote.GetAxis(SBRemote.JOY_HORIZONTAL) < -0.5f)
        {
            if (_focusID == 0 && GameManager.effectsVolume > 0)
            {
                GameManager.effectsVolume -= .01f;
            }
            else if (_focusID == 1 && GameManager.musicVolume > 0)
            {
                GameManager.musicVolume -= .01f;
            }
            else if (_focusID == 2 && GameManager.mouseSensitivity > .1f)
            {
                GameManager.mouseSensitivity -= .005f;
            }
        }
    }
示例#11
0
    /*
     * OnGUI is called for rendering and handling GUI events.
     * Buttons for 'Resume Game', 'Main Menu', and 'Options'
     * As well as buttons for Options menu
     */
    void OnGUI()
    {
        GUIStyle _highlightStyle = new GUIStyle(style);

        if (!currentlyActive)
        {
            return;
        }
        if (!_displayOptions)
        {
            // Resume Game Button
            GUI.SetNextControlName("0");
            if (GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2, ScreenUtil.ScreenHeight / 2,
                                    ScreenUtil.getPixelWidth(400), style.fontSize), new GUIContent("Resume Game", "0"), style))
            {
                exit();
            }
            if (GUI.tooltip == "0")
            {
                _highlightStyle.normal = style.hover;
            }
            GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2 + ScreenUtil.ScreenWidth, ScreenUtil.ScreenHeight / 2,
                                ScreenUtil.getPixelWidth(400), style.fontSize), "Resume Game", _highlightStyle);
            _highlightStyle.normal = style.normal;

            //Main Menu Button
            GUI.SetNextControlName("1");
            if (GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2,
                                    ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(100), ScreenUtil.getPixelWidth(400),
                                    style.fontSize), new GUIContent("Main Menu", "1"), style))
            {
                Application.LoadLevel(0);
            }
            if (GUI.tooltip == "1")
            {
                _highlightStyle.normal = style.hover;
            }
            if (GameManager.Instance.enableSeebright)
            {
                GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2 + ScreenUtil.ScreenWidth,
                                    ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(100), ScreenUtil.getPixelWidth(400),
                                    style.fontSize), "Main Menu", _highlightStyle);
            }
            _highlightStyle.normal = style.normal;

            //Options Button
            GUI.SetNextControlName("2");
            if (GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2,
                                    ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(200), ScreenUtil.getPixelWidth(400),
                                    style.fontSize), new GUIContent("Options", "2"), style))
            {
                _displayOptions = true;
            }
            if (GUI.tooltip == "2")
            {
                _highlightStyle.normal = style.hover;
            }
            if (GameManager.Instance.enableSeebright)
            {
                GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2 + ScreenUtil.ScreenWidth,
                                    ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(200), ScreenUtil.getPixelWidth(400),
                                    style.fontSize), "Options", _highlightStyle);
            }
            _highlightStyle.normal = style.normal;

            //Joystick Menu Navigation
            if (GameManager.Instance.enableSeebright)
            {
                _focusID = ManageFocus(_focusID, 2);
                if (SBRemote.GetButtonDown(SBRemote.BUTTON_SELECT))
                {
                    if (_focusID < 0)
                    {
                        return;
                    }
                    else if (_focusID == 0)
                    {
                        exit();
                    }
                    else if (_focusID == 1)
                    {
                        Application.LoadLevel(0);
                    }
                    else if (_focusID == 2)
                    {
                        _displayOptions = true;
                        _focusID        = -1;
                    }
                }
            }
        }
        //In option Menu
        else if (_displayOptions)
        {
            Color prev = GUI.color;
            GUI.color = Color.magenta;

            if (GameManager.Instance.enableSeebright == false)
            {
                GUI.Label(new Rect(ScreenUtil.ScreenWidth / 2 - 3 * ScreenUtil.ScreenWidth / 16, ScreenUtil.ScreenHeight / 2 -
                                   ScreenUtil.getPixelHeight(100), 3 * ScreenUtil.ScreenWidth / 8, ScreenUtil.getPixelHeight(200)), "Options", style);
                GUI.color = prev;
                GUI.Label(new Rect((ScreenUtil.ScreenWidth + ScreenUtil.getPixelWidth(200)) / 2, ScreenUtil.ScreenHeight / 2,
                                   ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(200)), "Effects Volume", style);
                GameManager.effectsVolume = GUI.HorizontalSlider(new Rect((ScreenUtil.ScreenWidth + ScreenUtil.getPixelWidth(200)) / 2,
                                                                          ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(100), ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(50)),
                                                                 GameManager.effectsVolume, 0f, 1.0f);
                GUI.Label(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(1000)) / 2, ScreenUtil.ScreenHeight / 2,
                                   ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(200)), "Music Volume", style);
                GameManager.musicVolume = GUI.HorizontalSlider(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(1000)) / 2,
                                                                        ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(100), ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(50)),
                                                               GameManager.musicVolume, 0f, 1.0f);
#if !UNITY_IPHONE
                GUI.Label(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2,
                                   ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(150), ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(200)),
                          "Sensitivity", style);
                GameManager.mouseSensitivity = GUI.HorizontalSlider(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2,
                                                                             ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(230), ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(50)),
                                                                    GameManager.mouseSensitivity, 0.1f, 0.5f);
#endif
            }
            else if (GameManager.Instance.enableSeebright == true)
            {
                GUI.Label(new Rect(ScreenUtil.ScreenWidth / 2 - 3 * ScreenUtil.ScreenWidth / 16, ScreenUtil.ScreenHeight / 2 -
                                   ScreenUtil.getPixelHeight(200), 3 * ScreenUtil.ScreenWidth / 8, ScreenUtil.getPixelHeight(200)), "Options", style);
                GUI.Label(new Rect(ScreenUtil.ScreenWidth / 2 - 3 * ScreenUtil.ScreenWidth / 16 + ScreenUtil.ScreenWidth, ScreenUtil.ScreenHeight / 2 -
                                   ScreenUtil.getPixelHeight(200), 3 * ScreenUtil.ScreenWidth / 8, ScreenUtil.getPixelHeight(200)), "Options", style);
                GUI.color = prev;
                //SFX Volume
                GUI.SetNextControlName("0");
                GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2, ScreenUtil.ScreenHeight / 2 - ScreenUtil.getPixelHeight(100),
                                    ScreenUtil.getPixelWidth(400), style.fontSize), new GUIContent("Effects Volume", "0"), style);
                GameManager.effectsVolume = GUI.HorizontalSlider(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2,
                                                                          ScreenUtil.ScreenHeight / 2 - ScreenUtil.getPixelHeight(30), ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(50)),
                                                                 GameManager.effectsVolume, 0f, 1.0f);
                if (GUI.tooltip == "0")
                {
                    _highlightStyle.normal = style.hover;
                }
                GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2 + ScreenUtil.ScreenWidth, ScreenUtil.ScreenHeight / 2 - ScreenUtil.getPixelHeight(100),
                                    ScreenUtil.getPixelWidth(400), style.fontSize), "Effects Volume", _highlightStyle);
                _highlightStyle.normal    = style.normal;
                GameManager.effectsVolume = GUI.HorizontalSlider(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2 + ScreenUtil.ScreenWidth,
                                                                          ScreenUtil.ScreenHeight / 2 - ScreenUtil.getPixelHeight(30), ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(50)),
                                                                 GameManager.effectsVolume, 0f, 1.0f);
                //Music Volume
                GUI.SetNextControlName("1");
                GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2, ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(20),
                                    ScreenUtil.getPixelWidth(400), style.fontSize), new GUIContent("Music Volume", "1"), style);
                GameManager.musicVolume = GUI.HorizontalSlider(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2,
                                                                        ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(90), ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(50)),
                                                               GameManager.musicVolume, 0f, 1.0f);
                if (GUI.tooltip == "1")
                {
                    _highlightStyle.normal = style.hover;
                }
                GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2 + ScreenUtil.ScreenWidth, ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(20),
                                    ScreenUtil.getPixelWidth(400), style.fontSize), "Music Volume", _highlightStyle);
                _highlightStyle.normal  = style.normal;
                GameManager.musicVolume = GUI.HorizontalSlider(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2 + ScreenUtil.ScreenWidth,
                                                                        ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(90), ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(50)),
                                                               GameManager.musicVolume, 0f, 1.0f);
                //Sensitivity Control
                GUI.SetNextControlName("2");
                GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2,
                                    ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(140), ScreenUtil.getPixelWidth(400), style.fontSize),
                           new GUIContent("Sensitivity", "2"), style);
                GameManager.mouseSensitivity = GUI.HorizontalSlider(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2,
                                                                             ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(210), ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(50)),
                                                                    GameManager.mouseSensitivity, 0.1f, 0.5f);
                if (GUI.tooltip == "2")
                {
                    _highlightStyle.normal = style.hover;
                }
                GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2 + ScreenUtil.ScreenWidth,
                                    ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(140), ScreenUtil.getPixelWidth(400), style.fontSize),
                           "Sensitivity", _highlightStyle);
                _highlightStyle.normal       = style.normal;
                GameManager.mouseSensitivity = GUI.HorizontalSlider(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(400)) / 2 + ScreenUtil.ScreenWidth,
                                                                             ScreenUtil.ScreenHeight / 2 + ScreenUtil.getPixelHeight(210), ScreenUtil.getPixelWidth(400), ScreenUtil.getPixelHeight(50)),
                                                                    GameManager.mouseSensitivity, 0.1f, 0.5f);
            }
            if (GameManager.Instance)
            {
                GameManager.Instance.updateMusicVolume();
            }


#if UNITY_IPHONE
            if (!GameManager.Instance.enableSeebright)
            {
                GUI.SetNextControlName("3");
                if (GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(200)) / 2,
                                        ScreenUtil.ScreenHeight - ScreenUtil.getPixelHeight(300), ScreenUtil.getPixelWidth(200),
                                        style.fontSize), new GUIContent((GameManager.invertedJoystick) ? "Inverted Joystick: On" : "Inverted Joystick: Off", "3"), style))
                {
                    GameManager.invertedJoystick = !GameManager.invertedJoystick;
                }
                if (GUI.tooltip == "3")
                {
                    _highlightStyle.normal = style.hover;
                }
                if (GameManager.Instance.enableSeebright)
                {
                    GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(200)) / 2 + ScreenUtil.ScreenWidth,
                                        ScreenUtil.ScreenHeight - ScreenUtil.getPixelHeight(300), ScreenUtil.getPixelWidth(200), style.fontSize), "Back", _highlightStyle);
                }
                _highlightStyle.normal = style.normal;
                _focusID = ManageFocus(_focusID, 3);


                GUI.SetNextControlName("4");
                if (GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(200)) / 2,
                                        ScreenUtil.ScreenHeight - ScreenUtil.getPixelHeight(200), ScreenUtil.getPixelWidth(200),
                                        style.fontSize), new GUIContent((GameManager.invertedControls) ? "Inverted Controls: On" : "Inverted Controls: Off", "3"), style))
                {
                    GameManager.invertedControls = !GameManager.invertedControls;
                    GameManager.Instance.joystickLeft.SetActive(GameManager.invertedControls);
                    GameManager.Instance.joystickRight.SetActive(!GameManager.invertedControls);
                }
                if (GUI.tooltip == "4")
                {
                    _highlightStyle.normal = style.hover;
                }
                if (GameManager.Instance.enableSeebright)
                {
                    GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(200)) / 2 + ScreenUtil.ScreenWidth,
                                        ScreenUtil.ScreenHeight - ScreenUtil.getPixelHeight(200), ScreenUtil.getPixelWidth(200), style.fontSize), "Back", _highlightStyle);
                }
                _highlightStyle.normal = style.normal;
                _focusID = ManageFocus(_focusID, 4);
            }
#endif


            GUI.SetNextControlName("5");
            if (GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(200)) / 2,
                                    ScreenUtil.ScreenHeight - ScreenUtil.getPixelHeight(100), ScreenUtil.getPixelWidth(200), style.fontSize), new GUIContent("Back", "3"), style))
            {
                _displayOptions = false;
                // update sensitivity when options are closed
                if (GameManager.Instance != null)
                {
                    foreach (Player player in GameManager.Instance.CurrentPlayerShips)
                    {
                        player.UpdateSensitivity();
                    }
                }
            }
            if (GUI.tooltip == "5")
            {
                _highlightStyle.normal = style.hover;
            }
            GUI.Button(new Rect((ScreenUtil.ScreenWidth - ScreenUtil.getPixelWidth(200)) / 2 + ScreenUtil.ScreenWidth,
                                ScreenUtil.ScreenHeight - ScreenUtil.getPixelHeight(100), ScreenUtil.getPixelWidth(200), style.fontSize), "Back", _highlightStyle);
            _highlightStyle.normal = style.normal;
            _focusID = ManageFocus(_focusID, 5);

            if (GameManager.Instance.enableSeebright)
            {
                if (SBRemote.GetButtonDown(SBRemote.BUTTON_SELECT))
                {
                    if (_focusID < 0)
                    {
                        return;
                    }
                    else if (_focusID == 3)
                    {
                        _displayOptions = false;
                        _focusID        = -1;
                    }
                }
                if (SBRemote.GetJoystickDelta(SBRemote.JOY_HORIZONTAL) > 2048 * 4 * 2)
                {
                    if (_focusID == 0 && GameManager.effectsVolume < 1)
                    {
                        GameManager.effectsVolume += .01f;
                    }
                    else if (_focusID == 1 && GameManager.musicVolume < 1)
                    {
                        GameManager.musicVolume += .01f;
                    }
                    else if (_focusID == 2 && GameManager.mouseSensitivity < .5f)
                    {
                        GameManager.mouseSensitivity += .005f;
                    }
                }
                if (SBRemote.GetJoystickDelta(SBRemote.JOY_HORIZONTAL) < -2048 * 4 * 2)
                {
                    if (_focusID == 0 && GameManager.effectsVolume > 0)
                    {
                        GameManager.effectsVolume -= .01f;
                    }
                    else if (_focusID == 1 && GameManager.musicVolume > 0)
                    {
                        GameManager.musicVolume -= .01f;
                    }
                    else if (_focusID == 2 && GameManager.mouseSensitivity > .1f)
                    {
                        GameManager.mouseSensitivity -= .005f;
                    }
                }
            }
        }
        else
        {
            _focusID = -1;
        }
    }
示例#12
0
    // Update is called once per frame
    void Update()
    {
        //Escape Menu
#if UNITY_EDITOR
        bool escapeMenuKeyPressed = Input.GetKeyDown(KeyCode.Escape);
#else
        bool escapeMenuKeyPressed = GameManager.Instance.enableSeebright ? SBRemote.GetButton(SBRemote.BUTTON_BACK) : Input.GetKeyDown(KeyCode.Escape);
#endif
        if (escapeMenuKeyPressed && !isClone)
        {
            if (!_escapeMenu.currentlyActive)
            {
                _escapeMenu.display();
            }
        }
        if (_escapeMenu.currentlyActive)
        {
            return;
        }

#if !UNITY_IPHONE
        Screen.lockCursor = true;
#endif

        //Invulnerability
        if (_invulnerable)
        {
            renderer.enabled = Mathf.Sin(Time.time * 50.0f) > 0;
        }
        if (Time.time > _invulnerabilityCooldown + RESPAWN_COOLDOWN)
        {
            renderer.enabled = true;
            _invulnerable    = false;
        }
        if (_transitioning && currentLevel.SpawnLane != null)
        {
            //if transitioning levels and clone is active, destroy clone
            if (isClone)
            {
                GameManager.Instance.removeShip(this);
                Destroy(gameObject);
            }
            setCamera();
            if (_goingDownLane)
            {
                gameObject.transform.position = Vector3.Lerp(_startPos, _endOfLane, (Time.time - _startTransTime) / (PLAYER_LEVEL_TRANSITION_TIME * 0.25f));
                if (gameObject.transform.position == _endOfLane)
                {
                    _goingDownLane = false;
                }
            }
            else
            {
                gameObject.transform.position = Vector3.Lerp(_endOfLane, currentLevel.SpawnLane.Front, (Time.time - _startTransTime) / (PLAYER_LEVEL_TRANSITION_TIME * 0.75f));
            }
            gameObject.transform.Rotate(new Vector3(1, 0, 0), 360.0f * (Time.time - _startTransTime) / PLAYER_LEVEL_TRANSITION_TIME);

            //Level Transition
            if (gameObject.transform.position == currentLevel.SpawnLane.Front &&
                CameraController.currentCamera.gameObject.transform.position == currentLevel.cameraPosition.transform.position)
            {
                if (!_flashbang.running)
                {
                    _flashbang.init(FLASHBANG_TIME);
                }
                if ((Time.time - _startTransTime) / (PLAYER_LEVEL_TRANSITION_TIME + FLASHBANG_TIME / 2.0f) >= 1.0f)
                {
                    CameraController.currentCamera.setRetroShader(false);
                }
                if (_flashbang.manualUpdate())
                {
                    return;
                }
                CameraController.currentCamera.setRetroShader(false);
                _transitioning = false;
                Destroy(_previousLevel);
                if (currentLevel.SpawnLane != null)
                {
                    currentPlane = currentLevel.lanes.IndexOf(currentLevel.SpawnLane);
                }
                else
                {
                    currentPlane = 0;
                }
            }
            return;
        }
        if (currentLevel == null || currentLevel.lanes == null)
        {
            return;
        }

        //This is a preprocess directive, exclusively used with Unity Editor
        //#yoyoloop
#if UNITY_EDITOR
        if (Input.GetKeyDown(KeyCode.Space))   // testing purposes
        {
            ActivateClone();
            ActivateMulti();
            ActivateRapid();
        }

        if (Input.GetKeyDown(KeyCode.F1))
        {
            _invulnerable            = !_invulnerable;
            _invulnerabilityCooldown = (_invulnerable) ? float.MaxValue : 0;
            GUIManager.Instance.addGUIItem(new GUIItem(Screen.width / 2, Screen.height / 2, "God Mode : " + _invulnerable.ToString(), GUIManager.Instance.defaultStyle, 4));
        }
#endif

        if (!_alive)
        {
            return;
        }

        if (!isClone)
        {
            handleMovement();
            if (_clone)
            {
                _clone.handleMovement();
            }
        }

        // shoot
        if (_numShots < 0)
        {
            _numShots = 0;
        }

        int maxMultiShots = MAX_SHOTS;
        if (isMultiActivated)
        {
            maxMultiShots = MAX_SHOTS * 3 - 2; // -2 for +3 shots from multi shot so it fires at 12 max (<13)
        }
#if UNITY_IPHONE && !UNITY_EDITOR
        bool triggerPressed = (GameManager.Instance.enableSeebright) ? SBRemote.GetButton(SBRemote.BUTTON_TRIGGER) : GameManager.Instance.TriggerPressed;
#elif UNITY_IPHONE && UNITY_EDITOR
        bool triggerPressed = (GameManager.Instance.enableSeebright) ? Input.GetMouseButton(0) : GameManager.Instance.TriggerPressed;
#else
        bool triggerPressed = Input.GetMouseButton(0);
#endif

        if (triggerPressed && _reload < 0 && _numShots < maxMultiShots)
        {
            Shoot();
            _reload = DELAY_NEXT_SHOT;
            if (isRapidActivated)
            {
                _reload /= 2.0f;
            }
        }

        // reload
        _reload -= Time.deltaTime;

        // powerup timers
        if (_rapidTime < 0)
        {
            isRapidActivated = false;
        }
        else
        {
            _rapidTime -= Time.deltaTime;
        }

        if (_multiTime < 0)
        {
            isMultiActivated = false;
        }
        else
        {
            _multiTime -= Time.deltaTime;
        }

        if (_clone == null)
        {
            isCloneActivated = false;
        }
    }
示例#13
0
    public void handleMovement()
    {
#if UNITY_IPHONE && !UNITY_EDITOR
        if (_moveTime + MOVE_DELAY > Time.time)
        {
            return;
        }
        float mouseMove = (GameManager.Instance.enableSeebright) ? SBRemote.GetAxis(SBRemote.JOY_HORIZONTAL) : GameManager.Instance.JoystickHorizontal;
        positionOnPlane = mouseMove * 3;
        if (GameManager.invertedJoystick)
        {
            positionOnPlane *= -1;
        }
        if (_isMovementMirrored)
        {
            positionOnPlane *= -1;
        }
#elif UNITY_IPHONE && UNITY_EDITOR
        if (_moveTime + MOVE_DELAY > Time.time && !GameManager.Instance.enableSeebright)
        {
            return;
        }
        float mouseMove = (GameManager.Instance.enableSeebright) ? Input.GetAxis("Mouse X") : GameManager.Instance.JoystickHorizontal;
        if (GameManager.Instance.enableSeebright)
        {
            float shipMove = mouseMove * _mouseSensitivity;
            if (_isMovementMirrored)
            {
                positionOnPlane -= shipMove;
            }
            else
            {
                positionOnPlane += shipMove;
            }
        }
        else
        {
            positionOnPlane = mouseMove * 3;
            if (GameManager.invertedJoystick)
            {
                positionOnPlane *= -1;
            }
            if (_isMovementMirrored)
            {
                positionOnPlane *= -1;
            }
        }
#else
        float mouseMove = Input.GetAxis("Mouse X");
        float shipMove  = mouseMove * _mouseSensitivity;
        if (_isMovementMirrored)
        {
            positionOnPlane -= shipMove;
        }
        else
        {
            positionOnPlane += shipMove;
        }
#endif

        currentLevel.lanes[currentPlane].setHighlight(false);
        // calculate new position after movement
        if (positionOnPlane < 0)
        {
            currentPlane--;
            positionOnPlane++;
        }
        else if (positionOnPlane > 1)
        {
            currentPlane++;
            positionOnPlane--;
        }

        if (currentPlane < 0)
        {
            if (currentLevel.wrapAround)
            {
                currentPlane += currentLevel.lanes.Count;
            }
            else
            {
                currentPlane    = 0;
                positionOnPlane = 0;
            }
        }
        else if (currentPlane >= currentLevel.lanes.Count)
        {
            if (currentLevel.wrapAround)
            {
                currentPlane -= currentLevel.lanes.Count;
            }
            else
            {
                currentPlane    = currentLevel.lanes.Count - 1;
                positionOnPlane = 1;
            }
        }
        _endOfLane = GameManager.Instance.CurrentLevel.getLaneFromIndex(currentPlane).Back;
        currentLevel.lanes[currentPlane].setHighlight(true);

        // update position
        transform.position = currentLevel.lanes[currentPlane].Front + new Vector3(renderer.bounds.extents.x, 0, 0);
        float angleUp    = Vector3.Angle(Vector3.up, currentLevel.lanes[currentPlane].Normal) - 90;
        float angleRight = Vector3.Angle(Vector3.forward, currentLevel.lanes[currentPlane].Normal);
        float angleLeft  = Vector3.Angle(Vector3.back, currentLevel.lanes[currentPlane].Normal);
        if (angleRight < angleLeft)
        {
            angleUp = -angleUp;
        }
        transform.eulerAngles = new Vector3(angleUp, 180, 0);
        _moveTime             = Time.time;
    }