Package model

Class Entity

java.lang.Object
model.Entity
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Building, Soldier

public abstract class Entity extends Object implements Serializable
Implementation of Entity abstract class, containing the Entity types common fields and methods.
See Also:
  • Field Details

    • healthPoints

      protected int healthPoints
      The health of the Entity.
    • maxHealthPoints

      protected int maxHealthPoints
      The maximum health of the Entity.
    • position

      protected Point position
      The position of the Entity.
    • type

      protected Types type
      The type of Entity.
    • isAlive

      protected boolean isAlive
      Determines if the Entity is alive.
    • damage

      protected int damage
      The damage the Entity deals.
    • range

      protected int range
      The attack range of the Entity.
    • size

      protected Dimension size
      The size of the Entity.
    • value

      protected int value
      The cost of the Entity.
    • owner

      protected Player owner
      The owner of the Entity.
    • animObj

      protected Animator animObj
      The Animator of the Entity.
    • isAnimated

      protected boolean isAnimated
      Determines if the Entity is animated.
    • side

      protected Sides side
      Determines which side the Entity belongs to.
  • Constructor Details

    • Entity

      protected Entity(Point position)
      Constructs an Entity instance without side.
      Parameters:
      position - the Entity instance's position on the Map
    • Entity

      protected Entity(Point position, Sides side)
      Constructs an Entity instance with side.
      Parameters:
      position - the Entity instance's position on the Map
      side - the side it belongs to
    • Entity

      protected Entity()
      Constructs an Entity instance with JacksonJSON.
  • Method Details

    • getSide

      public Sides getSide()
      Returns the side the Entity belongs to.
      Returns:
      the side the Entity belongs to
    • setSide

      public void setSide(Sides side)
      Sets the Entity's side.
      Parameters:
      side - the side we want to set it
    • getHealthPoints

      public int getHealthPoints()
      Returns the remaining health of the Entity.
      Returns:
      the remaining health of the Entity
    • getMaxHealthPoints

      public int getMaxHealthPoints()
      Returns the max health of the Entity.
      Returns:
      the max health of the Entity
    • getPosition

      public Point getPosition()
      Returns the Entity's position.
      Returns:
      Returns the Entity's position
    • setPosition

      public void setPosition(Point position)
      Sets the Entity's position.
      Parameters:
      position - the new position
    • getType

      public Types getType()
      Returns the Entity's type.
      Returns:
      the Entity's type
    • isAlive

      public boolean isAlive()
      Returns if the Entity is alive.
      Returns:
      if the Entity is alive
    • setAlive

      public void setAlive(boolean alive)
      Sets if the Entity is alive.
      Parameters:
      alive - if the Entity is alive
    • getValue

      public int getValue()
      Returns the Entity's value.
      Returns:
      the Entity's value
    • getOwner

      public Player getOwner()
      Returns the Entity's owner.
      Returns:
      the Entity's owner
    • setOwner

      public void setOwner(Player owner)
      Sets the Entity's owner.
      Parameters:
      owner - the new owner
    • getSize

      public Dimension getSize()
      Returns the Entity's size.
      Returns:
      the Entity's size
    • getImage

      public String getImage()
      Gets the name of correct sprite.
      Returns:
      name of image.
    • invert

      public void invert()
      Rotates the Entity.
    • getDamage

      public int getDamage()
      Returns the Entity's damage.
      Returns:
      the Entity's damage
    • getAnimObj

      public Animator getAnimObj()
      Gets the Entity's animator.
      Returns:
      the Entity's animator
    • isAnimated

      public boolean isAnimated()
      Gets if the Entity is animated.
      Returns:
      if the Entity is animated
    • setAnimated

      public void setAnimated(boolean l)
      Sets if the Entity is animated.
      Parameters:
      l - if the Entity is animated
    • setIsAnimated

      public void setIsAnimated(boolean l)
      Sets if the Entity is animated.
      Parameters:
      l - if the Entity is animated
    • takeDamage

      public void takeDamage(int damage)
      The Entity takes the passed damage.
      Parameters:
      damage - the damage to take
    • killUnit

      protected void killUnit()
      Sets the Entity's health to zero and sets it to dead.