Class Creature

All Implemented Interfaces:
EntityRenderedListener, EntityRenderListener, ICollisionEntity, ICombatEntity, IEntity, IMobileEntity, Tweenable, EventListener

public class Creature extends CombatEntity implements IMobileEntity
TODO: Add idle event
  • Constructor Details

  • Method Details

    • onMoved

      public void onMoved(IMobileEntity.EntityMovedListener listener)
      Description copied from interface: IMobileEntity
      Adds the specified entity moved listener to receive events when this entity was moved.

      In comparison to the EntityTransformListener.locationChanged(IEntity) event, this provides some additional information about the movement (e.g. distance) and is only fired if the entity instance is currently loaded.

      Specified by:
      onMoved in interface IMobileEntity
      Parameters:
      listener - The listener to add.
    • removeMovedListener

      public void removeMovedListener(IMobileEntity.EntityMovedListener listener)
      Description copied from interface: IMobileEntity
      Removes the specified entity moved listener.
      Specified by:
      removeMovedListener in interface IMobileEntity
      Parameters:
      listener - The listener to remove.
    • getTweenValues

      public float[] getTweenValues(TweenType tweenType)
      Description copied from interface: Tweenable
      Gets one or many values from the target object associated to the given tween type. It is used by the Tween Engine to determine starting values.
      Specified by:
      getTweenValues in interface Tweenable
      Overrides:
      getTweenValues in class CombatEntity
      Parameters:
      tweenType - The tween type of this interpolation, determining which values are modified.
      Returns:
      The array of current tween values.
    • setTweenValues

      public void setTweenValues(TweenType tweenType, float[] newValues)
      Description copied from interface: Tweenable
      This method is called in a Tween's update() method to set the new interpolated values.
      Specified by:
      setTweenValues in interface Tweenable
      Overrides:
      setTweenValues in class CombatEntity
      Parameters:
      tweenType - The tween type of this interpolation, determining which values are modified.
      newValues - The new values determined by the tween equation.
    • getAcceleration

      public int getAcceleration()
      Description copied from interface: IMobileEntity
      Gets a value that defines how long it takes the entity to reach the full velocity (in ms).
      Specified by:
      getAcceleration in interface IMobileEntity
      Returns:
      the acceleration value
    • getDeceleration

      public int getDeceleration()
      Description copied from interface: IMobileEntity
      Gets a value that defines how long it takes the entity to stop when slowing down from movements (in ms).
      Specified by:
      getDeceleration in interface IMobileEntity
      Returns:
      the deceleration value
    • getFacingDirection

      public Direction getFacingDirection()
    • movement

      public IMovementController movement()
      Description copied from interface: IMobileEntity
      Gets the movement controller.
      Specified by:
      movement in interface IMobileEntity
      Returns:
      the movement controller
    • getSpritesheetName

      public String getSpritesheetName()
      Gets the current spritesheet name of this instance. Overwriting this allows for a more sophisticated logic that determines the sprite to be used; e.g. This method could append certain properties of the creature (state, weapon, ...) to the default string.

      The value of this method will be used e.g. by the CreatureAnimationController to determine the animation that it should play.
      Returns:
      The current spritesheet name of this instance.
    • getTickVelocity

      public float getTickVelocity()
      Description copied from interface: IMobileEntity
      Gets the entity's velocity in PIXELS per tick.
      Specified by:
      getTickVelocity in interface IMobileEntity
      Returns:
      The velocity in pixel per tick.
    • getVelocity

      public Attribute<Float> getVelocity()
      Description copied from interface: IMobileEntity
      Gets the entity's velocity in PIXELS per Second.
      Specified by:
      getVelocity in interface IMobileEntity
      Returns:
      the velocity in pixel per second.
    • isScaling

      public boolean isScaling()
    • isIdle

      public boolean isIdle()
      Checks if is idle.
      Returns:
      true, if is idle
    • setAcceleration

      public void setAcceleration(int acceleration)
      Description copied from interface: IMobileEntity
      Sets the acceleration for this entity. Acceleration is a value that defines how long it takes the entity to reach the full velocity when starting to move (in ms). *
      Specified by:
      setAcceleration in interface IMobileEntity
      Parameters:
      acceleration - the new acceleration
    • setDeceleration

      public void setDeceleration(int deceleration)
      Description copied from interface: IMobileEntity
      Sets the deceleration for this entity. deceleration is a value that defines how long it takes the entity to stop when slowing down from movements (in ms).
      Specified by:
      setDeceleration in interface IMobileEntity
      Parameters:
      deceleration - the new deceleration
    • setFacingDirection

      public void setFacingDirection(Direction facingDirection)
    • setLocation

      public void setLocation(Point2D location)
      Description copied from class: Entity
      Sets the map location.
      Specified by:
      setLocation in interface IEntity
      Overrides:
      setLocation in class CollisionEntity
      Parameters:
      location - the new map location
    • setTurnOnMove

      public void setTurnOnMove(boolean turn)
      Description copied from interface: IMobileEntity
      Sets the turn on move parameter for this entity. It specifies if the entity will change its angle to the direction of the move destination when moved.
      Specified by:
      setTurnOnMove in interface IMobileEntity
      Parameters:
      turn - the new turn on move parameter.
    • setSpritesheetName

      public void setSpritesheetName(String spritesheetName)
    • setScaling

      public void setScaling(boolean scaling)
    • setVelocity

      public void setVelocity(float velocity)
      Description copied from interface: IMobileEntity
      Sets the base value on the velocity attribute of this instance.
      Specified by:
      setVelocity in interface IMobileEntity
      Parameters:
      velocity - The velocity to be set.
      See Also:
    • turnOnMove

      public boolean turnOnMove()
      Description copied from interface: IMobileEntity
      Gets the turn on move parameter for this entity. It specifies if the entity will change its angle to the direction of the move destination when moved.
      Specified by:
      turnOnMove in interface IMobileEntity
      Returns:
      true, if the entity will change its angle to the direction of the move destination when being moved
    • toString

      public String toString()
      Overrides:
      toString in class Entity
    • updateAnimationController

      protected void updateAnimationController()
    • createAnimationController

      protected IEntityAnimationController<?> createAnimationController()
    • createMovementController

      protected IMovementController createMovementController()