public override void HandleInput(InputState input) { //we will need a loop to handle input for each player PlayerIndex pi = new PlayerIndex(); if (input.IsMenuCancel(null, out pi)) { //Greg //ScreenManager.AddScreen(new BackgroundScreen(), null); if (Players[0].mCurrentState == Player.PlayerState.Playing) Players[0].mCurrentState = Player.PlayerState.Paused; if (Players[1].mCurrentState == Player.PlayerState.Playing) Players[1].mCurrentState = Player.PlayerState.Paused; if (Players[2].mCurrentState == Player.PlayerState.Playing) Players[2].mCurrentState = Player.PlayerState.Paused; if (Players[3].mCurrentState == Player.PlayerState.Playing) Players[3].mCurrentState = Player.PlayerState.Paused; ScreenManager.AddScreen(new PauseMenuScreen(ScreenManager), pi); } //Players[1].HandleInput(input.CurrentKeyboardStates[1]); //Players[0].HandleInput(input.CurrentKeyboardStates[0]); //Players[2].HandleInput(input.CurrentKeyboardStates[2]); //Players[3].HandleInput(input.CurrentKeyboardStates[3]); Players[1].HandleInput(input.CurrentGamePadStates[1], input.LastGamePadStates[1]); Players[0].HandleInput(input.CurrentGamePadStates[0],input.LastGamePadStates[0]); Players[2].HandleInput(input.CurrentGamePadStates[2], input.LastGamePadStates[2]); Players[3].HandleInput(input.CurrentGamePadStates[3], input.LastGamePadStates[3]); }
public override void HandleInput(InputState input) { //we will need a loop to handle input for each player PlayerIndex pi = new PlayerIndex(); if (input.IsMenuCancel(null, out pi)) { if (Players[0].mCurrentState == Player.PlayerState.Playing) Players[0].mCurrentState = Player.PlayerState.Paused; ScreenManager.AddScreen(new PauseMenuScreen(ScreenManager), pi); } Players[0].HandleInput(input.CurrentKeyboardStates[0], input.LastKeyboardStates[0]); }
/// <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) { // Move to the previous menu entry? if (input.IsMenuUp(ControllingPlayer)) { selectedEntry--; if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1; // mSound.Play(Sound.SoundFX.Move); } // Move to the next menu entry? if (input.IsMenuDown(ControllingPlayer)) { selectedEntry++; if (selectedEntry >= menuEntries.Count) selectedEntry = 0; // mSound.Play(Sound.SoundFX.Move); } // 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)) { mSound.Play(Sound.SoundFX.Selection); 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) { PlayerIndex playerIndex; if (input.CurrentKeyboardStates[0].IsKeyDown(Microsoft.Xna.Framework.Input.Keys.D) && input.CurrentKeyboardStates[0].IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F3)) { if (!dev_modes) { dev_modes = true; InitilizeDeveloperModes(); } } selectedtext = selectednode.Value.text; switch (selectedtext) { case "Single Player": preview = Game.Content.Load<Texture2D>("Images/prevew3"); break; case "Basic": preview = Game.Content.Load<Texture2D>("Images/preview2"); break; case "Combo": preview = Game.Content.Load<Texture2D>("Images/prevew3"); break; case "Battle": preview = Game.Content.Load<Texture2D>("Images/preview2"); break; default: preview = Game.Content.Load<Texture2D>("Images/prevew3"); break; } if (waitingforchallenger) { PlayerIndex challenger=ControllingPlayer.Value; if (input.CurrentGamePadStates[0].IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.Start) || input.CurrentGamePadStates[0].IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.A)) {challenger=PlayerIndex.One; } if(input.CurrentGamePadStates[1].IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.Start)|| input.CurrentGamePadStates[1].IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.A)) {challenger=PlayerIndex.Two; } if(input.CurrentGamePadStates[2].IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.Start)|| input.CurrentGamePadStates[2].IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.A)) {challenger=PlayerIndex.Three; } if(input.CurrentGamePadStates[3].IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.Start)|| input.CurrentGamePadStates[3].IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.A)) {challenger=PlayerIndex.Four; } if(ControllingPlayer!=challenger) { GameScreen[] screenstoload=new GameScreen[2]; screenstoload[0] = new BackgroundScreen(ScreenManager); screenstoload[1] = new BattleMode(ScreenManager, ControllingPlayer.Value,challenger); LoadingScreen.Load(ScreenManager, true,ControllingPlayer, screenstoload); } if (input.IsMenuCancel(ControllingPlayer, out playerIndex)) { //OnCancel(playerIndex); waitingforchallenger = false; } } else { // Move to the previous menu entry? if (input.IsMenuUp(ControllingPlayer)) { mSound.Play(Sound.SoundFX.Move); if (selectednode.Previous == null) {//you hit the beginning of the list loop back around selectednode = menuEntries.Last; } else selectednode = selectednode.Previous; // menutransition = -1; } // Move to the next menu entry? if (input.IsMenuDown(ControllingPlayer)) { mSound.Play(Sound.SoundFX.Move); if (selectednode.Next == null) {//you hit the beginning of the list loop back around selectednode = menuEntries.First; } else selectednode = selectednode.Next; //. menutransition = 1; } // 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. if (input.IsMenuSelect(ControllingPlayer, out playerIndex)) { OnSelectEntry(selectedEntry, playerIndex); } else if (input.IsMenuCancel(ControllingPlayer, out playerIndex)) { OnCancel(playerIndex); } } }
/// <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) { //we will need a loop to handle input for each player PlayerIndex pi = new PlayerIndex(); if (input.IsMenuCancel(null, out pi)) { //Greg if (Players[0].mCurrentState == Player.PlayerState.Playing) Players[0].mCurrentState = Player.PlayerState.Paused; ScreenManager.AddScreen(new PauseMenuScreen(ScreenManager), pi); } Players[0].HandleInput(input.CurrentGamePadStates[0], input.LastGamePadStates[0]); if (input == null) throw new ArgumentNullException("input"); // Look up inputs for the active player profile. int playerIndex = (int)ControllingPlayer.Value; KeyboardState keyboardState = input.CurrentKeyboardStates[playerIndex]; GamePadState gamePadState = input.CurrentGamePadStates[playerIndex]; // The game pauses either if the user presses the pause button, or if // they unplug the active gamepad. This requires us to keep track of // whether a gamepad was ever plugged in, because we don't want to pause // on PC if they are playing with a keyboard and have no gamepad at all! bool gamePadDisconnected = !gamePadState.IsConnected && input.GamePadWasConnected[playerIndex]; }
/// <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) { //we will need a loop to handle input for each player PlayerIndex pi = new PlayerIndex(); switch (CurrentStatus) { case BattleStatus.BattleOver: { if (input.IsMenuCancel(null, out pi)) { //Greg if (Players[0].mCurrentState == Player.PlayerState.Playing) Players[0].mCurrentState = Player.PlayerState.Paused; ScreenManager.AddScreen(new PauseMenuScreen(ScreenManager), pi); } if (input.CurrentGamePadStates[(int)player1_index].IsButtonDown(Buttons.Start) && !input.LastGamePadStates[(int)player1_index].IsButtonDown(Buttons.Start)) { ScreenManager.AddScreen(new PauseMenuScreen(ScreenManager), PlayerIndex.One); } if (input.CurrentGamePadStates[(int)player2_index].IsButtonDown(Buttons.Start) && !input.LastGamePadStates[(int)player2_index].IsButtonDown(Buttons.Start)) { ScreenManager.AddScreen(new PauseMenuScreen(ScreenManager), PlayerIndex.Two); } } break; case BattleStatus.Playing: //if (input.IsMenuCancel(null, out pi)) //{ // //Greg // if (Players[0].mCurrentState == Player.PlayerState.Playing) Players[0].mCurrentState = Player.PlayerState.Paused; // ScreenManager.AddScreen(new PauseMenuScreen(ScreenManager), pi); //} if (!input.CurrentGamePadStates[(int)player1_index].IsConnected || !input.CurrentGamePadStates[(int)player2_index].IsConnected) { Players[0].mCurrentState = Player.PlayerState.Paused; Players[1].mCurrentState = Player.PlayerState.Paused; ScreenManager.AddScreen(new PauseMenuScreen(ScreenManager), PlayerIndex.One); CurrentStatus = BattleStatus.Paused; } if (input.CurrentGamePadStates[(int)player1_index].IsButtonDown(Buttons.Start) && !input.LastGamePadStates[(int)player1_index].IsButtonDown(Buttons.Start) || input.CurrentGamePadStates[(int)player1_index].IsButtonDown(Buttons.Back)) { Players[0].mCurrentState = Player.PlayerState.Paused; Players[1].mCurrentState = Player.PlayerState.Paused; ScreenManager.AddScreen(new PauseMenuScreen(ScreenManager), PlayerIndex.One); CurrentStatus = BattleStatus.Paused; } if (input.CurrentGamePadStates[(int)player2_index].IsButtonDown(Buttons.Start) && !input.LastGamePadStates[(int)player2_index].IsButtonDown(Buttons.Start) || input.CurrentGamePadStates[(int)player2_index].IsButtonDown(Buttons.Back)) { // CurrentStatus = BattleStatus.Paused; Players[0].mCurrentState = Player.PlayerState.Paused; Players[1].mCurrentState = Player.PlayerState.Paused; ScreenManager.AddScreen(new PauseMenuScreen(ScreenManager), PlayerIndex.Two); CurrentStatus = BattleStatus.Paused; } //for (int i = 0; i < 2; i++) switch (Players[0].CurrentWeapon) { case Player.WeaponType.Snipe: if (input.CurrentGamePadStates[(int)player1_index].IsButtonDown(Buttons.LeftTrigger))// && reticule.showing!=1 )// && mPlayfield.RedBlocks >= quota) { reticules[0].visible = true; } else { reticules[0].visible = false; reticules[0].bullets = 1; } if (reticules[0].visible) { reticules[0].GamepadListener(input.CurrentGamePadStates[(int)player1_index], input.LastGamePadStates[(int)player1_index], Players[1]); } break; } switch (Players[1].CurrentWeapon) { case Player.WeaponType.Snipe: if (input.CurrentGamePadStates[(int)player2_index].IsButtonDown(Buttons.LeftTrigger))// && reticule.showing!=1 )// && mPlayfield.RedBlocks >= quota) { reticules[1].visible = true; } else { reticules[1].visible = false; reticules[1].bullets = 1; } if (reticules[1].visible) { reticules[1].GamepadListener(input.CurrentGamePadStates[(int)player2_index], input.LastGamePadStates[(int)player2_index], Players[0]); } break; } Players[0].HandleInput(input.CurrentGamePadStates[(int)player1_index], input.LastGamePadStates[(int)player1_index]); Players[1].HandleInput(input.CurrentGamePadStates[(int)player2_index], input.LastGamePadStates[(int)player2_index]); break; case BattleStatus.RoundOver: if (input.CurrentGamePadStates[(int)player2_index].IsButtonDown(Buttons.Start)) { Players[1].mCurrentState = Player.PlayerState.Waiting; } if (input.CurrentGamePadStates[(int)player1_index].IsButtonDown(Buttons.Start)) { Players[0].mCurrentState = Player.PlayerState.Waiting; } break; } // if (input == null) // throw new ArgumentNullException("input"); // // Look up inputs for the active player profile. int playerIndex = (int)ControllingPlayer.Value; KeyboardState keyboardState = input.CurrentKeyboardStates[playerIndex]; GamePadState gamePadState = input.CurrentGamePadStates[playerIndex]; // The game pauses either if the user presses the pause button, or if // they unplug the active gamepad. This requires us to keep track of // whether a gamepad was ever plugged in, because we don't want to pause // on PC if they are playing with a keyboard and have no gamepad at all! bool gamePadDisconnected = !gamePadState.IsConnected && input.GamePadWasConnected[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(ControllingPlayer)) { mSound.Play(Sound.SoundFX.Move); if (Guide.IsTrialMode) { if (selectedEntry - 1 < 0) {//you hit the beginning of the list loop back around selectedEntry = 4; } else selectedEntry = selectedEntry - 1; } else { if (selectedEntry - 1 < 0) {//you hit the beginning of the list loop back around selectedEntry = 3; } else selectedEntry = selectedEntry - 1; } } // Move to the next menu entry? if (input.IsMenuDown(ControllingPlayer)) { mSound.Play(Sound.SoundFX.Move); if (Guide.IsTrialMode) { if (selectedEntry + 1 > 4) {//you hit the beginning of the list loop back around selectedEntry = 0; } else selectedEntry = selectedEntry + 1; } else { if (selectedEntry + 1 > 3) {//you hit the beginning of the list loop back around selectedEntry = 0; } else selectedEntry = selectedEntry + 1; } //if (Guide.IsTrialMode == false && selectedEntry==4) //{ // selectedEntry++; //} //. menutransition = 1; } // 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; if (input.IsMenuSelect(ControllingPlayer, out playerIndex)) { OnSelectEntry(selectedEntry, playerIndex); } else if (input.IsMenuCancel(ControllingPlayer, out playerIndex)) { OnCancel(playerIndex); } }