public override void HandleInput(ControllerState input) { if (input.IsMenuUp(ControllingPlayer)) { --selectedEntry; if (selectedEntry < 0) { selectedEntry = menuEntries.Count - 1; } } if (input.IsMenuDown(ControllingPlayer)) { ++selectedEntry; if (selectedEntry >= menuEntries.Count) { selectedEntry = 0; } } PlayerIndex playerIndex; if (input.IsMenuSelect(ControllingPlayer, out playerIndex)) { OnSelectEntry(selectedEntry, playerIndex); } else if (input.IsMenuCancel(ControllingPlayer, out playerIndex)) { OnCancel(playerIndex); } }
public override void HandleInput(ControllerState input) { if (input == null) { throw new ArgumentNullException("input"); } int playerIndex = (int)ControllingPlayer.Value; KeyboardState keyboardState = input.CurrentKeyboardStates[playerIndex]; GamePadState gamePadState = input.CurrentGamePadStates[playerIndex]; bool gamePadDisconnected = !gamePadState.IsConnected && input.GamePadWasConnected[playerIndex]; if (input.IsPauseGame(ControllingPlayer) || gamePadDisconnected) { ScreenManager.AddScreen(new PauseMenuScreen(), ControllingPlayer); } else { Vector2 movement = Vector2.Zero; if (keyboardState.IsKeyDown(Keys.Left)) { --movement.X; } if (keyboardState.IsKeyDown(Keys.Right)) { ++movement.X; } if (keyboardState.IsKeyDown(Keys.Up)) { --movement.Y; } if (keyboardState.IsKeyDown(Keys.Down)) { ++movement.Y; } Vector2 thumbstick = gamePadState.ThumbSticks.Left; movement.X += thumbstick.X; movement.Y += thumbstick.Y; if (movement.Length() > 1) { movement.Normalize(); } playerPosition += movement * 2; } }
public virtual void HandleInput(ControllerState input) { }