コード例 #1
0
        public override void HandleLanding()
        {
            IsInAir = false;

            if (MovementState == CharacterMovementStates.Jumping)
            {
                MovementState = CharacterMovementStates.Idle;
                SpriteState   = IsFacingRight ? CharacterSpriteStates.IdleRight : CharacterSpriteStates.IdleLeft;
                character.SetSprite(SpriteFactory.GetCharacterIdleSprite(Constants.CHARACTER_TYPE_1, IsFacingRight ? SpriteOrientation.Right : SpriteOrientation.Left, IsCarryingObject));
            }
        }
コード例 #2
0
        private void ProcessActions(List <Actions> actionList)
        {
            foreach (Actions action in actionList)
            {
                if (action == Actions.MoveRight)
                {
                    StateManager.HandleMoveRightInput();

                    if (StateManager.IsFacingRight)
                    {
                        MoveRight();
                    }
                }

                else if (action == Actions.MoveLeft)
                {
                    StateManager.HandleMoveLeftInput();

                    if (!StateManager.IsFacingRight)
                    {
                        MoveLeft();
                    }
                }

                else if (action == Actions.Jump)
                {
                    StateManager.HandleJumpInput();
                }

                else if (action == Actions.PickUp)
                {
                    StateManager.HandlePickupInput();
                }

                else if (action == Actions.Drink)
                {
                    StateManager.HandleDrinkInput();
                }
            }

            if (actionList.Count == 0 && !StateManager.IsInAir && !StateManager.IsDead)
            {
                if (Velocity.X == 0 && Velocity.Y == 0 && StateManager.IsFacingRight)
                {
                    StateManager.MovementState = CharacterMovementStates.Idle;
                    SetSprite(SpriteFactory.GetCharacterIdleSprite(Constants.CHARACTER_TYPE_1, SpriteOrientation.Right, StateManager.IsCarryingObject));
                }
                else if (Velocity.X == 0 && Velocity.Y == 0 && !StateManager.IsFacingRight)
                {
                    StateManager.MovementState = CharacterMovementStates.Idle;
                    SetSprite(SpriteFactory.GetCharacterIdleSprite(Constants.CHARACTER_TYPE_1, SpriteOrientation.Left, StateManager.IsCarryingObject));
                }
            }
        }
コード例 #3
0
        public override void HandleMoveRightInput()
        {
            if (MovementState == CharacterMovementStates.Idle && IsFacingRight)
            {
                MovementState = CharacterMovementStates.Walking;
                character.SetSprite(SpriteFactory.GetCharacterWalkingSprite(Constants.CHARACTER_TYPE_1, SpriteOrientation.Right, IsCarryingObject));
            }
            else if (MovementState == CharacterMovementStates.Walking && IsCollidingWithPushableObject)
            {
                MovementState = CharacterMovementStates.Pushing;
                character.SetSprite(SpriteFactory.GetCharacterPushingSprite(Constants.CHARACTER_TYPE_1, SpriteOrientation.Right));
            }
            else if (MovementState == CharacterMovementStates.Idle && !IsFacingRight)
            {
                MovementState = CharacterMovementStates.Idle;
                character.SetSprite(SpriteFactory.GetCharacterIdleSprite(Constants.CHARACTER_TYPE_1, SpriteOrientation.Right, IsCarryingObject));
            }
            else if (MovementState == CharacterMovementStates.Walking && !IsFacingRight)
            {
                MovementState = CharacterMovementStates.Idle;
                character.SetSprite(SpriteFactory.GetCharacterIdleSprite(Constants.CHARACTER_TYPE_1, SpriteOrientation.Right, IsCarryingObject));
            }
            else if (MovementState == CharacterMovementStates.Pushing && IsFacingRight)
            {
                MovementState = CharacterMovementStates.Pushing;
            }
            else if (MovementState == CharacterMovementStates.Pushing && !IsFacingRight)
            {
                MovementState = CharacterMovementStates.Idle;
                character.SetSprite(SpriteFactory.GetCharacterIdleSprite(Constants.CHARACTER_TYPE_1, SpriteOrientation.Right, IsCarryingObject));
            }
            else if (MovementState == CharacterMovementStates.Jumping)
            {
                MovementState = CharacterMovementStates.Jumping;
                character.SetSprite(SpriteFactory.GetCharacterJumpingSprite(Constants.CHARACTER_TYPE_1, SpriteOrientation.Right, IsCarryingObject));
                IsInAir = true;
            }

            IsFacingRight = true;
        }