Beispiel #1
0
        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
        }
Beispiel #2
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            _timerFired.Update(gameTime);

            _position.X  = (float)(Center + Math.Sin(Y * 0.01f) * _radius);
            _position.Y += _speed;

            Play("move");

            int countPlayers = Registry.Players.Length;

            if (countPlayers > 1)
            {
                foreach (SpacePlayer player in Registry.Players)
                {
                    if (Rectangle.Intersects(player.Rectangle))
                    {
                        AddDamagesOnPlayer(player, 30);
                    }

                    if (Health <= 0)
                    {
                        Kill((int)player.PlayerIndex);
                    }
                }
            }
            else
            {
                if (Rectangle.Intersects(Registry.Players[0].Rectangle))
                {
                    AddDamagesOnPlayer(Registry.Players[0], 30);
                }

                if (Health <= 0)
                {
                    Kill(0);
                }
            }

            if (Y > YnG.Height)
            {
                Kill(0);
            }
        }
Beispiel #3
0
        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
        }
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            _shootTimer.Update(gameTime);
        }
Beispiel #5
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            spawnTimer.Update(gameTime);
        }
Beispiel #6
0
 public override void Update(GameTime gameTime)
 {
     base.Update(gameTime);
     highlightTimer.Update(gameTime);
     timeCounterWheelEntity.Rotation += gameTime.ElapsedGameTime.Milliseconds * 0.00025f;
 }
Beispiel #7
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            #region MessageBox Début de la partie

            if (gameStatus == GameStatus.Starting)
            {
                _startGameTimer.Update(gameTime);
            }

            #endregion

            #region Mise à jour globale du jeu

            else if (gameStatus == GameStatus.Running)
            {
                // Quitter le jeu
                // Todo retour au menu ou affichage du menu de pause
                if (YnG.Keys.Escape)
                {
                    ChangeGameStatus(GameStatus.Paused);
                    return;
                }
            }

            #endregion

            #region MessageBox Partie en pause

            else if (gameStatus == GameStatus.Paused)
            {
                if (YnG.Keys.JustPressed(Keys.Enter))
                {
                    ChangeGameStatus(GameStatus.Quit);
                }
                else if (YnG.Keys.JustPressed(Keys.P))
                {
                    ChangeGameStatus(GameStatus.Running);
                }
            }

            #endregion

            #region MessageBox Fin de partie

            // Si la partie est terminée on réinitialise le tout
            // Et on affichage la box de fin
            else if (gameStatus == GameStatus.Loose)
            {
                _looseTimer.Update(gameTime);

                // Mise à jour de la box de fin
                string message = messageBoxManager.MessageBoxEnd.BaseMessage;
                message += String.Format("\n\nGet ready in {0}\n\n\nOr press Enter or Space to continue", _looseTimer.TimeRemaining);
                messageBoxManager.MessageBoxEnd.Message = message;
            }

            else if (gameStatus == GameStatus.Success)
            {
                YnG.SwitchState(new ScoreState());
            }

            #endregion
        }
