public override void Update(GameTime gameTime) { base.Update(gameTime); #if COMPLETE if (kinect.IsAvailable) { _timerKinectOver.Update(gameTime); Vector3 hand = kinect.GetUserProfile(KinectPlayerIndex.One).HandRight; _handSelector.Position = new Vector2(hand.X, hand.Y); foreach (MenuItem item in items) { if (CheckKinectOver(item, (int)hand.X, (int)hand.Y)) { item_MouseOver(item, new MouseOverSpriteEventArgs((int)hand.X, (int)hand.Y)); if (_kinectValidedAction) { item_MouseJustClicked(item, new MouseClickSpriteEventArgs((int)hand.X, (int)hand.Y, Yna.Input.MouseButton.Left, true, false)); } if (_timerKinectOver.Active) { _transitionKinectOver.Update(gameTime); _handSelector.Alpha = _transitionKinectOver.Alpha; } else { _timerKinectOver.Restart(); } } else if (CheckKinectLeave(item, (int)_lastKinectPosition.X, (int)_lastKinectPosition.Y, (int)hand.X, (int)hand.Y)) { item_MouseLeave(item, new MouseLeaveSpriteEventArgs((int)_lastKinectPosition.X, (int)_lastKinectPosition.Y, (int)hand.X, (int)hand.Y)); _timerKinectOver.Stop(); _handSelector.Color = Color.White; _handSelector.Alpha = 1.0f; _kinectValidedAction = false; } } _lastKinectPosition = hand; } else { _handSelector.Position = new Vector2(YnG.Mouse.X, YnG.Mouse.Y); } #else _handSelector.Position = new Vector2(YnG.Mouse.X, YnG.Mouse.Y); #endif }
public override void Update(GameTime gameTime) { base.Update(gameTime); _playerTouchedTimer.Update(gameTime); _weaponManager.Update(gameTime); // Mise à jour de la position du bouclier _shields.X = X + Width / 2 - _shields.Width / 2; _shields.Y = Y + Height / 2 - _shields.Height / 2; if (_shields.Active) { if (_shield > 0) { _shields.Play("blueStrong"); } else { _shields.Play("smallBlack"); } _shields.Update(gameTime); } #region Gamepad if (YnG.Gamepad.Connected(_playerIndex)) { if (YnG.Gamepad.LeftStickUp(_playerIndex)) { VelocityY -= _shipSpeed.Up * YnG.Gamepad.LeftStickValue(_playerIndex).Y * 1.5f; } else if (YnG.Gamepad.LeftStickDown(PlayerIndex.One)) { VelocityY -= _shipSpeed.Down * YnG.Gamepad.LeftStickValue(_playerIndex).Y * 1.5f; } if (YnG.Gamepad.LeftStickLeft(_playerIndex)) { VelocityX += _shipSpeed.Left * YnG.Gamepad.LeftStickValue(_playerIndex).X * 1.5f; } if (YnG.Gamepad.LeftStickRight(_playerIndex)) { VelocityX += _shipSpeed.Right * YnG.Gamepad.LeftStickValue(_playerIndex).X * 1.5f; } if (YnG.Gamepad.Pressed(_playerIndex, Buttons.RightTrigger)) { _weaponManager.Shoot(1); } if (YnG.Gamepad.JustPressed(_playerIndex, Buttons.LeftTrigger)) { _weaponManager.Shoot(2); } } #endregion #region Clavier // Le joueur 2 peut utiliser le clavier si le joueur 1 à une manette de branchée if (_playerIndex == PlayerIndex.Two && YnG.Gamepad.Connected(PlayerIndex.One) && !YnG.Gamepad.Connected(PlayerIndex.Two)) { UpdateKeyboardControl(); } else if (_playerIndex == PlayerIndex.One) { UpdateKeyboardControl(); } #endregion #if COMPLETE #region kinect if (kinect.IsAvailable) { Vector3 handRight = kinect.GetUserProfile(_kinectPlayerIndex).HandRight; Vector3 handLeft = kinect.GetUserProfile(_kinectPlayerIndex).HandLeft; X = (int)handRight.X; Y = (int)handRight.Y; if (handLeft.Y > 500) { Shoot(); } if (handLeft.Y < 20) { SelectedNextWeapon(); } } #endregion #endif }