Package model
Class Soldier
java.lang.Object
model.Entity
model.Soldier
- All Implemented Interfaces:
Serializable
Implementation of Soldier Entity type.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe location of the enemy Castle's Tile locations.An ArrayList containing the path of the Solider to the enemy Castle.protected final Pathfinder
The soldier's pathfinderprotected double
The current speed of the Soldier.protected Entity
The Soldier's target Entity.An ArrayList which contains which tiles the Solider can cross.int
The end of visualization highlighting.int
The start of visualization highlighting.The soldier's waypoints.Fields inherited from class model.Entity
animObj, damage, healthPoints, isAlive, isAnimated, maxHealthPoints, owner, position, range, side, size, type, value
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addWaypoint
(Point waypoint) Adds a waypoint to the Soldier's path.void
attack()
Attacks the unit's target if nearby.protected void
Calculates the shortest path to the enemy Castle.Returns the Soldier's absolute path of the found path in an ArrayList.getImage()
Gets the name of correct sprite.getPath()
Returns the path of the Solider to the enemy Castle in an ArrayList.double
getSpeed()
Returns the current speed of the Soldier.Returns which tiles the Solider can cross in an ArrayList.Returns the waypoints of the Soldier in an ArrayList.boolean
Returns if the Soldier is targeted.void
selectTarget
(Entity target) Selects a target for the Soldier to attack.void
setTargeted
(boolean targeted) Sets if the Soldier is targeted.Methods inherited from class model.Entity
getAnimObj, getDamage, getHealthPoints, getMaxHealthPoints, getOwner, getPosition, getSide, getSize, getType, getValue, invert, isAlive, isAnimated, killUnit, setAlive, setAnimated, setIsAnimated, setOwner, setPosition, setSide, takeDamage
-
Field Details
-
visualizationStart
public int visualizationStartThe start of visualization highlighting. -
visualizationEnd
public int visualizationEndThe end of visualization highlighting. -
speed
protected double speedThe current speed of the Soldier. -
terrains
An ArrayList which contains which tiles the Solider can cross. -
target
The Soldier's target Entity. -
pathfinder
The soldier's pathfinder -
path
An ArrayList containing the path of the Solider to the enemy Castle. -
wayPoints
The soldier's waypoints. -
castleParts
The location of the enemy Castle's Tile locations.
-
-
Constructor Details
-
Soldier
Constructs a new Soldier instance.- Parameters:
position
- the soldier's position
-
-
Method Details
-
getSpeed
public double getSpeed()Returns the current speed of the Soldier.- Returns:
- the current speed of the Soldier
-
getTerrains
Returns which tiles the Solider can cross in an ArrayList.- Returns:
- which tiles the Solider can cross in an ArrayList
-
getPath
Returns the path of the Solider to the enemy Castle in an ArrayList.- Returns:
- the path of the Solider to the enemy Castle in an ArrayList
-
getImage
Description copied from class:Entity
Gets the name of correct sprite. -
selectTarget
Selects a target for the Soldier to attack.- Parameters:
target
- the target to select
-
attack
public void attack()Attacks the unit's target if nearby. -
calculatePath
protected void calculatePath()Calculates the shortest path to the enemy Castle. -
addWaypoint
Adds a waypoint to the Soldier's path.- Parameters:
waypoint
- the waypoint to add
-
getWayPoints
Returns the waypoints of the Soldier in an ArrayList.- Returns:
- the waypoints of the Soldier in an ArrayList
-
getAbsPath
Returns the Soldier's absolute path of the found path in an ArrayList.- Returns:
- the Soldier's absolute path of the found path in an ArrayList
-
isTargeted
public boolean isTargeted()Returns if the Soldier is targeted.- Returns:
- if the Soldier is targeted
-
setTargeted
public void setTargeted(boolean targeted) Sets if the Soldier is targeted.- Parameters:
targeted
- if the Soldier is targeted
-