public void ScreenComponent_GestureRead(GestureSample gesture) { showGameLogEntryPanel = false; showAppliedConditionDetailsPanel = false; }
public async void DeleteTeamButton_Tapped(string id, GestureSample gesture) { await teamManager.DeleteTeam(); }
public void CharacterButton_Tapped(string id, GestureSample gesture) { var selectedCharacter = teamManager.Team.Characters.Single(character => character.Id == Guid.Parse(id)); CharacterTapped?.Invoke(selectedCharacter); }
public override IEnumerable <Order> Order(World world, CPos cell, Framework.Int2 worldPixel, GestureSample gs) { if (gs.GestureType != expectedGestureType) { world.CancelInputMode(); } return(OrderInner(world, cell, gs)); }
public abstract void TouchEvent(GestureSample gesture);
private void UpdatePlayer(GameTime gameTime) { player.Update(gameTime); // Windows Phone Controls while (TouchPanel.IsGestureAvailable) { GestureSample gesture = TouchPanel.ReadGesture(); if (gesture.GestureType == GestureType.FreeDrag) { player.Position += gesture.Delta; } } // Get Thumbstick Controls player.Position.X += currentGamePadState.ThumbSticks.Left.X * playerMoveSpeed; player.Position.Y -= currentGamePadState.ThumbSticks.Left.Y * playerMoveSpeed; // Use the Keyboard / Dpad if (currentKeyboardState.IsKeyDown(Keys.Left) || currentGamePadState.DPad.Left == ButtonState.Pressed) { player.Position.X -= playerMoveSpeed; } if (currentKeyboardState.IsKeyDown(Keys.Right) || currentGamePadState.DPad.Right == ButtonState.Pressed) { player.Position.X += playerMoveSpeed; } if (currentKeyboardState.IsKeyDown(Keys.Up) || currentGamePadState.DPad.Up == ButtonState.Pressed) { player.Position.Y -= playerMoveSpeed; } if (currentKeyboardState.IsKeyDown(Keys.Down) || currentGamePadState.DPad.Down == ButtonState.Pressed) { player.Position.Y += playerMoveSpeed; } // Make sure that the player does not go out of bounds player.Position.X = MathHelper.Clamp(player.Position.X, 0, GraphicsDevice.Viewport.Width - player.Width); player.Position.Y = MathHelper.Clamp(player.Position.Y, 0, GraphicsDevice.Viewport.Height - player.Height); // Fire only every interval we set as the fireTime if (gameTime.TotalGameTime - previousFireTime > fireTime) { // Reset our current time previousFireTime = gameTime.TotalGameTime; // Add the projectile, but add it to the front and center of the player AddProjectile(player.Position + new Vector2(player.Width / 2, 0)); // Play the laser sound laserSound.Play(); } // reset score if player health goes to zero if (player.Health <= 0) { player.Health = 100; score = 0; } }
public override void LoadContent() { base.LoadContent(); backgroundTexture = screenContent.Load <Texture2D>("BG_About"); Gestures = new GestureSample(); }
public void Initialize() { gesture = default(GestureSample); TouchPanel.EnabledGestures = GestureType.Tap | GestureType.Flick; }
public void Update(GameTime gameTime) { touchCollection = TouchPanel.GetState(); while (TouchPanel.IsGestureAvailable) { gesture = TouchPanel.ReadGesture(); switch (gesture.GestureType) { case GestureType.Flick: { if (gesture.Delta.X > 0 && gesture.Delta.Y > 0) //topright { if (gesture.Delta.X < gesture.Delta.Y) { OnFlickDown?.Invoke(gesture, null); } else { OnFlickRight?.Invoke(gesture, null); } } else if (gesture.Delta.X > 0 && gesture.Delta.Y < 0) //bottomright { if (gesture.Delta.X < -gesture.Delta.Y) { OnFlickUp?.Invoke(gesture, null); } else { OnFlickRight?.Invoke(gesture, null); } } else if (gesture.Delta.X < 0 && gesture.Delta.Y < 0) //bottomleft { if (-gesture.Delta.X < -gesture.Delta.Y) { OnFlickUp?.Invoke(gesture, null); } else { OnFlickLeft?.Invoke(gesture, null); } } else if (gesture.Delta.X < 0 && gesture.Delta.Y > 0) //topleft { if (-gesture.Delta.X < gesture.Delta.Y) { OnFlickDown?.Invoke(gesture, null); } else { OnFlickLeft?.Invoke(gesture, null); } } break; } case GestureType.Tap: { if (ScaledResolution != Vector2.Zero) { OnTap?.Invoke(new Vector2(gesture.Position.X / TouchPanel.DisplayWidth * ScaledResolution.X, gesture.Position.Y / TouchPanel.DisplayHeight * ScaledResolution.Y), null); } break; } } } if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { OnBackButtonClicked?.Invoke(this, null); } }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if ((GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) && oldstate.IsKeyUp(Keys.Escape)) { if (gameState == PAUSED || gameState == GAMEOVER) { gameState = TITLE; waveManager.StopSong(); } } //Touch input TouchPanelCapabilities tc = TouchPanel.GetCapabilities();//Determine if there is a touch panel connected or not. GestureSample gesture; if (tc.IsConnected && TouchPanel.IsGestureAvailable) { gesture = TouchPanel.ReadGesture(); } else { gesture = new GestureSample();//Reset it so it's not stuck on one touch method. } //Get the number of fingers on the screen. int numTaps = 0; TouchCollection touchCollection = TouchPanel.GetState(); foreach (TouchLocation tl in touchCollection) { if ((tl.State == TouchLocationState.Pressed) || (tl.State == TouchLocationState.Moved)) { numTaps++;//All of this to get the number of fingers on the screen and each one's position. } } //Pausing if ((Keyboard.GetState().IsKeyDown(Keys.P) || Keyboard.GetState().IsKeyDown(Keys.Enter)) && (oldstate.IsKeyUp(Keys.P) && oldstate.IsKeyUp(Keys.Enter))) { if (gameState == GAME) { gameState = PAUSED; } else if (gameState == PAUSED) { gameState = GAME; } } else if (numTaps >= 3 || gesture.GestureType == GestureType.Flick) { if (gameState == GAME && numTaps >= 3) { gameState = PAUSED; } else if (gameState == PAUSED && gesture.GestureType == GestureType.Flick) { gameState = GAME; } } //Delete Scores if (Keyboard.GetState().IsKeyUp(Keys.X) && oldstate.IsKeyDown(Keys.X)) { clear_scores(10); //save_data(); } //Title if (gameState == TITLE) { if (Keyboard.GetState().IsKeyDown(Keys.Enter) || gesture.GestureType == GestureType.Tap) { gameState = GAME; //Reset the game Initialize(); waveManager.PlayWave("bgm"); } } //Game else if (gameState == GAME) { //Do all of the player stuff. player.Update(stages, gameTime, level, gesture); //Update the camera. camera(player); //Add new stage if necessary add_new_stage(stages); //Play sound on beat beat_timer(gameTime); //Fireworks for (int i = 0; i < fireworks.Count(); i++) { fireworks.ElementAt(i).Update(); } //Fragments for (int i = 0; i < fragments.Count(); i++) { fragments.ElementAt(i).Update(); paint_sky(fragments.ElementAt(i)); bool hit_ground = fragments.ElementAt(i).hit_ground(fragments.ElementAt(i).position, stages); bool hit_player = player.rectangle.Intersects(fragments.ElementAt(i).rectangle); //Hit the player if (hit_player) { if (!player.spinning) { if (playerHurtTimer <= 0)//Don't let the player get hurt too much. { lives -= 1; hit.Play(); playerHurtTimer = playerHurtTimerMax; paint_splat(fragments.ElementAt(i).color); } fragments.Remove(fragments.ElementAt(i)); } //If the player is spinning else { fragments.ElementAt(i).speedY = -5; score += 30; } } //Remove frags that hit the ground or go offscreen. else if (hit_ground || fragments.ElementAt(i).position.Y > screenHeight) { fragments.Remove(fragments.ElementAt(i)); ground_instance.Play();//Use instance so only one can play at a time. } } //Check if the player is in the safehouse for (int i = 0; i < stages.Count(); i++) { //Reach the safehouse if (player.rectangle.Intersects(stages.ElementAt(i).rectangle) && stages.ElementAt(i).safehouse) { inSafehouse = true; } else if (player.rectangle.Intersects(stages.ElementAt(i).rectangle) && !stages.ElementAt(i).safehouse) { inSafehouse = false; } } //Paint the ground paint_the_ground(); //Manage Lives if (lives <= 0) { gameState = GAMEOVER; //Show them their score add_score(displayedScore); } //Subtract lives if the player falls off the stage. if (player.position.Y >= screenHeight) { lives -= 1; hit.Play(); player.position.Y = screenHeight / 3; player.speedY = 0;//They don't have momentum built up. player.spinning = false; player.burstMode = false; } //Pause the game if the screen is snapped. if (Windows8._windowState == WindowState.Snap1Quarter) { gameState = PAUSED; } //Update the camera //cameraView.Update(new Vector2(player.position.X - (screenWidth / 2), player.position.Y - (screenHeight / 2))); //Decrement timers if (playerHurtTimer > 0) { playerHurtTimer--; } } else if (gameState == GAMEOVER) { if ((Keyboard.GetState().IsKeyUp(Keys.Enter) && oldstate.IsKeyDown(Keys.Enter)) || gesture.GestureType == GestureType.Tap) { //Reset the game SaveGameData temp = highscores; Initialize(); highscores = temp; gameState = GAME; waveManager.RestartSong(); } } else if (gameState == PAUSED) { } //Update the old keyboard state each frame. oldstate = Keyboard.GetState(); base.Update(gameTime); }
/// <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 the gestures /// </summary> /// <param name="touch">Information concerning an individual gesture</param> public override void TouchEvent(GestureSample gesture) { // Do nothing }
protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } // Update texture from pixels array from pixelInfos array if (PixelInfo.hasNewColors) { lock (pixelInfosLock) { // Transfer new colors to pixels array for (int pixelIndex = PixelInfo.firstNewIndex; pixelIndex <= PixelInfo.lastNewIndex; pixelIndex++) { pixels[pixelIndex] = pixelInfos[pixelIndex].packedColor; } // Transfer new pixels to texture int firstRow = PixelInfo.firstNewIndex / texture.Width; int numRows = PixelInfo.lastNewIndex / texture.Width - firstRow + 1; Rectangle rect = new Rectangle(0, firstRow, texture.Width, numRows); texture.SetData <uint>(0, rect, pixels, firstRow * texture.Width, numRows * texture.Width); // Reset PixelInfo PixelInfo.hasNewColors = false; PixelInfo.firstNewIndex = Int32.MaxValue; PixelInfo.lastNewIndex = 0; } } // Update globalIteration display upperRightStatusText.Remove(0, upperRightStatusText.Length); upperRightStatusText.AppendFormat("{0}", globalIteration + 1); Vector2 textSize = segoe14.MeasureString(upperRightStatusText); upperRightStatusPosition = new Vector2(viewport.Width - textSize.X, 0); // Read touch gestures while (TouchPanel.IsGestureAvailable) { GestureSample gesture = TouchPanel.ReadGesture(); switch (gesture.GestureType) { case GestureType.FreeDrag: // Adjust drawMatrix for shifting drawMatrix.M41 += gesture.Delta.X; drawMatrix.M42 += gesture.Delta.Y; break; case GestureType.DragComplete: // Update texture from pixels from shifted pixelInfos lock (pixelInfosLock) { pixelInfos = TranslatePixelInfo(pixelInfos, drawMatrix); for (int pixelIndex = 0; pixelIndex < pixelInfos.Length; pixelIndex++) { pixels[pixelIndex] = pixelInfos[pixelIndex].packedColor; } PixelInfo.hasNewColors = false; PixelInfo.firstNewIndex = Int32.MaxValue; PixelInfo.lastNewIndex = 0; } texture.SetData <uint>(pixels); drawMatrix = Matrix.Identity; globalIteration = 0; break; case GestureType.Pinch: bool xDominates = Math.Abs(gesture.Delta.X) + Math.Abs(gesture.Delta2.X) > Math.Abs(gesture.Delta.Y) + Math.Abs(gesture.Delta2.Y); Vector2 oldPoint1 = gesture.Position - gesture.Delta; Vector2 newPoint1 = gesture.Position; Vector2 oldPoint2 = gesture.Position2 - gesture.Delta2; Vector2 newPoint2 = gesture.Position2; drawMatrix *= ComputeScaleMatrix(oldPoint1, oldPoint2, newPoint2, xDominates); drawMatrix *= ComputeScaleMatrix(newPoint2, oldPoint1, newPoint1, xDominates); break; case GestureType.PinchComplete: // Set texture from zoomed pixels pixels = ZoomPixels(pixels, drawMatrix); texture.SetData <uint>(pixels); // Set new PixelInfo parameters PixelInfo.xPixelCoordAtComplexOrigin *= drawMatrix.M11; PixelInfo.xPixelCoordAtComplexOrigin += drawMatrix.M41; PixelInfo.yPixelCoordAtComplexOrigin *= drawMatrix.M22; PixelInfo.yPixelCoordAtComplexOrigin += drawMatrix.M42; PixelInfo.unitsPerPixel /= drawMatrix.M11; // Reinitialize PpixelInfos lock (pixelInfosLock) { InitializePixelInfo(pixels); } drawMatrix = Matrix.Identity; globalIteration = 0; break; } UpdateCoordinateText(); } base.Update(gameTime); }
public string ProcessTouch(GestureSample gesture, SaveGameData _gameData) { //base.ProcessInput(gesture); int level = _gameData.levelReached[_gameData.worldReached]; if (!pressedButton.isAnimating()) { if (menuState == GameMenuState.MenuStateMain && this.RespondsToGesture(gesture)) { gamePlay.animatedBlink(1, 30); pressedButton = gamePlay; nextState = GameMenuState.MenuStateChapterSelect; } else if (cityChapterButton.RespondsToGesture(gesture) && !cityChapterButton.hidden) { _gameData.worldReached = 0; updateButtons(_gameData.levelReached[_gameData.worldReached]); cityChapterButton.animatedBlink(1, 30); pressedButton = cityChapterButton; SelectedChapterNum = 0; nextState = GameMenuState.MenuStateLevelSelect; } else if (caveChapterButton.RespondsToGesture(gesture) && !caveChapterButton.hidden) { _gameData.worldReached = 2; updateButtons(_gameData.levelReached[_gameData.worldReached]); caveChapterButton.animatedBlink(1, 30); pressedButton = caveChapterButton; SelectedChapterNum = 2; nextState = GameMenuState.MenuStateLevelSelect; } else if (cityChallengeChapterButton.RespondsToGesture(gesture) && !cityChallengeChapterButton.hidden) { _gameData.worldReached = 1; updateButtons(_gameData.levelReached[_gameData.worldReached]); cityChallengeChapterButton.animatedBlink(1, 30); pressedButton = cityChallengeChapterButton; SelectedChapterNum = 1; nextState = GameMenuState.MenuStateLevelSelect; } else if (caveChallengeChapterButton.RespondsToGesture(gesture) && !caveChallengeChapterButton.hidden) { _gameData.worldReached = 3; updateButtons(_gameData.levelReached[_gameData.worldReached]); caveChallengeChapterButton.animatedBlink(1, 30); pressedButton = caveChallengeChapterButton; SelectedChapterNum = 3; nextState = GameMenuState.MenuStateLevelSelect; } else if (back.RespondsToGesture(gesture)) { pressedButton = back; nextState = menuState - 1; } foreach (Button b in lockedLevels) { if (b.RespondsToGesture(gesture)) { int buttonLevel = b.getExtra(); if (buttonLevel <= level && buttonLevel >= 0) { unloadContent(); SelectedLevelNum = buttonLevel; return "i am not a null string. don't use this anymore"; } } } } return null; }
public void WinGameNowButton_Tapped(string id, GestureSample gesture) { data.SetWinnerSide(data.Sides[data.GetPlayerId()]); GameOver?.Invoke(data); }
public static Vector2 ScaledPosition2(this GestureSample gestureSample) { return(Input.ScaledPosition(gestureSample.Position2)); }
/// <summary> /// Pass the touch to the game world as a last resort. /// </summary> /// <param name="gesture"></param> public bool ProcessTouch(GestureSample gesture) { return commandMenu.ProcessTouch(gesture, listOfWorldPlatforms); }
public abstract void update_input(TouchGestures gesture, GestureSample sample);
public static void Update(GameTime gameTime) { TouchPanel.EnabledGestures = GestureType.Tap | GestureType.HorizontalDrag | GestureType.VerticalDrag; #if WINDOWS_UAP if (!ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1)) #endif { // handle vibration if (_durationLeft > 0.0f) { _durationLeft -= gameTime.ElapsedGameTime.TotalMilliseconds; if (_durationLeft < 0.0f) { SetVibration(0.0f, _vibrationRight, 0, _durationRight); } } if (_durationRight > 0.0f) { _durationRight -= gameTime.ElapsedGameTime.TotalMilliseconds; if (_durationRight < 0.0f) { SetVibration(_vibrationLeft, 0.0f, _durationLeft, 0); } } // get current gamepad and keyboard state if (ActiveController != null) { _gamePadState = GamePad.GetState((PlayerIndex)ActiveController); } else { _gamePadState = new GamePadState(); } } _keyboardState = Keyboard.GetState(); _mouseState = Mouse.GetState(); _currentInputState.Position = _mouseState.Position; // for each button, get it's actual state (we only want one "true" per button press...holding a button doesn't stay "true" _currentInputState.Up = GetKeyState(_gamePadState.DPad.Up, _lastGamePadState.DPad.Up, InputStates.Up); _currentInputState.Down = GetKeyState(_gamePadState.DPad.Down, _lastGamePadState.DPad.Down, InputStates.Down); _currentInputState.Left = GetKeyState(_gamePadState.DPad.Left, _lastGamePadState.DPad.Left, InputStates.Left); _currentInputState.Right = GetKeyState(_gamePadState.DPad.Right, _lastGamePadState.DPad.Right, InputStates.Right); _currentInputState.Back = GetKeyState(_gamePadState.Buttons.Back, _lastGamePadState.Buttons.Back, InputStates.Back) | GetKeyState(_gamePadState.Buttons.B, _lastGamePadState.Buttons.B, InputStates.Back) | GetKeyState(_mouseState.RightButton, _lastMouseState.RightButton, InputStates.Back); _currentInputState.Start = GetKeyState(_gamePadState.Buttons.Start, _lastGamePadState.Buttons.Start, InputStates.Start) | GetKeyState(_gamePadState.Buttons.A, _lastGamePadState.Buttons.A, InputStates.Start) | GetKeyState(_mouseState.LeftButton, _lastMouseState.LeftButton, InputStates.Start); _currentInputState.Debug = GetKeyState(_gamePadState.Buttons.LeftShoulder, _lastGamePadState.Buttons.LeftShoulder, InputStates.Debug); _currentInputState.FullScreen = GetKeyState(_gamePadState.Buttons.RightShoulder, _lastGamePadState.Buttons.RightShoulder, InputStates.FullScreen); // now setup a state for the real gamepad state ("true" for the length of time held down) _rawInputState.Up = GetKeyState(_gamePadState.DPad.Up, InputStates.Up) | GetThumbstickState(InputStates.Up); _rawInputState.Down = GetKeyState(_gamePadState.DPad.Down, InputStates.Down) | GetThumbstickState(InputStates.Down); _rawInputState.Left = GetKeyState(_gamePadState.DPad.Left, InputStates.Left) | GetThumbstickState(InputStates.Left); _rawInputState.Right = GetKeyState(_gamePadState.DPad.Right, InputStates.Right) | GetThumbstickState(InputStates.Right); _rawInputState.Back = GetKeyState(_gamePadState.Buttons.Back, InputStates.Back) | GetKeyState(_gamePadState.Buttons.B, InputStates.Back) | GetKeyState(_mouseState.RightButton, InputStates.Right); _rawInputState.Start = GetKeyState(_gamePadState.Buttons.Start, InputStates.Start) | GetKeyState(_gamePadState.Buttons.A, InputStates.Start) | GetKeyState(_mouseState.LeftButton, InputStates.Start); _lastGamePadState = _gamePadState; _lastKeyboardState = _keyboardState; _lastMouseState = _mouseState; TouchPanel.GetState(); while (TouchPanel.IsGestureAvailable) { GestureSample gesture = TouchPanel.ReadGesture(); switch (gesture.GestureType) { case GestureType.Tap: _currentInputState.Start = true; break; case GestureType.HorizontalDrag: if (gesture.Delta.X > 0) { _currentInputState.Right = _rawInputState.Right = true; } if (gesture.Delta.X < 0) { _currentInputState.Left = _rawInputState.Left = true; } break; case GestureType.VerticalDrag: if (gesture.Delta.Y > 0) { _currentInputState.Down = _rawInputState.Down = true; } if (gesture.Delta.Y < 0) { _currentInputState.Up = _rawInputState.Up = true; } break; } } }
protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } // Process auto-move card and perhaps initiate next auto-move bool checkForNextAutoMove = false; foreach (List <CardInfo> final in finals) { foreach (CardInfo cardInfo in final) { if (cardInfo.AutoMoveTime > TimeSpan.Zero) { cardInfo.AutoMoveTime -= gameTime.ElapsedGameTime; if (cardInfo.AutoMoveTime <= TimeSpan.Zero) { cardInfo.AutoMoveTime = TimeSpan.Zero; checkForNextAutoMove = true; } cardInfo.AutoMoveInterpolation = (float)cardInfo.AutoMoveTime.Ticks / AutoMoveDuration.Ticks; } } } if (checkForNextAutoMove && !AnalyzeForAutoMove() && HasWon()) { congratsComponent.Enabled = true; } while (TouchPanel.IsGestureAvailable) { GestureSample gesture = TouchPanel.ReadGesture(); // Adjust position and delta for compressed image Vector2 position = Vector2.Transform(gesture.Position, inverseMatrix); Vector2 delta = position - Vector2.Transform(gesture.Position - gesture.Delta, inverseMatrix); switch (gesture.GestureType) { case GestureType.Tap: // Check if Replay is pressed if ((position - centerReplay).Length() < radiusReplay) { congratsComponent.Enabled = false; Replay(); } break; case GestureType.FreeDrag: // Continue to move a dragged card if (touchedCard != null) { touchedCardPosition += delta; } // Try to pick up a card else if (firstDragInGesture) { TryPickUpCard(position); } firstDragInGesture = false; break; case GestureType.DragComplete: if (touchedCard != null && TryPutDownCard(touchedCard)) { CalculateDisplayMatrix(); if (!AnalyzeForAutoMove() && HasWon()) { congratsComponent.Enabled = true; } } firstDragInGesture = true; touchedCard = null; break; } } base.Update(gameTime); }
private void UpdatePlayer(GameTime gameTime) { player.Update(gameTime); // Get Thumbstick Controls player.Position.X += currentGamePadState.ThumbSticks.Left.X * playerMoveSpeed; player.Position.Y -= currentGamePadState.ThumbSticks.Left.Y * playerMoveSpeed; // Para soportar pantalla tactil en Windows 8/10 while (TouchPanel.IsGestureAvailable) { GestureSample gesture = TouchPanel.ReadGesture(); if (gesture.GestureType == GestureType.FreeDrag) { player.Position += gesture.Delta; } } //Get Mouse State then Capture the Button type and Respond Button Press Vector2 mousePosition = new Vector2(currentMouseState.X, currentMouseState.Y); if (currentMouseState.LeftButton == ButtonState.Pressed) { Vector2 posDelta = mousePosition - player.Position; posDelta.Normalize(); posDelta = posDelta * playerMoveSpeed; player.Position = player.Position + posDelta; } // Use the Keyboard / Dpad if (currentKeyboardState.IsKeyDown(Keys.Left) || currentGamePadState.DPad.Left == ButtonState.Pressed) { player.Position.X -= playerMoveSpeed; } if (currentKeyboardState.IsKeyDown(Keys.Right) || currentGamePadState.DPad.Right == ButtonState.Pressed) { player.Position.X += playerMoveSpeed; } if (currentKeyboardState.IsKeyDown(Keys.Up) || currentGamePadState.DPad.Up == ButtonState.Pressed) { player.Position.Y -= playerMoveSpeed; } if (currentKeyboardState.IsKeyDown(Keys.Down) || currentGamePadState.DPad.Down == ButtonState.Pressed) { player.Position.Y += playerMoveSpeed; } // Make sure that the player does not go out of bounds //player.Position.X = MathHelper.Clamp(player.Position.X, 0, GraphicsDevice.Viewport.Width - player.Width); //player.Position.Y = MathHelper.Clamp(player.Position.Y, 0, GraphicsDevice.Viewport.Height - player.Height); //Solucion al problema en la ubicacion del Player. player.Position.X = MathHelper.Clamp (player.Position.X, player.Width * player.PlayerAnimation.scale / 2, GraphicsDevice.Viewport.Width - player.Width * player.PlayerAnimation.scale / 2); player.Position.Y = MathHelper.Clamp (player.Position.Y, player.Height * player.PlayerAnimation.scale / 2, GraphicsDevice.Viewport.Height - player.Height * player.PlayerAnimation.scale / 2); //para disparar con espacio el laser if (currentKeyboardState.IsKeyDown(Keys.Space) || currentGamePadState.Buttons.X == ButtonState.Pressed) { FireLaser(gameTime); } }
// This function will check to see if the user has just pushed the A button or // the space bar. If so, we should go to the next effect. private void HandleInput() { KeyboardState currentKeyboardState = Keyboard.GetState(); GamePadState currentGamePadState = GamePad.GetState(PlayerIndex.One); // Allows the game to exit if (currentGamePadState.Buttons.Back == ButtonState.Pressed || currentKeyboardState.IsKeyDown(Keys.Escape)) { this.Exit(); } // check to see if someone has just released the space bar. bool keyboardSpace = currentKeyboardState.IsKeyUp(Keys.Space) && lastKeyboardState.IsKeyDown(Keys.Space); // check to see if someone has just released the 'F' key. bool keyboardF = currentKeyboardState.IsKeyUp(Keys.F) && lastKeyboardState.IsKeyDown(Keys.F); // check the gamepad to see if someone has just released the A button. bool gamepadA = currentGamePadState.Buttons.A == ButtonState.Pressed && lastGamepadState.Buttons.A == ButtonState.Released; // check our gestures to see if someone has tapped the screen. we want // to read all available gestures even if a tap occurred so we clear // the queue. bool tapGesture = false; while (TouchPanel.IsGestureAvailable) { GestureSample sample = TouchPanel.ReadGesture(); if (sample.GestureType == GestureType.Tap) { tapGesture = true; } } // if either the A button or the space bar was just released, or the screen // was tapped, move to the next state. Doing modulus by the number of // states lets us wrap back around to the first state. if (keyboardSpace || gamepadA || tapGesture) { currentState = (State)((int)(currentState + 1) % NumStates); } if (keyboardF) { graphics.ToggleFullScreen(); //Window.Window.IsVisible = true; //Window.Window.MakeKeyAndOrderFront(Window); } lastKeyboardState = currentKeyboardState; lastGamepadState = currentGamePadState; }
public override void Update(GameTime gametime) { #if ANDROID CurrentTouchState = TouchPanel.GetState(); if (CurrentTouchState.Count == 1) { PreviousGesturePosition = CurrentGesturePosition; CurrentGesturePosition = CurrentTouchState[0].Position; } while (TouchPanel.IsGestureAvailable) { GestureSample gesture = TouchPanel.ReadGesture(); switch (gesture.GestureType) { case GestureType.None: clearColor = Color.CornflowerBlue; break; case GestureType.DoubleTap: clearColor = clearColor == Color.CornflowerBlue ? Color.Red : Color.CornflowerBlue; break; case GestureType.Tap: clearColor = clearColor == Color.CornflowerBlue ? Color.Black : Color.CornflowerBlue; break; case GestureType.Flick: clearColor = clearColor == Color.CornflowerBlue ? Color.Pink : Color.CornflowerBlue; break; case GestureType.HorizontalDrag: clearColor = clearColor == Color.CornflowerBlue ? Color.Peru : Color.CornflowerBlue; break; case GestureType.VerticalDrag: clearColor = clearColor == Color.CornflowerBlue ? Color.Wheat : Color.CornflowerBlue; break; } currentGestureType = gesture.GestureType; } #endif #if WINDOWS PreviousPadState = currentPadState; previousKeyState = currentKeyState; currentPadState = GamePad.GetState(PlayerIndex.One); currentKeyState = Keyboard.GetState(); previousMouseState = currentMouseState; currentMousePos = new Vector2(Mouse.GetState().X, Mouse.GetState().Y); currentMouseState = Mouse.GetState(); KeysPressedInLastFrame.Clear(); CheckForTextInput(); UpdateControls(); thumbStick = ApplyDeadZone(currentPadState.ThumbSticks); #endif base.Update(gametime); }
public string GetCursor(World world, CPos cell, Int2 worldPixel, GestureSample gs) { return("default"); }
protected virtual void HandleGesture(GestureSample gesture) { //TODO: Create CCGesture and convert the coordinates into the local coordinates. }
public override bool ProcessTouch(GestureSample gesture) { //base.ProcessInput(gesture); if (toTitleScreen.RespondsToGesture(gesture)) { flag = GameMenuFlag.ToTitleScreen; } else if (replay.RespondsToGesture(gesture)) { flag = GameMenuFlag.Replay; } return flag != GameMenuFlag.NoFlag; }
public void BackButton_Tapped(string id, GestureSample gesture) { ApplicationData.CurrentScreen = ScreenType.Start; }
/// <summary> /// Function processes the user input /// </summary> /// <param name="gestureSample"></param> public void HandleInput(GestureSample gestureSample) { // Process input only if in Human's turn if (IsActive) { // Process any Drag gesture if (gestureSample.GestureType == GestureType.FreeDrag) { // If drag just began save the sample for future // calculations and start Aim "animation" if (null == firstSample) { firstSample = gestureSample; Catapult.CurrentState = CatapultState.Aiming; } // save the current gesture sample prevSample = gestureSample; // calculate the delta between first sample and current // sample to present visual sound on screen Vector2 delta = prevSample.Value.Position - firstSample.Value.Position; Catapult.ShotStrength = delta.Length() / maxDragDelta; Catapult.ShotVelocity = MinShotVelocity + Catapult.ShotStrength * (MaxShotVelocity - MinShotVelocity); if (delta.Length() > 0) { Catapult.ShotAngle = MathHelper.Clamp((float)Math.Asin(-delta.Y / delta.Length()), MinShotAngle, MaxShotAngle); } else { Catapult.ShotAngle = MinShotAngle; } float baseScale = 0.001f; arrowScale = baseScale * delta.Length(); isDragging = true; } else if (gestureSample.GestureType == GestureType.DragComplete) { // calc velocity based on delta between first and last // gesture samples if (null != firstSample) { Vector2 delta = prevSample.Value.Position - firstSample.Value.Position; Catapult.ShotVelocity = MinShotVelocity + Catapult.ShotStrength * (MaxShotVelocity - MinShotVelocity); if (delta.Length() > 0) { Catapult.ShotAngle = MathHelper.Clamp((float)Math.Asin(-delta.Y / delta.Length()), MinShotAngle, MaxShotAngle); } else { Catapult.ShotAngle = MinShotAngle; } Catapult.CurrentState = CatapultState.Firing; } // turn off dragging state ResetDragState(); } } }
public async void CreateTeamButton_Tapped(string id, GestureSample gesture) { team = TeamData.CreateDefaultTeam(); await teamManager.CreateTeam(team); }
/// <summary> /// Perform logic based on the current game state. /// </summary> /// <param name="gameTime">Time since this method was last called.</param> protected override void Update(GameTime gameTime) { // Allows the game to be closed using the back button if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } // Reads a gesture if one is available Rectangle? touchRect = null; GestureSample gs = new GestureSample(); while (TouchPanel.IsGestureAvailable && canUserInput) { gs = TouchPanel.ReadGesture(); touchRect = new Rectangle((int)gs.Position.X - 1, (int)gs.Position.Y - 1, 2, 2); } switch (state) { case TicTacToeState.GameInitialize: if (random.Next(0, 10) > 5) { state = TicTacToeState.PlayerTurn; } else { state = TicTacToeState.AITurn; } break; case TicTacToeState.ServiceNotAvailable: text = ServiceNotAvailableText; break; case TicTacToeState.WaitingForService: if (currentMove.Player == ConstData.XString) { text = SendingMoveText; } else { text = SendingAIMoveText; } break; case TicTacToeState.PlayerTurn: // If a tap was performed, try to perform a corresponding move if (touchRect.HasValue) { HandlePickMoveInput(touchRect.Value); if (currentMove != null) { sendMoveButton.HandleInput(gs); } } break; case TicTacToeState.AITurn: text = "Waiting for AI Player..."; AIPlay(); break; case TicTacToeState.GameOver: // Checks if one of the two buttons available at this state have been clicked newGameButton.HandleInput(gs); exitButtonButton.HandleInput(gs); break; default: break; } base.Update(gameTime); }
public async void EndTurnButton_Tapped(string id, GestureSample gesture) { await NextPlayerTurn(); }
public static Vector2 scaledPosition(this GestureSample gestureSample) { return(Input.scaledPosition(gestureSample.Position)); }
public void AppliedConditionRow_Held(UIComponent component, GestureSample gesture) { showAppliedConditionDetailsPanel = true; appliedConditionDetailsPanel.Position = gesture.Position; appliedConditionDetailsText.Value = selectedCharacter.Conditions.Aggregate("", (total, condition) => condition.Condition.Text + "\n" + total).Trim(); }
public override bool ProcessTouch(GestureSample gesture) { return base.ProcessTouch(gesture); }