Class Character
java.lang.Object
de.tum.cit.ase.maze.objects.GameElement
de.tum.cit.ase.maze.objects.dynamic.Character
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
Defines an abstract class, that describes a movable Character.
Can be a Player or a NPC.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final DeathListener
Handles death of a Charterprotected int
protected int
protected int
Health of a Characterprotected float
Defines the speed the Character is movingprotected State
State of the object.protected float
Time for a stateprotected List<WalkDirection>
List of requested directionsprotected final Map<WalkDirection,
com.badlogic.gdx.graphics.g2d.Animation<com.badlogic.gdx.graphics.g2d.TextureRegion>> List of moving animationsprotected final float
Fields inherited from class de.tum.cit.ase.maze.objects.GameElement
body, texture, world
-
Constructor Summary
ConstructorDescriptionCharacter
(com.badlogic.gdx.physics.box2d.World world, DeathListener deathListener) -
Method Summary
Modifier and TypeMethodDescriptioncom.badlogic.gdx.physics.box2d.Body
getBody()
com.badlogic.gdx.math.Vector2
int
com.badlogic.gdx.math.Vector2
Gets positionfloat
getSpeed()
com.badlogic.gdx.graphics.g2d.TextureRegion
Gets Texture.boolean
heal
(int amountToHeal) Heals the Characterboolean
isDead()
Tells ifCharacter
has 0 lives;void
makeDamage
(int damage) Applies damage.void
setSpeed
(float speed) void
update
(float deltaTime) Moves the ObjectMethods inherited from class de.tum.cit.ase.maze.objects.GameElement
render
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.badlogic.gdx.utils.Disposable
dispose
-
Field Details
-
walkTypesAnimationMap
protected final Map<WalkDirection,com.badlogic.gdx.graphics.g2d.Animation<com.badlogic.gdx.graphics.g2d.TextureRegion>> walkTypesAnimationMapList of moving animations -
deathListener
Handles death of a Charter -
ZOOM
protected final float ZOOM- See Also:
-
frameWidth
protected int frameWidth -
frameHeight
protected int frameHeight -
health
protected int healthHealth of a Character -
state
State of the object. -
walkDirectionList
List of requested directions -
speed
protected float speedDefines the speed the Character is moving -
stateTime
protected float stateTimeTime for a state
-
-
Constructor Details
-
Character
-
-
Method Details
-
getPosition
public com.badlogic.gdx.math.Vector2 getPosition()Gets position- Returns:
Vector2
of the position in Box2D scale. (REQUIRED to covert into pixel)
-
getTexture
public com.badlogic.gdx.graphics.g2d.TextureRegion getTexture()Gets Texture.- Returns:
- TextureRegion at the moment
-
update
public void update(float deltaTime) Moves the Object- Specified by:
update
in classGameElement
- Parameters:
deltaTime
- Time since last frame.
-
isDead
public boolean isDead()Tells ifCharacter
has 0 lives; -
getBody
public com.badlogic.gdx.physics.box2d.Body getBody() -
getHealth
public int getHealth() -
makeDamage
public void makeDamage(int damage) Applies damage.- Parameters:
damage
- damage to apply
-
heal
public boolean heal(int amountToHeal) Heals the Character- Parameters:
amountToHeal
- Health amount to restore- Returns:
- if health was full
-
getSpeed
public float getSpeed() -
setSpeed
public void setSpeed(float speed) -
getDimensions
public com.badlogic.gdx.math.Vector2 getDimensions()
-