/// <summary> /// Polls input states and handles player input. /// </summary> public override void HandleInput(InputState input) { int playerIndex = (int)ControllingPlayer.Value; keyboardState = input.CurrentKeyboardStates[playerIndex]; gamePadState = input.CurrentGamePadStates[playerIndex]; touchState = TouchPanel.GetState(); accelerometerState = Accelerometer.GetState(); if (level.Player.Alive && level.EndReached) LoadNextLevel(); if (!level.Player.Alive) if (level.Player.Lives > 0) level.NewLife(); else { ScreenManager.AddScreen(new GameOverScreen(), ControllingPlayer); ReloadLevel(); } bool gamePadDisconnected = !gamePadState.IsConnected && input.GamePadWasConnected[playerIndex]; if (input.GamePadWasConnected[playerIndex]) controlCheck.wasConnected = true; if (input.IsPauseGame(ControllingPlayer) || gamePadDisconnected) { ScreenManager.AddScreen(new PauseMenuScreen(), ControllingPlayer); } if (!gamePadState.IsConnected) { controlCheck.wasConnected = false; input.GamePadWasConnected[playerIndex] = false; } }
/// <summary> /// Polls input states and handles player input. /// </summary> public override void HandleInput(InputState input) { int playerIndex = (int)ControllingPlayer.Value; keyboardState = input.CurrentKeyboardStates[playerIndex]; gamePadState = input.CurrentGamePadStates[playerIndex]; //if (keyboardState.IsKeyDown(Keys.Escape) || // gamePadState.Buttons.Back == ButtonState.Pressed) //this.Exit(); if (level.Player.Alive && level.EndReached) LoadNextLevel(); if (!level.Player.Alive) if (level.Player.Lives > 0) level.NewLife(); else { ScreenManager.AddScreen(new GameOverScreen(), ControllingPlayer); ReloadLevel(); } bool gamePadDisconnected = !gamePadState.IsConnected && input.GamePadWasConnected[playerIndex]; if (input.IsPauseGame(ControllingPlayer) || gamePadDisconnected) { ScreenManager.AddScreen(new PauseMenuScreen(), ControllingPlayer); } }