Exemple #1
0
        public override void update(IEntity entity)
        {
            Gravity     gravity     = entity.getGravity();
            KeysPressed keysPressed = entity.getKeysPressed();

            moveEntity(entity, keysPressed, gravity, entity.getMovementSpeed());

            if (gravity.isStanding() || gravity.isNotFalling())
            {
                entity.playAudio(AudioAttributes.LANDING_SOUND);
                IBehaviourStateFactory behaviourStateFactory = entity.getBehaviourStateFactory();

                if (!keysPressed.left && !keysPressed.right)
                {
                    entity.setState(behaviourStateFactory.getIdleState(entity));
                }
                else
                {
                    entity.setState(behaviourStateFactory.getMoveState(entity));
                }
            }
        }
Exemple #2
0
 protected void setEntity(IBehaviourStateFactory behaviourStateFactory)
 {
     entity = behaviourStateFactory.getBehaviourStateForPlayer(this);
     entity.setBehaviourStateFactory(behaviourStateFactory);
     state = behaviourStateFactory.getIdleState(entity);
 }