Beispiel #1
0
 public Player(SpriteSheet spriteSheet, float x, float y, String startingAnimationName)
     : base(spriteSheet, x, y, startingAnimationName)
 {
     FacingDirection        = Direction.RIGHT;
     AirGroundState         = AirGroundState.AIR;
     previousAirGroundState = AirGroundState;
     PlayerState            = PlayerState.STANDING;
     previousPlayerState    = PlayerState;
     LevelState             = LevelState.RUNNING;
 }
Beispiel #2
0
 public override void Initialize()
 {
     base.Initialize();
     facingDirection = startFacingDirection;
     if (facingDirection == Direction.RIGHT)
     {
         currentAnimationName = "WALK_RIGHT";
     }
     else if (facingDirection == Direction.LEFT)
     {
         currentAnimationName = "WALK_LEFT";
     }
     airGroundState = AirGroundState.GROUND;
 }
Beispiel #3
0
 public override void OnEndCollisionCheckY(bool hasCollided, Direction direction)
 {
     // if bug is colliding with the ground, change its air ground state to GROUND
     // if it is not colliding with the ground, it means that it's currently in the air, so its air ground state is changed to AIR
     if (direction == Direction.DOWN)
     {
         if (hasCollided)
         {
             airGroundState = AirGroundState.GROUND;
         }
         else
         {
             airGroundState = AirGroundState.AIR;
         }
     }
 }
Beispiel #4
0
        public override void Update()
        {
            //Debug.WriteLine("X: " + GetX() + " Y: " + GetY());
            KeyboardState keyboardState = Keyboard.GetState();

            moveAmountX = 0;
            moveAmountY = 0;

            // if player is currently playing through level (has not won or lost)
            if (LevelState == LevelState.RUNNING)
            {
                ApplyGravity();

                // update player's state and current actions, which includes things like determining how much it should move each frame and if its walking or jumping
                do
                {
                    previousPlayerState = PlayerState;
                    HandlePlayerState(keyboardState);
                } while (previousPlayerState != PlayerState);

                previousAirGroundState = AirGroundState;

                // update player's animation
                base.Update();

                // move player with respect to map collisions based on how much player needs to move this frame
                base.MoveYHandleCollision(moveAmountY);
                base.MoveXHandleCollision(moveAmountX);

                UpdateLockedKeys(keyboardState);
            }

            // if player has beaten level
            else if (LevelState == LevelState.LEVEL_COMPLETED)
            {
                UpdateLevelCompleted();
            }

            // if player has lost level
            else if (LevelState == LevelState.PLAYER_DEAD)
            {
                UpdatePlayerDead();
            }
        }
Beispiel #5
0
        public override void Initialize()
        {
            base.Initialize();
            dinosaurState         = DinosaurState.WALK;
            previousDinosaurState = dinosaurState;
            facingDirection       = startFacingDirection;
            if (facingDirection == Direction.RIGHT)
            {
                currentAnimationName = "WALK_RIGHT";
            }
            else if (facingDirection == Direction.LEFT)
            {
                currentAnimationName = "WALK_LEFT";
            }
            airGroundState = AirGroundState.GROUND;

            // every 2 seconds, the fireball will be shot out
            shootTimer.SetWaitTime(2000);
        }
 //Also we need to start the context with initial state.
 //I use contructor class to specify the initial state
 public Aircraft(AirGroundState _initialState)
 {
     this.airGndState = _initialState;
 }