public bool Evaluate(InputState state, PlayerIndex? controllingPlayer, out PlayerIndex player) { ButtonPress buttonTest; KeyPress keyTest; if (newPressOnly) { buttonTest = state.IsNewButtonPress; keyTest = state.IsNewKeyPress; } else { buttonTest = state.IsButtonPressed; keyTest = state.IsKeyPressed; } foreach (Buttons button in buttons) { if (buttonTest(button, controllingPlayer, out player)) return true; } foreach (Keys key in keys) { if (keyTest(key, controllingPlayer, out player)) return true; } player = PlayerIndex.One; return false; }
public virtual void HandleInput(GameTime gameTime, InputState input) { }
public override void HandleInput(GameTime gameTime, InputState input) { PlayerIndex playerIndex; if (menuUp.Evaluate(input, ControllingPlayer, out playerIndex)) { selectedEntry--; if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1; } if (menuDown.Evaluate(input, ControllingPlayer, out playerIndex)) { selectedEntry++; if (selectedEntry >= menuEntries.Count) selectedEntry = 0; } if (menuSelect.Evaluate(input, ControllingPlayer, out playerIndex)) { OnSelectEntry(selectedEntry, playerIndex); } else if (menuCancel.Evaluate(input, ControllingPlayer, out playerIndex)) { OnCancel(playerIndex); } }
public override void HandleInput(GameTime gameTime, InputState input) { if (input == null) throw new ArgumentNullException("input"); PlayerIndex player; if (_menuSelected == (int)MenuSelected.JUST_CHANGED) _menuSelected = (int)MenuSelected.NONE; switch (_menuSelected) { case (int)MenuSelected.BLURTYPE: if (_upAction.Evaluate(input, ControllingPlayer, out player)) nextBlurType(); else if (_downAction.Evaluate(input, ControllingPlayer, out player)) nextBlurType(); else if (_deselectAction.Evaluate(input, ControllingPlayer, out player)) _menuSelected = (int)MenuSelected.JUST_CHANGED; break; case (int)MenuSelected.BLUR: if (_upAction.Evaluate(input, ControllingPlayer, out player)) moreBlur(); else if (_downAction.Evaluate(input, ControllingPlayer, out player)) lessBlur(); else if (_deselectAction.Evaluate(input, ControllingPlayer, out player)) { _blur.Text = "Blur"; _menuSelected = (int)MenuSelected.JUST_CHANGED; } break; case (int)MenuSelected.TRANSPARECY: if (_upAction.Evaluate(input, ControllingPlayer, out player)) { moreTransparacy(); } else if (_downAction.Evaluate(input, ControllingPlayer, out player)) { lessTransparacy(); } else if (_deselectAction.Evaluate(input, ControllingPlayer, out player)) { _iceTransparency.Text = "Ice Transparency"; _menuSelected = (int)MenuSelected.JUST_CHANGED; } break; case (int)MenuSelected.NONE: default: break; } if(_menuSelected == (int)MenuSelected.NONE) base.HandleInput(gameTime, input); }
public override void HandleInput(GameTime gameTime, InputState input) { if (_networkSession != null) { foreach (LocalNetworkGamer gamer in _networkSession.LocalGamers) { if (!HandlePlayerInput(gameTime, input, gamer.SignedInGamer.PlayerIndex)) break; } } else HandlePlayerInput(gameTime, input, ControllingPlayer.Value); }
protected bool HandlePlayerInput(GameTime gameTime, InputState input, PlayerIndex playerIndex) { if (input == null) throw new ArgumentNullException("input"); KeyboardState keyboardState = input.CurrentKeyboardStates[(int)playerIndex]; GamePadState gamePadState = input.CurrentGamePadStates[(int)playerIndex]; // The game pauses either if the user presses the pause button, or if // they unplug the active gamepad bool gamePadDisconnected = !gamePadState.IsConnected && input.GamePadWasConnected[(int)playerIndex]; PlayerIndex player; if (_pauseAction.Evaluate(input, ControllingPlayer, out player) || gamePadDisconnected) { ScreenManager.AddScreen(new PauseMenuScreen(), ControllingPlayer); _isPropertiesWindow = false; return false; } if(_propertiesAction.Evaluate(input, ControllingPlayer, out player)) { ScreenManager.AddScreen(new PropertiesMenuScreen(_gameManager), ControllingPlayer); _isPropertiesWindow = true; return false; } return true; }
public override void HandleInput(GameTime gameTime, InputState input) { PlayerIndex playerIndex; if (menuSelect.Evaluate(input, ControllingPlayer, out playerIndex)) { if (Accepted != null) Accepted(this, new PlayerIndexEventArgs(playerIndex)); ExitScreen(); } else if (menuCancel.Evaluate(input, ControllingPlayer, out playerIndex)) { if (Cancelled != null) Cancelled(this, new PlayerIndexEventArgs(playerIndex)); ExitScreen(); } }