Exemple #1
0
 protected virtual void switchState(IEntity entity, KeysPressed keysPressed, Gravity gravity, IGravityClient gravityClient)
 {
     if (!keysPressed.jump)
     {
         if (gravity.Y_velocity >= 0.0f && (gravityClient.getJumpForce() * 0.85f) > gravity.Y_velocity)
         {
             gravity.Y_velocity = -0.01f;
         }
     }
     if (gravity.isFalling() || gravity.isStanding())
     {
         gravity.Jumping = false;
         IBehaviourStateFactory behaviourStateFactory = entity.getBehaviourStateFactory();
         entity.setState(behaviourStateFactory.getFallState(entity));
     }
 }
Exemple #2
0
        public override void update(IEntity entity)
        {
            Gravity     gravity     = entity.getGravity();
            KeysPressed keysPressed = entity.getKeysPressed();

            IBehaviourStateFactory behaviourStateFactory = entity.getBehaviourStateFactory();

            if (keysPressed.jump && gravity.isStanding() && entity.getJumpedReleased())
            {
                entity.setState(behaviourStateFactory.getJumpUpState(entity));
            }
            else if (gravity.isStanding() && ((keysPressed.left && !keysPressed.right) || (!keysPressed.left && keysPressed.right)))
            {
                entity.setState(behaviourStateFactory.getMoveState(entity));
            }
            else if (!gravity.isStanding())
            {
                entity.setState(behaviourStateFactory.getFallState(entity));
            }
        }