public override void HandleInput(InputState input) { if (input.PauseGame) { ExitScreen(); } }
public override void HandleInput(InputState input) { TouchCollection touchState; touchState = TouchPanel.GetState(); if (input.PauseGame) { options.Clear(); options.Add(Convert.ToBoolean(music.value)); options.Add(Convert.ToBoolean(vibration.value)); options.Add(Convert.ToBoolean(menuMusic.value)); iso.SaveOptions("options.xml", options); ExitScreen(); } //interpert touch screen presses foreach (TouchLocation location in touchState) { switch (location.State) { case TouchLocationState.Pressed: foreach (Button b in MenuButtons) { b.HandleTap(location.Position); } break; case TouchLocationState.Moved: break; case TouchLocationState.Released: break; } } }
/// <summary> /// Evaluates the action against a given InputState. /// </summary> /// <param name="state">The InputState to test for the action.</param> /// <param name="controllingPlayer">The player to test, or null to allow any player.</param> /// <param name="player">If controllingPlayer is null, this is the player that performed the action.</param> /// <returns>True if the action occurred, false otherwise.</returns> public bool Evaluate(InputState state) { // Figure out which delegate methods to map from the state which takes care of our "newPressOnly" logic ButtonPress buttonTest; KeyPress keyTest; if (newPressOnly) { buttonTest = state.IsNewButtonPress; //keyTest = state.IsNewKeyPress; } else { //buttonTest = state.IsButtonPressed; //keyTest = state.IsKeyPressed; } // Now we simply need to invoke the appropriate methods for each button and key in our collections foreach (Buttons button in buttons) { //if (buttonTest(button)) return true; } foreach (Keys key in keys) { //if (keyTest(key)) return true; } // If we got here, the action is not matched return false; }
public override void HandleInput(InputState input) { if (input.PauseGame) { this.ExitScreen(); ScreenManager.AddScreen(new PhoneMainMenu()); } base.HandleInput(input); }
/// <summary> /// Input helper method provided by GameScreen. Packages up the various input /// values for ease of use. Here it checks for pausing and handles controlling /// the player's tank. /// </summary> /// <param name="input">The state of the gamepads</param> public override void HandleInput(InputState input) { Vector3 accelerationInfo = accelState == null ? Vector3.Zero : new Vector3((float)accelState.X, (float)accelState.Y, (float)accelState.Z); if (gameplayHelper.HandleInput(input.PauseGame, accelerationInfo, TouchPanel.GetState())) { FinishCurrentGame(); } }
public override void HandleInput(InputState input) { if (input.PauseGame) { ExitScreen(); if (newGame) ScreenManager.AddScreen(new ReadyScreen()); //else ExitScreen(); } 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) { }
/// <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? if (input.MenuSelect) { OnSelectEntry(selectedEntry); } else if (input.MenuCancel) { OnCancel(); } }
public override void HandleInput(InputState input) { accelerationInfo = accelState == null ? Vector2.Zero : new Vector2((float)accelState.SensorReading.Acceleration.X * 2.5f, -(float)accelState.SensorReading.Acceleration.Y * 3.5f); Vector3 _accelerationInfo = accelState == null ? Vector3.Zero : new Vector3((float)accelState.SensorReading.Acceleration.X, (float)accelState.SensorReading.Acceleration.Y, (float)accelState.SensorReading.Acceleration.Z); if (input.PauseGame) { GameplayHelper.isPauseGame = true; GameplayHelper.updateGameTime = true; PauseCurrentGame(); GameplayHelper.PauseMusic(); } if (input.DeactivateGame) { } }
/// <summary> /// Input helper method provided by GameScreen. Packages up the various input /// values for ease of use. Here it checks for pausing and handles controlling /// the player's tank. /// </summary> /// <param name="input">The state of the gamepads</param> public override void HandleInput(InputState input) { if (input == null) throw new ArgumentNullException("input"); if (input.PauseGame) { if (gameOver == true) { foreach (GameScreen screen in ScreenManager.GetScreens()) screen.ExitScreen(); ScreenManager.AddScreen(new BackgroundScreen()); ScreenManager.AddScreen(new MainMenuScreen()); } else { ScreenManager.AddScreen(new PauseMenuScreen()); } } else { // This section handles tank movement. We only allow one "movement" action // to occur at once so that touchpad devices don't get double hits. if (input.CurrentGamePadStates[0].DPad.Left == ButtonState.Pressed) { player.Velocity.X = -1.0f; } else if (input.CurrentGamePadStates[0].DPad.Right == ButtonState.Pressed) { player.Velocity.X = 1.0f; } else { player.Velocity.X = MathHelper.Min(input.CurrentGamePadStates[0].ThumbSticks.Left.X * 2.0f, 1.0f); } // B button, or pressing on the upper half of the pad fires the weapon. if (input.CurrentGamePadStates[0].IsButtonDown(Buttons.B) || input.CurrentGamePadStates[0].IsButtonDown(Buttons.A) || input.CurrentGamePadStates[0].ThumbSticks.Left.Y > 0.25f) { if (player.FireTimer <= 0.0f && player.IsAlive && !gameOver) { Bullet bullet = CreatePlayerBullet(); bullet.Position = new Vector2((int)(player.Position.X + player.Width / 2) - bulletTexture.Width / 2, player.Position.Y - 4); bullet.Velocity = new Vector2(0, -256.0f); player.FireTimer = 1.0f; particles.CreatePlayerFireSmoke(player); playerFired.Play(); } } } }
/// <summary> /// Responds to user input, changing the selected entry and accepting /// or cancelling the menu. /// </summary> /// public override void HandleInput(InputState input) { TouchCollection touchState = TouchPanel.GetState(); bool touchDetected = false; Vector2 touchPosition = new Vector2(); //interpert touch screen presses foreach (TouchLocation location in touchState) { switch (location.State) { case TouchLocationState.Pressed: touchDetected = true; touchPosition = location.Position; break; case TouchLocationState.Moved: break; case TouchLocationState.Released: break; } } if (touchDetected) { foreach (MenuEntry menuEntry in menuEntries) { Rectangle touchRect = new Rectangle((int)touchPosition.X - 5, (int)touchPosition.Y - 5, 10, 10); if (menuEntry.EntryPosition.Intersects(touchRect)) menuEntry.OnSelectEntry(); } } // Move to the previous menu entry? if (input.MenuUp) { selectedEntry--; if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1; } // Move to the next menu entry? if (input.MenuDown) { selectedEntry++; if (selectedEntry >= menuEntries.Count) selectedEntry = 0; } // Accept or cancel the menu? if (input.MenuSelect) { OnSelectEntry(selectedEntry); } else if (input.MenuCancel) { OnCancel(); } }
/// <summary> /// Input helper method provided by GameScreen. Packages up the various input /// values for ease of use. Here it checks for pausing and handles controlling /// the player's tank. /// </summary> /// <param name="input">The state of the gamepads</param> public override void HandleInput(InputState input) { if (input == null) throw new ArgumentNullException("input"); if (input.PauseGame) { if (gameOver == true) finishCurrentGame(); } else { touchState = TouchPanel.GetState(); bool buttonTouched = false; //interpret touch screen presses foreach (TouchLocation location in touchState) { switch (location.State) { case TouchLocationState.Pressed: buttonTouched = true; break; case TouchLocationState.Moved: break; case TouchLocationState.Released: break; } } float movement = 0.0f; //if (accelState != null) //{ // if (Math.Abs(accelState.X) > 0.10f) // { // if (accelState.X > 0.0f) // movement = 1.0f; // else movement = -1.0f; // } //} if (accelState != null) { if (Math.Abs(accelState.X) > 0.10f) { // set our movement speed movement = MathHelper.Clamp((float)-accelState.X * AccelerometerScale, -1f, 1f); } } //TODO: Update player Velocity over X axis #1 player.Velocity.X = movement; //This section handles tank movement. We only allow one "movement" action //to occur at once so that touchpad devices don't get double hits. KeyboardState keyState = Keyboard.GetState(); if (input.CurrentGamePadStates[0].DPad.Left == ButtonState.Pressed || keyState.IsKeyDown(Keys.Left)) { //TODO: Update player velocity over X axis #2 player.Velocity.X = -1.0f; } else if (input.CurrentGamePadStates[0].DPad.Right == ButtonState.Pressed || keyState.IsKeyDown(Keys.Right)) { //TODO: Update player velocity over X axis #3 player.Velocity.X = 1.0f; } else { //TODO: Update player velocity over X axis #4 player.Velocity.X = MathHelper.Min(input.CurrentGamePadStates[0].ThumbSticks.Left.X * 2.0f, 1.0f); } // B button, or pressing on the upper half of the pad or space on keyboard or touching the touch panel fires the weapon. if (input.CurrentGamePadStates[0].IsButtonDown(Buttons.B) || input.CurrentGamePadStates[0].IsButtonDown(Buttons.A) || input.CurrentGamePadStates[0].ThumbSticks.Left.Y > 0.25f || keyState.IsKeyDown(Keys.Space) || buttonTouched) { if (player.FireTimer <= 0.0f && player.IsAlive && !gameOver) { Bullet bullet = CreatePlayerBullet(); bullet.Position = new Vector2((int)(player.Position.X + player.Width / 2) - bulletTexture.Width / 2, player.Position.Y - 4); bullet.Velocity = new Vector2(0, -256.0f); player.FireTimer = 1.0f; particles.CreatePlayerFireSmoke(player); playerFired.Play(); } else if (gameOver) finishCurrentGame(); } } }
/// <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; } // Move to the next menu entry? if (input.MenuDown) { selectedEntry++; if (selectedEntry >= menuEntries.Count) selectedEntry = 0; } // Accept or cancel the menu? if (input.MenuSelect) { OnSelectEntry(selectedEntry); } else if (input.MenuCancel) { OnCancel(); } }
public override void HandleInput(InputState input) { if (input.PauseGame) { ScreenManager.Game.Exit(); } base.HandleInput(input); }
public override void HandleInput(InputState input) { TouchCollection touchState; touchState = TouchPanel.GetState(); foreach (TouchLocation location in touchState) { switch (location.State) { case TouchLocationState.Pressed: if (location.Position.X >= 10 && location.Position.Y >= 600 && location.Position.X <= 200 && location.Position.Y <= 800) { if (!NetworkInterface.GetIsNetworkAvailable()) { Guide.BeginShowMessageBox("Error", "Network unavailable", new string[] { "OK" }, 0, MessageBoxIcon.None, OnEndDialog, null); break; } else { ExitScreen(); ScreenManager.AddScreen(new WorldScoresScreen()); break; } } if (location.Position.X >= 250 && location.Position.Y >= 600 && location.Position.X <= 480 && location.Position.Y <= 800) { Debug.WriteLine("zapisuje"); if (!NetworkInterface.GetIsNetworkAvailable()) { Guide.BeginShowMessageBox("Error", "Network unavailable", new string[] { "OK" }, 0, MessageBoxIcon.None, OnEndDialog, null); break; } else { if (repeat) { //repeat = false; SaveHighSCoresOnArka(); } break; } } break; } } if (input.PauseGame) { ExitScreen(); //ScreenManager.AddScreen(new PhoneMainMenu()); } }
/// <summary> /// Input helper method provided by GameScreen. Packages up the various input /// values for ease of use. Here it checks for pausing and handles controlling /// the player's tank. /// </summary> /// <param name="input">The state of the gamepads</param> public override void HandleInput(InputState input) { if (input == null) throw new ArgumentNullException("input"); if (input.PauseGame) { if (gameOver == true) { MediaPlayer.Stop(); foreach (GameScreen screen in ScreenManager.GetScreens()) screen.ExitScreen(); ScreenManager.AddScreen(new BackgroundScreen()); ScreenManager.AddScreen(new MainMenuScreen()); } else { ScreenManager.AddScreen(new PauseMenuScreen()); } } else { bool touchShoot = false; #if TARGET_IPHONE_SIMULATOR // This section handles tank movement. We only allow one "movement" action // to occur at once so that touchpad devices don't get double hits. player.Velocity.X = MathHelper.Min(input.CurrentGamePadStates.ThumbSticks.Left.X * 2.0f, 1.0f); touchShoot = input.MenuSelect; #else // Add the accelerometer support player.Velocity.X = MathHelper.Min(Accelerometer.GetState().Acceleration.X * 2.0f, 1.0f); // tap the screen to shoot foreach (TouchLocation location in input.TouchStates) { switch (location.State) { case TouchLocationState.Pressed: touchShoot = true; break; case TouchLocationState.Moved: break; case TouchLocationState.Released: break; } } #endif if (touchShoot) { //Mouse.SetPosition(0,0); if (player.FireTimer <= 0.0f && player.IsAlive && !gameOver) { Bullet bullet = CreatePlayerBullet(); bullet.Position = new Vector2((int)(player.Position.X + player.Width / 2) - bulletTexture.Width / 2, player.Position.Y - 4); bullet.Velocity = new Vector2(0, -256.0f); player.FireTimer = 0.5f; particles.CreatePlayerFireSmoke(player); playerFired.Play(); } } } }
public override void HandleInput(InputState input) { TouchCollection touchState; touchState = TouchPanel.GetState(); foreach (TouchLocation location in touchState) { switch (location.State) { case TouchLocationState.Pressed: foreach (Button b in menuButtons) { b.HandleTap(location.Position); } break; case TouchLocationState.Moved: break; case TouchLocationState.Released: break; } } base.HandleInput(input); }