/// <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.MenuUp) { selectedEntry--; if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1; AudioManager.PlaySoundEffect("menu_scroll"); } // Move to the next menu entry? if (input.MenuDown) { selectedEntry++; if (selectedEntry >= menuEntries.Count) selectedEntry = 0; AudioManager.PlaySoundEffect("menu_scroll"); } // Accept or cancel the menu? if (input.MenuSelect) { AudioManager.PlaySoundEffect("menu_select"); OnSelectEntry(selectedEntry); } else if (input.MenuCancel) { OnCancel(); } }
/// <summary> /// Responds to user input, accepting or cancelling the message box. /// </summary> public override void HandleInput(InputState input) { if (input.MenuSelect && (!pauseMenu || (input.CurrentGamePadState.Buttons.A == ButtonState.Pressed))) { // Raise the accepted event, then exit the message box. if (Accepted != null) Accepted(this, EventArgs.Empty); ExitScreen(); } else if (input.MenuCancel || (input.MenuSelect && pauseMenu && (input.CurrentGamePadState.Buttons.A == ButtonState.Released))) { // Raise the cancelled event, then exit the message box. if (Cancelled != null) Cancelled(this, EventArgs.Empty); ExitScreen(); } }
/// <summary> /// Lets the game respond to player input. Unlike the Update method, /// this will only be called when the gameplay screen is active. /// </summary> public override void HandleInput(InputState input) { if (input == null) throw new ArgumentNullException("input"); if (!IsExiting) { if ((world != null) && !world.GameExited) { if (input.PauseGame && !world.GameWon) { // If they pressed pause, bring up the pause menu screen. const string message = "Exit the game?"; MessageBoxScreen messageBox = new MessageBoxScreen(message, false); messageBox.Accepted += ExitMessageBoxAccepted; ScreenManager.AddScreen(messageBox); } if (input.MenuSelect && world.GameWon) { world.GameExited = true; world = null; if (!IsExiting) { ExitScreen(); } networkSession = null; } } } }
/// <summary> /// Lets the game respond to player input. Unlike the Update method, /// this will only be called when the gameplay screen is active. /// </summary> public override void HandleInput(InputState input) { // safety-check the parameter if (input == null) { throw new ArgumentNullException("input"); } if ((networkSession != null) && (networkSession.LocalGamers.Count > 0)) { // update the ready state if (input.MarkReady) { networkSession.LocalGamers[0].IsReady = !networkSession.LocalGamers[0].IsReady; } // update the player data PlayerData playerData = networkSession.LocalGamers[0].Tag as PlayerData; if (playerData != null) { bool playerDataChanged = false; if (input.ShipColorChangeUp) { playerData.ShipColor = Ship.GetNextUniqueColorIndex( playerData.ShipColor, networkSession); playerDataChanged = true; } else if (input.ShipColorChangeDown) { playerData.ShipColor = Ship.GetPreviousUniqueColorIndex( playerData.ShipColor, networkSession); playerDataChanged = true; } if (input.ShipModelChangeUp) { playerData.ShipVariation = (byte)((playerData.ShipVariation + 1) % 4); playerDataChanged = true; } else if (input.ShipModelChangeDown) { if (playerData.ShipVariation == 0) { playerData.ShipVariation = 3; } else { playerData.ShipVariation--; } playerDataChanged = true; } // if the data changed, send an update to the others if (playerDataChanged) { packetWriter.Write((int)World.PacketTypes.PlayerData); playerData.Serialize(packetWriter); networkSession.LocalGamers[0].SendData(packetWriter, SendDataOptions.ReliableInOrder); } } } base.HandleInput(input); }
/// <summary> /// Allows the screen to handle user input. Unlike Update, this method /// is only called when the screen is active, and not when some other /// screen has taken the focus. /// </summary> public virtual void HandleInput(InputState input) { }