public override void HandleInput(InputState input) { PlayerIndex player; if (input.IsNewButtonPress(Buttons.Y, ControllingPlayer, out player)) { #if XBOX Debug.Assert (ControllingPlayer != null); HighScores2.GoLoad(ControllingPlayer ?? PlayerIndex.One); #else HighScores2.DoWindowsLoadGame(); #endif ScreenManager.AddScreen(new HighScoreScreen(), ControllingPlayer); } if (input.IsMenuCancel(ControllingPlayer, out player)) { MediaPlayer.Stop(); } songSelectionBox.HandleInput(input); if (songSelectionBox.SongCount <= 0 && input.IsNewButtonPress(Buttons.A, null, out player)) { return; } base.HandleInput(input); }
/// <summary> /// Responds to user input, accepting or cancelling the message box. /// </summary> public override void HandleInput(InputState input) { PlayerIndex playerIndex; // We pass in our ControllingPlayer, which may either be null (to // accept input from any player) or a specific index. If we pass a null // controlling player, the InputState helper returns to us which player // actually provided the input. We pass that through to our Accepted and // Cancelled events, so they can tell which player triggered them. if (input.IsMenuSelect(ControllingPlayer, out playerIndex)) { // Raise the accepted event, then exit the message box. if (Accepted != null) { Accepted(this, new PlayerIndexEventArgs(playerIndex)); } ExitScreen(); } else if (input.IsMenuCancel(ControllingPlayer, out playerIndex)) { // Raise the cancelled event, then exit the message box. if (Cancelled != null) { Cancelled(this, new PlayerIndexEventArgs(playerIndex)); } ExitScreen(); } }
/// <summary> /// Responds to user input, changing the selected entry and accepting /// or cancelling the menu. /// </summary> public override void HandleInput(InputState input) { var touch = input.TouchState; var rect = new Rectangle(0, 0, 100, 30); if (touch.Count == 1) { for (int i = 0; i < menuEntries.Count; i++) { rect.X = (int)menuEntries[i].Position.X; rect.Y = (int)menuEntries[i].Position.Y; selectedEntry = i; if (rect.Contains((int)touch[0].Position.X, (int)touch[0].Position.Y)) { OnSelectEntry(selectedEntry, 0); break; } } } // Move to the previous menu entry? if (input.IsMenuUp(ControllingPlayer)) { selectedEntry--; if (selectedEntry < 0) { selectedEntry = menuEntries.Count - 1; } } // Move to the next menu entry? if (input.IsMenuDown(ControllingPlayer)) { selectedEntry++; if (selectedEntry >= menuEntries.Count) { selectedEntry = 0; } } // Accept or cancel the menu? We pass in our ControllingPlayer, which may // either be null (to accept input from any player) or a specific index. // If we pass a null controlling player, the InputState helper returns to // us which player actually provided the input. We pass that through to // OnSelectEntry and OnCancel, so they can tell which player triggered them. 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; // Exit game if (input.IsMenuCancel(ControllingPlayer, out playerIndex)) { OnCancel(playerIndex); } // Start game if (TransitionAlpha == 1.0f) { GamePadState state1 = GamePad.GetState(PlayerIndex.One); GamePadState state2 = GamePad.GetState(PlayerIndex.Two); GamePadState state3 = GamePad.GetState(PlayerIndex.Three); GamePadState state4 = GamePad.GetState(PlayerIndex.Four); if (state1.IsButtonDown(Buttons.Start)) { ActivePlayer.PlayerIndex = PlayerIndex.One; startPressed = true; } else if (state2.IsButtonDown(Buttons.Start)) { ActivePlayer.PlayerIndex = PlayerIndex.Two; startPressed = true; } else if (state3.IsButtonDown(Buttons.Start)) { ActivePlayer.PlayerIndex = PlayerIndex.Three; startPressed = true; } else if (state4.IsButtonDown(Buttons.Start)) { ActivePlayer.PlayerIndex = PlayerIndex.Four; startPressed = true; } #if WINDOWS KeyboardState keyboardState = Keyboard.GetState(); if (keyboardState.IsKeyDown(Keys.Enter)) { startPressed = true; } #endif } if (startPressed) { StartButtonPressed(); } }
/// <summary> /// Responds to user input, accepting or cancelling the message box. /// </summary> public override void HandleInput(InputState input) { PlayerIndex playerIndex; Viewport viewport = ScreenManager.Game.GraphicsDevice.Viewport; Vector2 halfSize = new Vector2(viewport.Width, viewport.Height) / 2; // We pass in our ControllingPlayer, which may either be null (to // accept input from any player) or a specific index. If we pass a null // controlling player, the InputState helper returns to us which player // actually provided the input. We pass that through to our Accepted and // Cancelled events, so they can tell which player triggered them. if (input.IsMenuSelect()) { // Raise the accepted event, then exit the message box. if (Accepted != null) { Accepted(this, new EventArgs()); } ExitScreen(); } else if (input.IsMenuCancel()) { // Raise the cancelled event, then exit the message box. if (Cancelled != null) { Cancelled(this, new EventArgs()); } ExitScreen(); } Point mouseLoc = new Point(input.CurrentMouseState.X, input.CurrentMouseState.Y); Rectangle okRect = new Rectangle((int)halfSize.X - 25, (int)halfSize.Y + 25, 50, 50); if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released) { if (okRect.Contains(mouseLoc)) { ExitScreen(); } } }
/// <summary> /// Responds to user input, changing the selected entry and accepting /// or cancelling the menu. /// </summary> public override void HandleInput(InputState input) { // Move to the previous menu entry? if (input.IsMenuUp(ControllingPlayer)) { selectedEntry--; menuSFX.Play(); if (selectedEntry < 0) { selectedEntry = menuEntries.Count - 1; } } // Move to the next menu entry? if (input.IsMenuDown(ControllingPlayer)) { selectedEntry++; menuSFX.Play(); if (selectedEntry >= menuEntries.Count) { selectedEntry = 0; } } // Accept or cancel the menu? We pass in our ControllingPlayer, which may // either be null (to accept input from any player) or a specific index. // If we pass a null controlling player, the InputState helper returns to // us which player actually provided the input. We pass that through to // OnSelectEntry and OnCancel, so they can tell which player triggered them. PlayerIndex playerIndex; if (input.IsMenuSelect(ControllingPlayer, out playerIndex)) { OnSelectEntry(selectedEntry, playerIndex); } else if (input.IsMenuCancel(ControllingPlayer, out playerIndex)) { OnCancel(playerIndex); } }
/// <summary> /// Responds to user input, changing the selected entry and accepting /// or cancelling the menu /// </summary> public override void HandleInput(InputState input) { // Move to the previous menu entry if (input.IsMenuUp()) { // Decrement the currently selected entry selectedEntry--; // If the entry is less than 0, wrap it back around to the last entry if (selectedEntry < 0) { selectedEntry = menuEntries.Count - 1; } } // Move to the next menu entry if (input.IsMenuDown()) { // Increment the currently selected entry selectedEntry++; // If the entry is the last entry, wrap it back around to first entry if (selectedEntry >= menuEntries.Count) { selectedEntry = 0; } } // Check to see if a menu was selected if (input.IsMenuSelect()) { // Trigger the event for the selected entry OnSelectEntry(selectedEntry); } // Otherwhise, check if the user cancelled the menu else if (input.IsMenuCancel()) { // Call the cancel method to take the user out OnCancel(); } }
public override void HandleInput(InputState input) { PlayerIndex playerIndex; if (input.IsMenuCancel(ControllingPlayer, out playerIndex)) { // Remove all MedalsMenuScreens open GameScreen[] screens = ScreenManager.GetScreens(); for (int i = screens.Length - 1; i >= 0; i--) { if (screens[i] is MedalsMenuScreen) { screens[i].ExitScreen(); } } } else if (input.IsNewButtonPress(Buttons.LeftShoulder, ControllingPlayer, out playerIndex) || input.IsNewKeyPress(Keys.Left, ControllingPlayer, out playerIndex)) { if (medalStartIndex != 0) { screenChangeSFX.Play(0.5f, -0.1f, 0.0f); // Remove this page of medals OnCancel(playerIndex); } } else if (input.IsNewButtonPress(Buttons.RightShoulder, ControllingPlayer, out playerIndex) || input.IsNewKeyPress(Keys.Right, ControllingPlayer, out playerIndex)) { // Add a new page of medals if needed if (medalStartIndex + MEDALS_PER_SCREEN < ActivePlayer.Profile.MedalList.Count) { screenChangeSFX.Play(0.5f, 0.1f, 0.0f); ScreenManager.AddScreen(new MedalsMenuScreen(medalStartIndex + MEDALS_PER_SCREEN, 0), ActivePlayer.PlayerIndex); } } }
/// <summary> /// Responds to user input, changing the selected entry and accepting /// or cancelling the menu. /// </summary> public override void HandleInput(InputState input) { if (input.IsMenuCancel()) { OnCancel(null, null); } if (input.IsMenuUp()) { selectedEntry--; if (selectedEntry < 0) { selectedEntry = menuEntries.Count - 1; } while (!menuEntries[selectedEntry].Enabled) { selectedEntry--; if (selectedEntry < 0) { selectedEntry = menuEntries.Count - 1; } } } if (input.IsMenuDown()) { selectedEntry++; if (selectedEntry >= menuEntries.Count) { selectedEntry = 0; } while (!menuEntries[selectedEntry].Enabled) { selectedEntry++; if (selectedEntry >= menuEntries.Count) { selectedEntry = 0; } } } if (input.IsMenuLeft()) { menuEntries[selectedEntry].Left(); } if (input.IsMenuRight()) { menuEntries[selectedEntry].Right(); } if (input.IsMenuSelect()) { OnSelectEntry(selectedEntry); } if (selectedEntry < 0) { selectedEntry = menuEntries.Count - 1; } if (selectedEntry >= menuEntries.Count) { selectedEntry = 0; } Point mouseLocation = ScreenManager.ScaledMousePos; for (int i = 0; i < menuEntries.Count; i++) { MenuEntry menuEntry = menuEntries[i]; if (GetMenuEntryHitBounds(menuEntry).Contains(mouseLocation)) { selectedEntry = i; // Mouse left click? if (input.CurrentMouseState.LeftButton == ButtonState.Released && input.LastMouseState.LeftButton == ButtonState.Pressed) { menuEntry.Click(mouseLocation.X, mouseLocation.Y); } } } }
/// <summary> /// Handles user input for all the local gamers in the session. Unlike most /// screens, which use the InputState class to combine input data from all /// gamepads, the lobby needs to individually mark specific players as ready, /// so it loops over all the local gamers and reads their inputs individually. /// </summary> public override void HandleInput (InputState input) { foreach (LocalNetworkGamer gamer in networkSession.LocalGamers) { PlayerIndex playerIndex = gamer.SignedInGamer.PlayerIndex; PlayerIndex unwantedOutput; if (input.IsMenuSelect (playerIndex, out unwantedOutput)) { HandleMenuSelect (gamer); } else if (input.IsMenuCancel (playerIndex, out unwantedOutput)) { HandleMenuCancel (gamer); } } }
private bool HandleGameplayInputButtons(InputState input, Player cP) { PlayerIndex output; if (input.IsSelect(cP.PI, out output)) { if (cP.selected == false && cP.hover.getOwner() == cP && cP.hover.canAddMove()) { cP.selected = true; cP.origin = cP.hover; } else if (cP.selected == true) { cP.selected = false; if (cP.target == Player.Tgt.Self && cP.hover != cP.origin && cP.origin.canAddMove()) { //cP.origin.transfer(cP.dest); cP.dest = cP.hover; movements.Add(new Movement(cP, cP.origin, cP.dest, Movement.Type.Transfer)); } if (cP.target == Player.Tgt.Enemy && cP.origin.canAddMove()) { //cP.origin.attack(cP.dest); cP.dest = cP.hover; movements.Add(new Movement(cP, cP.origin, cP.dest, Movement.Type.Attack)); } } } else if (input.IsMenuCancel(cP.PI, out output)) { if (cP.selected == true) { cP.selected = false; } else { cP.hover.cancelOutgoing = true; pruneMovements(); } } else if (input.IsScrollLeft(cP.PI)) { cP.decPower(); } else if (input.IsScrollRight(cP.PI)) { cP.incPower(); } else if (input.IsUsePower(cP.PI)) { if (cP.usePower()) { if (cP.curPower == Player.Power.Transfer) transfer(cP); else if (cP.curPower == Player.Power.Reinforce) reinforce(cP); else if (cP.curPower == Player.Power.Invincible) invincible(cP); else if (cP.curPower == Player.Power.Defect) defect(cP, cP.hover); } } else { return false; } return true; }
/// <summary> /// Responds to user input, changing the selected entry and accepting /// or cancelling the menu. /// </summary> public override void HandleInput(InputState input) { if (input.IsMenuCancel()) { OnCancel(null, null); } if (input.IsMenuUp()) { selectedEntry--; if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1; while (!menuEntries[selectedEntry].Enabled) { selectedEntry--; if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1; } } if (input.IsMenuDown()) { selectedEntry++; if (selectedEntry >= menuEntries.Count) selectedEntry = 0; while (!menuEntries[selectedEntry].Enabled) { selectedEntry++; if (selectedEntry >= menuEntries.Count) selectedEntry = 0; } } if (input.IsMenuLeft()) menuEntries[selectedEntry].Left(); if (input.IsMenuRight()) menuEntries[selectedEntry].Right(); if (input.IsMenuSelect()) OnSelectEntry(selectedEntry); if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1; if (selectedEntry >= menuEntries.Count) selectedEntry = 0; Point mouseLocation = ScreenManager.ScaledMousePos; for (int i = 0; i < menuEntries.Count; i++) { MenuEntry menuEntry = menuEntries[i]; if (GetMenuEntryHitBounds(menuEntry).Contains(mouseLocation)) { selectedEntry = i; // Mouse left click? if (input.CurrentMouseState.LeftButton == ButtonState.Released && input.LastMouseState.LeftButton == ButtonState.Pressed) { menuEntry.Click(mouseLocation.X, mouseLocation.Y); } } } }
/// <summary> /// Responds to user input, changing the selected entry and accepting /// or cancelling the menu. /// </summary> public override void HandleInput(InputState input) { // Accept or cancel the menu? We pass in our ControllingPlayer, which may // either be null (to accept input from any player) or a specific index. // If we pass a null controlling player, the InputState helper returns to // us which player actually provided the input. We pass that through to // OnSelectEntry and OnCancel, so they can tell which player triggered them. PlayerIndex playerIndex; if (input.IsMenuSelect(ControllingPlayer, out playerIndex)) { //OnSelectEntry(selectedEntry, playerIndex); //ExitScreen(); showControls = !showControls; } if (input.IsMenuCancel(ControllingPlayer, out playerIndex)) { //OnCancel(playerIndex); ExitScreen(); } }
/// <summary> /// Responds to user input, accepting or cancelling the message box. /// </summary> public override void HandleInput(InputState input) { PlayerIndex playerIndex; Viewport viewport = ScreenManager.Game.GraphicsDevice.Viewport; Vector2 halfSize = new Vector2(viewport.Width, viewport.Height)/2; // We pass in our ControllingPlayer, which may either be null (to // accept input from any player) or a specific index. If we pass a null // controlling player, the InputState helper returns to us which player // actually provided the input. We pass that through to our Accepted and // Cancelled events, so they can tell which player triggered them. if (input.IsMenuSelect()) { // Raise the accepted event, then exit the message box. if (Accepted != null) Accepted(this, new EventArgs()); ExitScreen(); } else if (input.IsMenuCancel()) { // Raise the cancelled event, then exit the message box. if (Cancelled != null) Cancelled(this, new EventArgs()); ExitScreen(); } Point mouseLoc = new Point(input.CurrentMouseState.X, input.CurrentMouseState.Y); Rectangle okRect = new Rectangle((int)halfSize.X - 25, (int)halfSize.Y + 25, 50, 50); if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released) { if (okRect.Contains(mouseLoc)) ExitScreen(); } }
/// <summary> /// Responds to user input, changing the selected entry and accepting /// or cancelling the menu. /// </summary> public override void HandleInput(InputState input) { // Move to the previous menu entry? if (input.IsMenuUp(ControllingPlayer)) { selectedEntry--; if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1; } // Move to the next menu entry? if (input.IsMenuDown(ControllingPlayer)) { selectedEntry++; if (selectedEntry >= menuEntries.Count) selectedEntry = 0; } // Accept or cancel the menu? We pass in our ControllingPlayer, which may // either be null (to accept input from any player) or a specific index. // If we pass a null controlling player, the InputState helper returns to // us which player actually provided the input. We pass that through to // OnSelectEntry and OnCancel, so they can tell which player triggered them. PlayerIndex playerIndex; if (input.IsMenuSelect(ControllingPlayer, out playerIndex)) { OnSelectEntry(selectedEntry, playerIndex); } else if (input.IsMenuCancel(ControllingPlayer, out playerIndex)) { OnCancel(playerIndex); } }
/// <summary> /// Responds to user input, accepting or cancelling the message box. /// </summary> public override void HandleInput(InputState input) { PlayerIndex playerIndex; // We pass in our ControllingPlayer, which may either be null (to // accept input from any player) or a specific index. If we pass a null // controlling player, the InputState helper returns to us which player // actually provided the input. We pass that through to our Accepted and // Cancelled events, so they can tell which player triggered them. if (input.IsMenuSelect(ControllingPlayer, out playerIndex)) { // Raise the accepted event, then exit the message box. if (Accepted != null) Accepted(this, new PlayerIndexEventArgs(playerIndex)); ExitScreen(); } else if (input.IsMenuCancel(ControllingPlayer, out playerIndex)) { // Raise the cancelled event, then exit the message box. if (Cancelled != null) Cancelled(this, new PlayerIndexEventArgs(playerIndex)); ExitScreen(); } }
/// <summary> /// Responds to user input, changing the selected entry and accepting /// or cancelling the menu. /// </summary> public override void HandleInput(InputState input) { var touch = input.TouchState; var rect = new Rectangle(0,0,100,30); if (touch.Count == 1 ) { for (int i = 0; i < menuEntries.Count; i++){ rect.X = (int)menuEntries[i].Position.X; rect.Y = (int)menuEntries[i].Position.Y; selectedEntry = i; if (rect.Contains((int)touch[0].Position.X, (int)touch[0].Position.Y)){ OnSelectEntry(selectedEntry, 0); break; } } } // Move to the previous menu entry? if (input.IsMenuUp(ControllingPlayer)) { selectedEntry--; if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1; } // Move to the next menu entry? if (input.IsMenuDown(ControllingPlayer)) { selectedEntry++; if (selectedEntry >= menuEntries.Count) selectedEntry = 0; } // Accept or cancel the menu? We pass in our ControllingPlayer, which may // either be null (to accept input from any player) or a specific index. // If we pass a null controlling player, the InputState helper returns to // us which player actually provided the input. We pass that through to // OnSelectEntry and OnCancel, so they can tell which player triggered them. PlayerIndex playerIndex; if (input.IsMenuSelect(ControllingPlayer, out playerIndex)) { OnSelectEntry(selectedEntry, playerIndex); } else if (input.IsMenuCancel(ControllingPlayer, out playerIndex)) { OnCancel(playerIndex); } }