Class Enemy
java.lang.Object
de.tum.cit.ase.maze.objects.GameElement
de.tum.cit.ase.maze.objects.dynamic.Character
de.tum.cit.ase.maze.objects.dynamic.Enemy
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
An enemy is a
Character
that can't be controlled by a GOD e.g. a person.
Instead, it will act as a dynamic "obstacle", that, if in contact, will hurt a Player
.
The damage is handled by a ContactListener
, more specific by the ListenerClass
.-
Field Summary
Fields inherited from class de.tum.cit.ase.maze.objects.dynamic.Character
deathListener, frameHeight, frameWidth, speed, state, stateTime, walkDirectionList, walkTypesAnimationMap, ZOOM
Fields inherited from class de.tum.cit.ase.maze.objects.GameElement
body, texture, world
-
Constructor Summary
ConstructorDescriptionEnemy
(com.badlogic.gdx.physics.box2d.World world, DeathListener deathListener) Enemy
(com.badlogic.gdx.physics.box2d.World world, DeathListener deathListener, float x, float y) Creates a new instance of the Enemy class with the given parameters.Enemy
(com.badlogic.gdx.physics.box2d.World world, DeathListener deathListener, Player player, float x, float y) Enemy
(com.badlogic.gdx.physics.box2d.World world, DeathListener deathListener, Player player, com.badlogic.gdx.math.Vector2 position) -
Method Summary
Modifier and TypeMethodDescriptionvoid
damage
(int damage) Subtracts the given amount of damage from the enemy's health and performs necessary actions based on the resulting health.void
dispose()
Releases all resources of this object.List<com.badlogic.gdx.math.Vector2>
getPath()
boolean
isDead()
Tells ifCharacter
has 0 lives;void
render
(com.badlogic.gdx.graphics.g2d.SpriteBatch spriteBatch) Renders the appearance of the game objectvoid
Sets the path it should follow the start nodevoid
void
update
(float deltaTime) Moves the Objectvoid
updateStateAndDirection
(State state, WalkDirection direction) Updates the state and direction.Methods inherited from class de.tum.cit.ase.maze.objects.dynamic.Character
getBody, getDimensions, getHealth, getPosition, getSpeed, getTexture, heal, makeDamage, setSpeed
-
Field Details
-
isFollowing
public boolean isFollowing
-
-
Constructor Details
-
Enemy
-
Enemy
public Enemy(com.badlogic.gdx.physics.box2d.World world, DeathListener deathListener, Player player, com.badlogic.gdx.math.Vector2 position) -
Enemy
public Enemy(com.badlogic.gdx.physics.box2d.World world, DeathListener deathListener, Player player, float x, float y) -
Enemy
public Enemy(com.badlogic.gdx.physics.box2d.World world, DeathListener deathListener, float x, float y) Creates a new instance of the Enemy class with the given parameters.- Parameters:
world
- The Box2D world in which the enemy will be created.deathListener
- The listener to handle the death of the enemy.x
- The initial x-coordinate of the enemy.y
- The initial y-coordinate of the enemy.
-
-
Method Details
-
damage
public void damage(int damage) Subtracts the given amount of damage from the enemy's health and performs necessary actions based on the resulting health.- Parameters:
damage
- The amount of damage to be inflicted on the enemy.
-
render
public void render(com.badlogic.gdx.graphics.g2d.SpriteBatch spriteBatch) Renders the appearance of the game object- Specified by:
render
in classGameElement
- Parameters:
spriteBatch
-
-
update
public void update(float deltaTime) Moves the Object -
getPlayer
-
setPlayer
-
updateStateAndDirection
Updates the state and direction. Convenience wrapper for start Moving and Stop moving.- Parameters:
state
-State
to which it should be changed.direction
-WalkDirection
it should change to.
-
setPath
Sets the path it should follow the start node -
getPath
-
dispose
public void dispose()Releases all resources of this object. -
isDead
public boolean isDead()Description copied from class:Character
Tells ifCharacter
has 0 lives;
-