Class Enemy
java.lang.Object
de.tum.cit.fop.maze.objects.GameObject
de.tum.cit.fop.maze.objects.Dynamic.Enemy.Enemy
- All Implemented Interfaces:
Enemies
Base enemy class with AI behavior, death handling, and collision detection.
-
Field Summary
FieldsFields inherited from class de.tum.cit.fop.maze.objects.GameObject
bounds, currentAnimationType, drawable, position, sizes, speed, speedMultiplier, spriteSizes, texture, velocity -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidanimate(com.badlogic.gdx.graphics.g2d.Batch batch) Renders the object using its drawable or texture.Gets enemy as GameObject.com.badlogic.gdx.math.Vector2Gets enemy position.booleanisDead()Checks if enemy is dead.Handles enemy death rewards and collectables.voidsetDead(boolean dead) Sets enemy death state.booleanChecks if enemy should be removed after death.voidupdateBehavior(float deltaTime, com.badlogic.gdx.math.Vector2 playerPosition, GameField gameField, Player player) Updates enemy behavior including chasing and idle states.voidupdateDeathAnimation(float delta) Updates death animation fade timer.protected booleanWallOrObstacle(float x, float y, com.badlogic.gdx.math.Vector2 size, GameField gameField) Methods inherited from class de.tum.cit.fop.maze.objects.GameObject
changeAnimation, entitiesOverlap, getBounds, getDrawable, getSize, getSpeed, getVelocity, increaseSpeed, move, multiplySpeed, nextPosition, setAnimationTime, updateAnimationMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.tum.cit.fop.maze.objects.Dynamic.Enemy.Enemies
AnimationDirection, chase, flee, patrol
-
Field Details
-
isDead
protected boolean isDead
-
-
Constructor Details
-
Enemy
-
-
Method Details
-
updateBehavior
public void updateBehavior(float deltaTime, com.badlogic.gdx.math.Vector2 playerPosition, GameField gameField, Player player) Updates enemy behavior including chasing and idle states.- Parameters:
deltaTime- Time since last updateplayerPosition- Player's current positiongameField- Game field for navigationplayer- Player reference
-
updateDeathAnimation
public void updateDeathAnimation(float delta) Updates death animation fade timer.- Parameters:
delta- Time since last update
-
shouldRemove
public boolean shouldRemove()Checks if enemy should be removed after death.- Returns:
- True if fade animation is complete
-
WallOrObstacle
protected boolean WallOrObstacle(float x, float y, com.badlogic.gdx.math.Vector2 size, GameField gameField) -
onDeath
Handles enemy death rewards and collectables.- Parameters:
player- The player who killed the enemy- Returns:
- Collectable drop
-
animate
public void animate(com.badlogic.gdx.graphics.g2d.Batch batch) Description copied from class:GameObjectRenders the object using its drawable or texture.- Overrides:
animatein classGameObject- Parameters:
batch- Sprite batch for rendering
-
isDead
public boolean isDead()Checks if enemy is dead.- Returns:
- True if dead
-
setDead
public void setDead(boolean dead) Sets enemy death state.- Parameters:
dead- New death state
-
getEnemyEntity
Gets enemy as GameObject.- Returns:
- This enemy instance
-
getPosition
public com.badlogic.gdx.math.Vector2 getPosition()Gets enemy position.- Returns:
- Position vector
-