Exemplo n.º 1
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);
    }
Exemplo n.º 2
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;
            }
        }
    }
Exemplo n.º 3
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;
    }