Пример #1
0
        public Single Vertical()
        {
            Single vert = 0.0f;

            // Mouse.
            if (mouseScreenInput.LeftButtonPress())
            {
                vert = controlManager.CheckJoyPadVert(mouseScreenInput.MousePosition);
                if (Math.Abs(vert) > Single.Epsilon)
                {
                    return(vert);
                }
            }

            // Joystick.
            Byte   index  = (Byte)joystickInput.CurrPlayerIndex;
            Single floatY = joystickInput.CurrGamePadState[index].ThumbSticks.Left.Y;

            if (floatY < -Constants.JoystickTolerance || floatY > Constants.JoystickTolerance)
            {
                return(-floatY);
            }
            if (joystickInput.CurrGamePadState[index].IsButtonDown(Buttons.DPadUp))
            {
                return(-1.0f);
            }
            if (joystickInput.CurrGamePadState[index].IsButtonDown(Buttons.DPadDown))
            {
                return(1.0f);
            }

            // Keyboard.
            if (keyboardInput.KeyPress(Keys.Up))
            {
                vert = -1.0f;
            }
            if (keyboardInput.KeyPress(Keys.Down))
            {
                vert = 1.0f;
            }

            return(vert);
        }