コード例 #1
0
        /// <summary>
        /// Constructs a new input state.
        /// </summary>
        public InputState()
        {
            CurrentKeyboardStates = new KeyboardState[MaxInputs];
            CurrentGamePadStates = new GamePadState[MaxInputs];

            LastKeyboardStates = new KeyboardState[MaxInputs];
            LastGamePadStates = new GamePadState[MaxInputs];

            GamePadWasConnected = new bool[MaxInputs];
            currentVoiceCommand = voiceCommandStates.None;
        }
コード例 #2
0
        public int IsAimChanged(PlayerIndex? controllingPlayer)
        {
            PlayerIndex playerIndex;
            if (currentVoiceCommand == voiceCommandStates.Number)
            {
                currentVoiceCommand = voiceCommandStates.None;
                return myAngle;
            }

            else if (currentVoiceCommand == voiceCommandStates.Angle)
            {
                currentVoiceCommand = voiceCommandStates.None;
                int tempInt = (int)myArmAngle;
                return tempInt;
            }
            else
                return -1;
        }
コード例 #3
0
        public bool IsTankFire(PlayerIndex? controllingPlayer)
        {
            PlayerIndex playerIndex;

            if (currentVoiceCommand == voiceCommandStates.Fire)
            {
                currentVoiceCommand = voiceCommandStates.None;
                return true;
            }

            return IsNewKeyPress(Keys.Space, controllingPlayer, out playerIndex);
        }
コード例 #4
0
        /// <summary>
        /// Checks for a "pause the game" input action.
        /// The controllingPlayer parameter specifies which player to read
        /// input for. If this is null, it will accept input from any player.
        /// </summary>
        public bool IsPauseGame(PlayerIndex? controllingPlayer)
        {
            PlayerIndex playerIndex;

            if (currentVoiceCommand == voiceCommandStates.Pause)
            {
                currentVoiceCommand = voiceCommandStates.None;
                return true;
            }

            return IsNewKeyPress(Keys.Escape, controllingPlayer, out playerIndex) ||
                   IsNewButtonPress(Buttons.Back, controllingPlayer, out playerIndex) ||
                   IsNewButtonPress(Buttons.Start, controllingPlayer, out playerIndex);
        }
コード例 #5
0
        /// <summary>
        /// Checks for a "menu up" input action.
        /// The controllingPlayer parameter specifies which player to read
        /// input for. If this is null, it will accept input from any player.
        /// </summary>
        public bool IsMenuUp(PlayerIndex? controllingPlayer)
        {
            PlayerIndex playerIndex;

            if (currentVoiceCommand == voiceCommandStates.Up)
            {
                currentVoiceCommand = voiceCommandStates.None;
                return true;
            }

            return IsNewKeyPress(Keys.Up, controllingPlayer, out playerIndex) ||
                   IsNewButtonPress(Buttons.DPadUp, controllingPlayer, out playerIndex) ||
                   IsNewButtonPress(Buttons.LeftThumbstickUp, controllingPlayer, out playerIndex);
        }
コード例 #6
0
        /// <summary>
        /// Checks for a "menu select" input action.
        /// The controllingPlayer parameter specifies which player to read input for.
        /// If this is null, it will accept input from any player. When the action
        /// is detected, the output playerIndex reports which player pressed it.
        /// </summary>
        public bool IsMenuSelect(PlayerIndex? controllingPlayer,
                                 out PlayerIndex playerIndex)
        {
            if (currentVoiceCommand == voiceCommandStates.Enter)
            {
                currentVoiceCommand = voiceCommandStates.None;
                playerIndex = 0;
                return true;
            }

            return IsNewKeyPress(Keys.Space, controllingPlayer, out playerIndex) ||
                   IsNewKeyPress(Keys.Enter, controllingPlayer, out playerIndex) ||
                   IsNewButtonPress(Buttons.A, controllingPlayer, out playerIndex) ||
                   IsNewButtonPress(Buttons.Start, controllingPlayer, out playerIndex);
        }
コード例 #7
0
        /// <summary>
        /// Checks for a "menu cancel" input action.
        /// The controllingPlayer parameter specifies which player to read input for.
        /// If this is null, it will accept input from any player. When the action
        /// is detected, the output playerIndex reports which player pressed it.
        /// </summary>
        public bool IsMenuCancel(PlayerIndex? controllingPlayer,
                                 out PlayerIndex playerIndex)
        {
            if (currentVoiceCommand == voiceCommandStates.Resume)
            {
                currentVoiceCommand = voiceCommandStates.None;
                playerIndex = 0;
                return true;
            }

            return IsNewKeyPress(Keys.Escape, controllingPlayer, out playerIndex) ||
                   IsNewButtonPress(Buttons.B, controllingPlayer, out playerIndex) ||
                   IsNewButtonPress(Buttons.Back, controllingPlayer, out playerIndex);
        }
コード例 #8
0
        public bool IsAimUp(PlayerIndex? controllingPlayer)
        {
            PlayerIndex playerIndex;

            if (currentVoiceCommand == voiceCommandStates.Up)
            {
                currentVoiceCommand = voiceCommandStates.None;
                return true;
            }

            return IsNewKeyPress(Keys.Up, controllingPlayer, out playerIndex) ||
                   IsKeyHeld(Keys.Up);
        }