Esempio n. 1
0
        public virtual void Update(GameTime gameTime, Map map, int[,] hazardMap)
        {
            if (IsAlive && !InDestruction)
            {
                PreviousDirection = CurrentDirection;

                Sprite.Update(gameTime);

                #region Invincibility

                if (!GameConfiguration.Invincible && IsInvincible)
                {
                    if (InvincibleTimer >= TimeSpan.Zero)
                    {
                        if (_invincibleBlinkTimer >= TimeSpan.Zero)
                        {
                            _invincibleBlinkTimer -= TimeSpan.FromTicks(GameConfiguration.DeltaTime);
                        }
                        else
                        {
                            _invincibleBlinkTimer = TimeSpan.FromSeconds(_invincibleBlinkFrequency);
                        }
                    }
                }

                #endregion

                #region Moving

                Move(gameTime, map, hazardMap);

                #endregion

                #region Bomb

                #region Push a bomb

                if (Config.PlayerCanPush)
                {
                    if (CurrentDirection != LookDirection.Idle)
                    {
                        Point direction = Point.Zero;
                        switch (CurrentDirection)
                        {
                        case LookDirection.Up:
                            direction = new Point(CellPosition.X, CellPosition.Y - 1);
                            break;

                        case LookDirection.Down:
                            direction = new Point(CellPosition.X, CellPosition.Y + 1);
                            break;

                        case LookDirection.Left:
                            direction = new Point(CellPosition.X - 1, CellPosition.Y);
                            break;

                        case LookDirection.Right:
                            direction = new Point(CellPosition.X + 1, CellPosition.Y);
                            break;
                        }
                        Bomb bomb = BombAt(direction);
                        if (bomb != null)
                        {
                            bomb.ChangeDirection(CurrentDirection, Id);
                        }
                    }
                }

                #endregion

                #endregion

                #region Teleporter

                /*
                 * if (!_cellTeleporting && FinalBomber.Instance.GamePlayScreen.World.Levels[FinalBomber.Instance.GamePlayScreen.World.CurrentLevel].
                 *  Map[CellPosition.X, CellPosition.Y] is Teleporter)
                 * {
                 *  var teleporter = (Teleporter)(FinalBomber.Instance.GamePlayScreen.World.Levels[FinalBomber.Instance.GamePlayScreen.World.CurrentLevel].
                 *      Map[CellPosition.X, CellPosition.Y]);
                 *
                 *  teleporter.ChangePosition(this);
                 *  _cellTeleporting = true;
                 * }
                 */

                #endregion
            }

            #region Death

            else if (InDestruction)
            {
                _deathAnimation.Update(gameTime);
            }
            #endregion

            #region Edge wall gameplay

            /*
             * else if (OnEdge &&
             *       (!Config.ActiveSuddenDeath ||
             *        (Config.ActiveSuddenDeath && !FinalBomber.Instance.GamePlayScreen.SuddenDeath.HasStarted)))
             * {
             *  Sprite.Update(gameTime);
             *
             *  MoveFromEdgeWall();
             * }
             */
            #endregion

            #region Camera

            /*
             * Camera.Update(gameTime);
             *
             * if (Config.Debug)
             * {
             *  if (InputHandler.KeyDown(Microsoft.Xna.Framework.Input.Keys.PageUp) ||
             *      InputHandler.ButtonReleased(Buttons.LeftShoulder, PlayerIndex.One))
             *  {
             *      Camera.ZoomIn();
             *      if (Camera.CameraMode == CameraMode.Follow)
             *          Camera.LockToSprite(Sprite);
             *  }
             *  else if (InputHandler.KeyDown(Microsoft.Xna.Framework.Input.Keys.PageDown))
             *  {
             *      Camera.ZoomOut();
             *      if (Camera.CameraMode == CameraMode.Follow)
             *          Camera.LockToSprite(Sprite);
             *  }
             *  else if (InputHandler.KeyDown(Microsoft.Xna.Framework.Input.Keys.End))
             *  {
             *      Camera.ZoomReset();
             *  }
             *
             *  if (InputHandler.KeyReleased(Microsoft.Xna.Framework.Input.Keys.F))
             *  {
             *      Camera.ToggleCameraMode();
             *      if (Camera.CameraMode == CameraMode.Follow)
             *          Camera.LockToSprite(Sprite);
             *  }
             *
             *  if (Camera.CameraMode != CameraMode.Follow)
             *  {
             *      if (InputHandler.KeyReleased(Microsoft.Xna.Framework.Input.Keys.L))
             *      {
             *          Camera.LockToSprite(Sprite);
             *      }
             *  }
             * }
             *
             * if (IsMoving && Camera.CameraMode == CameraMode.Follow)
             *  Camera.LockToSprite(Sprite);
             */

            #endregion

            // Call DynamicEntity Update method
            base.Update();
        }