Beispiel #8
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            _ambianceManager.Update(gameTime);

            _narationTimer.Update(gameTime);

            if (_deadlySceenOfDeath)
            {
                // Le joueur est là où il ne devrait pas!
                // Fondu qui va bien
                _deathAlpha += 0.01F;

                if (_deathAlpha >= 1.0F && _ambianceManager.TransitionDone())
                {
                    // Le joueur est mort : TP sur le banc
                    _deathAlpha = 0.0F;
                    SetData(ImlostGame.Scenes ["scene_1"]);
                }
            }
            else
            {
                if (_showSplash)
                {
                    // Splash affiché, on le masque si on clique n'importe où
                    if (YnG.Mouse.JustClicked(MouseButton.Left) || GetTouchState() ||
                        YnG.Keys.JustPressed(Keys.C) || YnG.Keys.JustPressed(Keys.NumPad0) || YnG.Gamepad.JustPressed(PlayerIndex.One, Buttons.Y))
                    {
                        _showSplash = false;
                    }
                }
                else
                {
                    _menuIcon.Update(gameTime);
                    _notesIcon.Update(gameTime);

                    //Gestion du curseur par manette xbox360
                    if (GamePad.GetState(PlayerIndex.One).IsConnected)
                    {
#if !LINUX
                        Mouse.SetPosition(YnG.Mouse.X + (int)YnG.Gamepad.RightStickValue(PlayerIndex.One).X * 20, YnG.Mouse.Y - (int)YnG.Gamepad.RightStickValue(PlayerIndex.One).Y * 20);
#endif
                    }

                    if (MouseInRectangle(_menuIcon.Rectangle) && YnG.Mouse.JustClicked(MouseButton.Left) || GetTouchState() ||
                        YnG.Keys.JustPressed(Keys.C) || YnG.Keys.JustPressed(Keys.NumPad0) || YnG.Gamepad.JustPressed(PlayerIndex.One, Buttons.Y))
                    {
                        // Click sur le menu
                        // TODO
                    }

                    // Images sur la scène
                    List <YnEntity> safeList = new List <YnEntity>(_itemsOnScreen);
                    foreach (YnEntity img in safeList)
                    {
                        img.Update(gameTime);
                    }

                    if (YnG.Mouse.MouseState.LeftButton == ButtonState.Pressed && !_dragging)
                    {
                        foreach (YnEntity img in _itemImages.Values)
                        {
                            if (MouseInRectangle(img.Rectangle))
                            {
                                _dragging = true;

                                _draggedImage = new YnEntity(img.AssetName);
                                _draggedImage.LoadContent();
                            }
                        }
                    }

                    if (YnG.Mouse.Released(MouseButton.Left) && _dragging)
                    {
                        _draggedImage.Position = new Vector2(YnG.Mouse.X - _draggedImage.Width / 2, YnG.Mouse.Y - _draggedImage.Height / 2);

                        if (YnG.Mouse.Released(MouseButton.Left))
                        {
                            // Drop
                            List <YnEntity> safeList2 = new List <YnEntity>(_itemsOnScreen);
                            foreach (YnEntity img in safeList2)
                            {
                                if (img.Rectangle.Intersects(_draggedImage.Rectangle))
                                {
                                    // Intersection
                                    DoDrop(_draggedImage, img);
                                }
                            }
                        }
                    }

                    if (_dragging)
                    {
                        _draggedImage.Position = new Vector2(YnG.Mouse.X - _draggedImage.Width / 2, YnG.Mouse.Y - _draggedImage.Height / 2);
                    }

                    if (YnG.Mouse.Released(MouseButton.Left))
                    {
                        _dragging = false;
                    }

                    // Déplacement au clavier, et manette Xbox360
                    if ((YnG.Keys.JustPressed(Keys.Z) || YnG.Keys.JustPressed(Keys.Up) || YnG.Gamepad.JustPressed(PlayerIndex.One, Buttons.LeftThumbstickUp)) &&
                        _sceneData.TopScene != String.Empty)
                    {
                        GoUp();
                    }
                    else if ((YnG.Keys.JustPressed(Keys.S) || YnG.Keys.JustPressed(Keys.Down) || YnG.Gamepad.JustPressed(PlayerIndex.One, Buttons.LeftThumbstickDown)) &&
                             _sceneData.BottomScene != String.Empty)
                    {
                        GoDown();
                    }
                    else if ((YnG.Keys.JustPressed(Keys.Q) || YnG.Keys.JustPressed(Keys.Left) || YnG.Gamepad.JustPressed(PlayerIndex.One, Buttons.LeftThumbstickLeft)) &&
                             _sceneData.LeftScene != String.Empty)
                    {
                        GoLeft();
                    }
                    else if ((YnG.Keys.JustPressed(Keys.D) || YnG.Keys.JustPressed(Keys.Right) || YnG.Gamepad.JustPressed(PlayerIndex.One, Buttons.LeftThumbstickRight)) &&
                             _sceneData.RightScene != String.Empty)
                    {
                        GoRight();
                    }
                    else if (YnG.Keys.JustPressed(Keys.Escape) || YnG.Gamepad.JustPressed(PlayerIndex.One, Buttons.Back))
                    {
                        YnG.Exit();
                    }

                    if (YnG.Mouse.JustClicked(MouseButton.Left) || GetTouchState() ||
                        YnG.Keys.JustPressed(Keys.C) || YnG.Keys.JustPressed(Keys.NumPad0) || YnG.Gamepad.JustPressed(PlayerIndex.One, Buttons.Y))
                    {
                        // Click sur le bouton de menu
                        int mx = YnG.Mouse.X;
                        int my = YnG.Mouse.Y;
                        if (MouseInRectangle(_menuHitbox) || TouchInRectangle(_menuHitbox) ||
                            YnG.Keys.JustPressed(Keys.C) || YnG.Keys.JustPressed(Keys.NumPad0) || YnG.Gamepad.JustPressed(PlayerIndex.One, Buttons.Y))
                        {
                            // Afficher ou masquer le menu
                            // 97 => hauteur du menu
                            // 25 => hauteur de la poignée
                            int delta = 97 - 25;
                            if (_menuIsShown)
                            {
                                // Déplacement de la hitbox vers le haut
                                _menuHitbox.Y += delta;

                                // Déplacement du background vers le haut
                                _menuBackground.Y += delta;
                            }
                            else
                            {
                                // Déplacement de la hitbox vers le bas
                                _menuHitbox.Y -= delta;

                                // Déplacement du background vers le bas
                                _menuBackground.Y -= delta;
                            }
                            _menuIsShown = !_menuIsShown;

                            _menuIcon.Visible  = _menuIsShown;
                            _notesIcon.Visible = _menuIsShown;

                            // Un peu brutasse comme méthode...
                            // On cache tout
                            foreach (KeyValuePair <string, YnEntity> pair in _itemImages)
                            {
                                pair.Value.Visible = false;
                            }

                            // Et on ne raffiche que ce qui est dans l'inventaire du joueur
                            int itemPadding = 20;
                            int nbItems     = _inventory.Count;
                            int x           = YnG.Width / 2 - (56 * nbItems) / 2;
                            if (nbItems > 1)
                            {
                                x -= ((nbItems - 1) * itemPadding) / 2;
                            }

                            foreach (InventoryItem item in _inventory)
                            {
                                if (_menuIsShown)
                                {
                                    _itemImages [item.Code].Visible = true;

                                    // Replacement de l'élément, centré en bas, de gauche à droite
                                    Vector2 pos = new Vector2(x, YnG.Height - 63);
                                    _itemImages [item.Code].Position = pos;

                                    x += 56 + itemPadding;
                                }
                            }
                        }
                    }
                }
            }
        }
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (gameState == MazeGameState.Playing)
            {
                if (YnG.Keys.JustPressed(Keys.Escape) || YnG.Gamepad.JustPressed(PlayerIndex.One, Buttons.Back))
                {
                    gameState = MazeGameState.Terminated;
                    OnExitRequest(EventArgs.Empty);
                }

                soundTimer.Update(gameTime);

                elapsedPartyTime += gameTime.ElapsedGameTime.Milliseconds;

                timeTimer.Update(gameTime.ElapsedGameTime.Milliseconds);

                _gameHUD.Update(gameTime);
                _gameHUD.Time = timeTimer.ToString();

                control.Update(gameTime);
#if DEBUG
                if (YnG.Keys.JustPressed(Keys.F8))
                {
                    OnLevelFinished(new LevelFinishEventArgs(score, (_mazeLevel.Id + 1), false));
                }
#endif
                string collider = control.ValidatePosition(_mazeLevel.Walls);

                if (collider == "END")
                {
                    gameState = MazeGameState.Ending;
                    UpdateScore(50);
                }
                else if (collider == "WALL")
                {
                    if (YnG.AudioManager.SoundEnabled)
                    {
                        YnG.AudioManager.PlaySound("Audio/bat", 1.0f, 1.0f, 0.0f);
                        YnG.AudioManager.SoundEnabled = false;
                        soundTimer.Start();
                    }
                }

                groundPlayerBoundingSphere.Center = new Vector3(Camera.Position.X, 1, Camera.Position.Z);

                foreach (YnMeshModel model in _mazeLevel.Items)
                {
                    if (model.Active)
                    {
                        if (groundPlayerBoundingSphere.Intersects(model.BoundingSphere))
                        {
                            YnG.AudioManager.PlaySound("Audio/kristal", 1.0f, 1.0f, 0.0f);
                            UpdateScore((model as AnimatedItemMesh).Points);
                            _gameHUD.MiniMap.UpdateItemStatus(Camera.X, Camera.Z);
                            _gameHUD.UpdateNbCrystals();
                            model.Active = false;
                        }
                    }
                }

                if (_gameHUD.MiniMap.Enabled)
                {
                    _gameHUD.MiniMap.UpdatePlayerPosition(Camera.X, Camera.Z);
                }

                if (virtualPad.Enabled)
                {
                    virtualPad.Update(gameTime);
                }
            }
            else if (gameState == MazeGameState.Ending)
            {
                gameState = MazeGameState.Terminated;

                bool finishedGame = false;

                int nextLevel = (_mazeLevel.Id + 1);

                if (nextLevel > GameConfiguration.LevelCount)
                {
                    nextLevel    = 1;
                    finishedGame = true;
                }

                score.ElapsedTime = elapsedPartyTime;

                OnLevelFinished(new LevelFinishEventArgs(score, nextLevel, finishedGame));
            }
        }