Exemple #1
0
        public void Update(GameTime gameTime)
        {
            var keyboardState = Keyboard.GetState();

            if (keyboardState.IsKeyDown(Keys.Enter))
            {
                _game.GameManager.ParticleManager.EmitPlayerDestroyedParticles(Position());
            }

            if (InputManager.KeyPressed(Keys.Z))
            {
                if (_game.Camera.Zoom == 1f)
                {
                    _game.Camera.ZoomTo(5f, 0.5, Position());
                }
                else
                {
                    _game.Camera.ZoomTo(1f, 0.5, Position());
                }
            }

            if (_invincibleTimer.TotalMilliseconds > 0)
            {
                _invincibleTimer -= gameTime.ElapsedGameTime;
            }
            else
            {
                Invincible = false;
            }

            CurrentAnimator.Update(gameTime.ElapsedGameTime.Milliseconds);

            _hitboxSprite.Position = _hitbox.GetCenter();

#if ANDROID
            UpdatePositionFromTouch(gameTime);
            //UpdateAnimationFromTouch();
#else
            UpdatePositionFromKeyboard(gameTime);
            //UpdateAnimationFromKeyboard();
#endif

            CheckOutOfBounds();
            UpdateShoot(gameTime);
        }
Exemple #2
0
        public void Update(GameTime gameTime)
        {
            if (_destroyed)
            {
                if (_game.GameManager.TransitioningToEndGame())
                {
                    _game.GameManager.ParticleManager.EmitPlayerDestroyedParticles(Position());
                    Dispose();
                }

                return;
            }

            if (_game.GameManager.CantMove())
            {
                return;
            }

            if (_ready)
            {
                var keyboardState = Keyboard.GetState();

                if (keyboardState.IsKeyDown(Keys.Enter))
                {
                    _game.GameManager.ParticleManager.EmitPlayerDestroyedParticles(Position());
                }

                if (InputManager.KeyPressed(Keys.Z))
                {
                    if (_game.Camera.Zoom == 1f)
                    {
                        _game.Camera.ZoomTo(5f, 0.5, Position());
                    }
                    else
                    {
                        _game.Camera.ZoomTo(1f, 0.5, Position());
                    }
                }

                if (!_hitTimer.Equals(TimeSpan.Zero))
                {
                    if (_hitTimer.TotalMilliseconds <= 0)
                    {
                        if (_game.SpriteBatchManager.Background != null)
                        {
                            var gradientBackground = (GradientBackground)_game.SpriteBatchManager.Background;
                            gradientBackground.ChangeGradientColors(_savedBackgroundBrightColor,
                                                                    _savedBackgroundDarkColor);

                            _backgroundColorChanged = false;
                        }
                    }
                    else
                    {
                        _hitTimer -= gameTime.ElapsedGameTime;
                    }
                }

#if ANDROID
                UpdatePositionFromTouch(gameTime);
                //UpdateAnimationFromTouch();
#else
                UpdatePositionFromKeyboard(gameTime);
                //UpdateAnimationFromKeyboard();
#endif

                UpdateShoot(gameTime);
                CheckOutOfBounds();
            }

            _hitboxSprite.Position = _hitbox.GetCenter();
            CurrentAnimator.Update(gameTime.ElapsedGameTime.Milliseconds);
        }