/// <summary> /// Handles user input as a part of screen logic update. /// </summary> /// <param name="gameTime">Game time information.</param> /// <param name="input">Input information.</param> public override void HandleInput(GameTime gameTime, InputState input) { if (input == null) { throw new ArgumentNullException("input"); } if (input.IsPauseGame(null)) { Exit(); } // Return to the main menu when a tap gesture is recognized if (input.Gestures.Count > 0) { GestureSample sample = input.Gestures[0]; if (sample.GestureType == GestureType.Tap) { Exit(); input.Gestures.Clear(); } } // Handle gamepad input PlayerIndex player; // Handle keyboard input if (input.IsNewKeyPress(Keys.Enter, ControllingPlayer, out player) || input.IsNewKeyPress(Keys.Space, ControllingPlayer, out player)) { Exit(); } }
/// <summary> /// Handles user input as a part of screen logic update. /// </summary> /// <param name="gameTime">Game time information.</param> /// <param name="input">Input information.</param> public override void HandleInput(GameTime gameTime, InputState input) { if (input == null) { throw new ArgumentNullException("input"); } if (input.IsPauseGame(null)) { Exit(); } // Return to the main menu when a tep gesture is recognized if (input.Gestures.Count > 0) { GestureSample sample = input.Gestures[0]; if (sample.GestureType == GestureType.Tap) { Exit(); input.Gestures.Clear(); } } }
/// <summary> /// Handle the player's input. /// </summary> /// <param name="input"></param> public override void HandleInput(GameTime gameTime, InputState input) { if (IsActive) { if (input == null) { throw new ArgumentNullException("input"); } if (input.IsPauseGame(null)) { PauseCurrentGame(); } } if (input.TouchState.Count > 0) { foreach (TouchLocation touch in input.TouchState) { lastTouchPosition = touch.Position; } } isSmokebuttonClicked = false; PlayerIndex player; VirtualThumbsticks.Update(input); if (input.Gestures.Count > 0) { GestureSample topGesture = input.Gestures[0]; if (topGesture.GestureType == GestureType.Tap && deviceUpperRightCorner.Contains(new Point((int)topGesture.Position.X, (int)topGesture.Position.Y))) { showDebugInfo = !showDebugInfo; } } if (isLevelEnd) { if (input.Gestures.Count > 0) { if (input.Gestures[0].GestureType == GestureType.Tap) { userInputToExit = true; } } if (input.IsNewKeyPress(Keys.Enter, ControllingPlayer, out player) || input.IsNewKeyPress(Keys.Space, ControllingPlayer, out player)) { userInputToExit = true; } } if (!IsStarted) { return; } // If there was any touch if (VirtualThumbsticks.RightThumbstickCenter.HasValue) { // Button Bounds Rectangle buttonRectangle = new Rectangle((int)smokeButtonPosition.X, (int)smokeButtonPosition.Y, smokeButton.Width / 2, smokeButton.Height); // Touch Bounds Rectangle touchRectangle = new Rectangle((int)VirtualThumbsticks.RightThumbstickCenter.Value.X, (int)VirtualThumbsticks.RightThumbstickCenter.Value.Y, 1, 1); // If the touch is in the button if (buttonRectangle.Contains(touchRectangle) && !beeKeeper.IsCollectingHoney && !beeKeeper.IsStung) { isSmokebuttonClicked = true; } } // Handle keyboard if (input.IsNewKeyPress(Keys.Y, ControllingPlayer, out player)) { showDebugInfo = !showDebugInfo; } if (input.IsKeyDown(Keys.Space, ControllingPlayer, out player) && !beeKeeper.IsCollectingHoney && !beeKeeper.IsStung) { isSmokebuttonClicked = true; } movementVector = SetMotion(input); beeKeeper.SetDirection(movementVector); }
/// <summary> /// Handle the player's input. /// </summary> /// <param name="input"></param> public override void HandleInput(GameTime gameTime, InputState input) { if (IsActive) { if (input == null) { throw new ArgumentNullException("input"); } if (input.IsPauseGame(null)) { PauseCurrentGame(); } } if (input.TouchState.Count > 0) { foreach (TouchLocation touch in input.TouchState) { lastTouchPosition = touch.Position; } } isSmokebuttonClicked = false; PlayerIndex player; VirtualThumbsticks.Update(input); if (input.Gestures.Count > 0) { GestureSample topGesture = input.Gestures[0]; if (topGesture.GestureType == GestureType.Tap && deviceUpperRightCorner.Contains(new Point((int)topGesture.Position.X, (int)topGesture.Position.Y))) { showDebugInfo = !showDebugInfo; } } if (isLevelEnd) { if (input.Gestures.Count > 0) { if (input.Gestures[0].GestureType == GestureType.Tap) { userInputToExit = true; } } else if (input.IsNewButtonPress(Buttons.A, ControllingPlayer, out player)) { userInputToExit = true; } if (input.IsNewKeyPress(Keys.Enter, ControllingPlayer, out player) || input.IsNewKeyPress(Keys.Space, ControllingPlayer, out player)) { userInputToExit = true; } } if (!IsStarted) { return; } // If there was any touch if (VirtualThumbsticks.RightThumbstickCenter.HasValue) { // Button Bounds Rectangle buttonRectangle = new Rectangle((int)smokeButtonPosition.X, (int)smokeButtonPosition.Y, smokeButton.Width / 2, smokeButton.Height); // Touch Bounds Rectangle touchRectangle = new Rectangle((int)VirtualThumbsticks.RightThumbstickCenter.Value.X, (int)VirtualThumbsticks.RightThumbstickCenter.Value.Y, 1, 1); // If the touch is in the button if (buttonRectangle.Contains(touchRectangle) && !beeKeeper.IsCollectingHoney && !beeKeeper.IsStung) { isSmokebuttonClicked = true; } } if (input.IsNewButtonPress(Buttons.Y, ControllingPlayer, out player)) { showDebugInfo = !showDebugInfo; } else if (input.IsButtonDown(Buttons.A, ControllingPlayer, out player) && !beeKeeper.IsCollectingHoney && !beeKeeper.IsStung) { isSmokebuttonClicked = true; } // Handle keyboard if (input.IsNewKeyPress(Keys.Y, ControllingPlayer, out player)) { showDebugInfo = !showDebugInfo; } if (input.IsKeyDown(Keys.Space, ControllingPlayer, out player) && !beeKeeper.IsCollectingHoney && !beeKeeper.IsStung) { isSmokebuttonClicked = true; } movementVector = SetMotion(input); beeKeeper.SetDirection(movementVector); }
/// <summary> /// Handles user input as a part of screen logic update. /// </summary> /// <param name="gameTime">Game time information.</param> /// <param name="input">Input information.</param> public override void HandleInput(GameTime gameTime, InputState input) { if (input == null) { throw new ArgumentNullException("input"); } if (input.IsPauseGame(null)) { Exit(); } // Return to the main menu when a tap gesture is recognized if (input.Gestures.Count > 0) { GestureSample sample = input.Gestures[0]; if (sample.GestureType == GestureType.Tap) { Exit(); input.Gestures.Clear(); } } // Handle gamepad input PlayerIndex player; // Handle keyboard input if (input.IsNewKeyPress(Keys.Enter, ControllingPlayer, out player) || input.IsNewKeyPress(Keys.Space, ControllingPlayer, out player)) { Exit(); } }
/// <summary> /// Handle the player's input. /// </summary> /// <param name="input"></param> public override void HandleInput(GameTime gameTime, InputState input) { if (IsActive) { if (input == null) { throw new ArgumentNullException("input"); } VirtualThumbsticks.Update(input); if (input.IsPauseGame(null)) { PauseCurrentGame(); } } if (input.TouchState.Count > 0) { foreach (TouchLocation touch in input.TouchState) { lastTouchPosition = touch.Position; } } isSmokebuttonClicked = false; PlayerIndex player; // If there was any touch if (VirtualThumbsticks.RightThumbstickCenter.HasValue) { // Button Bounds Rectangle buttonRectangle = new Rectangle((int)smokeButtonPosition.X, (int)smokeButtonPosition.Y, smokeButton.Width / 2, smokeButton.Height); // Touch Bounds Rectangle touchRectangle = new Rectangle((int)VirtualThumbsticks.RightThumbstickCenter.Value.X, (int)VirtualThumbsticks.RightThumbstickCenter.Value.Y, 1, 1); // If the touch is in the button if (buttonRectangle.Contains(touchRectangle) && !beeKeeper.IsCollectingHoney && !beeKeeper.IsStung) { isSmokebuttonClicked = true; } } if (input.IsKeyDown(Keys.Space, ControllingPlayer, out player) && !beeKeeper.IsCollectingHoney && !beeKeeper.IsStung) { isSmokebuttonClicked = true; } if (input.Gestures.Count > 0) { if (isLevelEnd) { if (input.Gestures[0].GestureType == GestureType.Tap) { userTapToExit = true; } } } }