All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable

public class Enemy extends Character
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 Details

    • isFollowing

      public boolean isFollowing
  • Constructor Details

    • Enemy

      public Enemy(com.badlogic.gdx.physics.box2d.World world, DeathListener deathListener)
    • 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 class GameElement
      Parameters:
      spriteBatch -
    • update

      public void update(float deltaTime)
      Moves the Object
      Overrides:
      update in class Character
      Parameters:
      deltaTime - Time since last frame.
    • getPlayer

      public Player getPlayer()
    • setPlayer

      public void setPlayer(Player player)
    • updateStateAndDirection

      public void updateStateAndDirection(State state, WalkDirection direction)
      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

      public void setPath(@NonNull List<Node> path)
      Sets the path it should follow the start node
      Parameters:
      path - List<Node> it should follow.
    • getPath

      public List<com.badlogic.gdx.math.Vector2> getPath()
    • dispose

      public void dispose()
      Releases all resources of this object.
    • isDead

      public boolean isDead()
      Description copied from class: Character
      Tells if Character has 0 lives;
      Overrides:
      isDead in class Character