Package model
Class Entity
java.lang.Object
model.Entity
- All Implemented Interfaces:
Serializable
Implementation of Entity abstract class, containing the Entity types common fields and methods.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Animator
The Animator of the Entity.protected int
The damage the Entity deals.protected int
The health of the Entity.protected boolean
Determines if the Entity is alive.protected boolean
Determines if the Entity is animated.protected int
The maximum health of the Entity.protected Player
The owner of the Entity.protected Point
The position of the Entity.protected int
The attack range of the Entity.protected Sides
Determines which side the Entity belongs to.protected Dimension
The size of the Entity.protected Types
The type of Entity.protected int
The cost of the Entity. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the Entity's animator.int
Returns the Entity's damage.int
Returns the remaining health of the Entity.getImage()
Gets the name of correct sprite.int
Returns the max health of the Entity.getOwner()
Returns the Entity's owner.Returns the Entity's position.getSide()
Returns the side the Entity belongs to.getSize()
Returns the Entity's size.getType()
Returns the Entity's type.int
getValue()
Returns the Entity's value.void
invert()
Rotates the Entity.boolean
isAlive()
Returns if the Entity is alive.boolean
Gets if the Entity is animated.protected void
killUnit()
Sets the Entity's health to zero and sets it to dead.void
setAlive
(boolean alive) Sets if the Entity is alive.void
setAnimated
(boolean l) Sets if the Entity is animated.void
setIsAnimated
(boolean l) Sets if the Entity is animated.void
Sets the Entity's owner.void
setPosition
(Point position) Sets the Entity's position.void
Sets the Entity's side.void
takeDamage
(int damage) The Entity takes the passed damage.
-
Field Details
-
healthPoints
protected int healthPointsThe health of the Entity. -
maxHealthPoints
protected int maxHealthPointsThe maximum health of the Entity. -
position
The position of the Entity. -
type
The type of Entity. -
isAlive
protected boolean isAliveDetermines if the Entity is alive. -
damage
protected int damageThe damage the Entity deals. -
range
protected int rangeThe attack range of the Entity. -
size
The size of the Entity. -
value
protected int valueThe cost of the Entity. -
owner
The owner of the Entity. -
animObj
The Animator of the Entity. -
isAnimated
protected boolean isAnimatedDetermines if the Entity is animated. -
side
Determines which side the Entity belongs to.
-
-
Constructor Details
-
Entity
Constructs an Entity instance without side.- Parameters:
position
- the Entity instance's position on the Map
-
Entity
Constructs an Entity instance with side.- Parameters:
position
- the Entity instance's position on the Mapside
- the side it belongs to
-
Entity
protected Entity()Constructs an Entity instance with JacksonJSON.
-
-
Method Details
-
getSide
Returns the side the Entity belongs to.- Returns:
- the side the Entity belongs to
-
setSide
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
Returns the Entity's position.- Returns:
- Returns the Entity's position
-
setPosition
Sets the Entity's position.- Parameters:
position
- the new position
-
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
Returns the Entity's owner.- Returns:
- the Entity's owner
-
setOwner
Sets the Entity's owner.- Parameters:
owner
- the new owner
-
getSize
Returns the Entity's size.- Returns:
- the Entity's size
-
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
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.
-