public override void HandleInput(InputState 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(InputState input) { PlayerIndex playerIndex; if (input.IsMenuSelect(ControllingPlayer, out playerIndex)) { if (Accepted != null) Accepted(this, new PlayerIndexEventArgs(playerIndex)); ExitScreen(); } }
public override void HandleInput(InputState input) { //if no input, throw exception if (input == null) throw new ArgumentNullException("input"); //playerindex is the controlling player int playerIndex = (int)ControllingPlayer.Value; //set new keyboard and controller state objects KeyboardState keyboardState = input.CurrentKeyboardStates[playerIndex]; GamePadState gamePadState = input.CurrentGamePadStates[playerIndex]; //set a new boolean as the current connection state of the game pad bool gamePadDisconnected = !gamePadState.IsConnected && input.GamePadWasConnected[playerIndex]; //of the gamepad is disconnected or the game is paused then then //pause the game if (input.IsPauseGame(ControllingPlayer) || gamePadDisconnected) ScreenManager.AddScreen(PauseMenu, ControllingPlayer); //if game is not paused else { //Check if controller should be vibrating, vibrate it //Otherwise remove vibration if (Vibrate) GamePad.SetVibration(ControllingPlayer.Value, 0.5f, 0.5f); else GamePad.SetVibration(ControllingPlayer.Value, 0, 0); //if the left trigger or left alt key is held down then switch to top //down view if (gamePadState.Triggers.Left > 0 || keyboardState.IsKeyDown(Keys.LeftAlt)) { if (!CamPressed) { if (isTopDown) { Cam.MainCam(); isTopDown = false; } else { Cam.TopDown(); isTopDown = true; } CamPressed = true; } } else CamPressed = false; //update the camera Cam.Update(); //Set the player velocity to either the X value of the left //thumbstick or the left or right key Player.SetVelocity(new Vector3(0.2f * gamePadState.ThumbSticks.Left.X, 0, 0)); if (keyboardState.IsKeyDown(Keys.Left)) Player.SetVelocity(new Vector3(-0.2f, 0, 0)); if (keyboardState.IsKeyDown(Keys.Right)) Player.SetVelocity(new Vector3(0.2f, 0, 0)); //if the player collides with the arena or the player collides with //the ball with a velocity*2 then stop the player if (Player.InternalCollision(Arena) || Player.ExternalCollision(Ball, 2)) Player.SetVelocity(Vector3.Zero); //if the player is carrying the ball and either the A button or //space bar is pressed then the ball is released if (SetPlayerCarry && gamePadState.IsButtonDown(Buttons.A) || SetPlayerCarry && keyboardState.IsKeyDown(Keys.Space)) { if (Ball.GetPosition() == new Vector3(Player.GetPosition().X + (Player.GetSize().X / 2), Ball.GetPosition().Y, 14.5f)) { Ball.SetVelocity(new Vector3(0.15f, 0, -0.15f)); Ball.SetSpeed(Ball.GetVelocity().X + -Ball.GetVelocity().Z); SetPlayerCarry = false; } } //if the background music is not being changed and the right shoulder //button or the W key is pressed then pause the current song, and //go to the next one. set the background music to being changed. //also check if the song is at the end in which case set to first //song again if (!SwitchCue) { if (gamePadState.IsButtonDown(Buttons.RightShoulder)||keyboardState.IsKeyDown(Keys.W)) { if (!PauseCue) { SwitchCue = true; BGM[currentcue].Pause(); if (currentcue < BGM.Length - 1) currentcue++; else currentcue = 0; } } //if the background music is not being changed and the left shoulder //button or the Q key is pressed then pause the current song, and //go to the previous one. set the background music to being changed. //also check if the song is at the beginning in which case set to the //last song again if (gamePadState.IsButtonDown(Buttons.LeftShoulder) || keyboardState.IsKeyDown(Keys.Q)) { if (!PauseCue) { SwitchCue = true; BGM[currentcue].Pause(); if (currentcue != 0) currentcue--; else currentcue = BGM.Length - 1; } } } //if the song is being changed and all song modifier buttons are released //then set the song to not being changed else if (gamePadState.IsButtonUp(Buttons.RightShoulder) && gamePadState.IsButtonUp(Buttons.LeftShoulder) && keyboardState.IsKeyUp(Keys.Q) && keyboardState.IsKeyUp(Keys.W)) SwitchCue = false; //if the music is not off and down on the dpad or the A key is pressed //then turn off the music and change the music animation to something that looks off if (!PauseCue) { if (gamePadState.IsButtonDown(Buttons.DPadDown) || keyboardState.IsKeyDown(Keys.A)) { PauseCue = true; MusicPlayer = new clsDrops(15, tMusicPlayerOff, new Vector2(435, 133), new Vector2(155, 24), Vector2.Zero, 0); MusicPlayer.Show(); } } //if the music is turned off and up on the dpad or the S key is press //then turn on the music and change the music animation to something that looks on else { if (gamePadState.IsButtonDown(Buttons.DPadUp) || keyboardState.IsKeyDown(Keys.S)) { PauseCue = false; MusicPlayer = new clsDrops(15, tMusicPlayer, new Vector2(435, 133), new Vector2(155, 24), Vector2.Zero, 4); MusicPlayer.Show(); } } } }
public virtual void HandleInput(InputState input) { }