Package model

Class Soldier

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Assassin, Climber, Diver, Kamikaze

public class Soldier extends Entity
Implementation of Soldier Entity type.
See Also:
  • Field Details

    • visualizationStart

      public int visualizationStart
      The start of visualization highlighting.
    • visualizationEnd

      public int visualizationEnd
      The end of visualization highlighting.
    • speed

      protected double speed
      The current speed of the Soldier.
    • terrains

      protected ArrayList<Types> terrains
      An ArrayList which contains which tiles the Solider can cross.
    • target

      protected Entity target
      The Soldier's target Entity.
    • pathfinder

      protected final Pathfinder pathfinder
      The soldier's pathfinder
    • path

      protected ArrayList<Point> path
      An ArrayList containing the path of the Solider to the enemy Castle.
    • wayPoints

      protected final ArrayList<Point> wayPoints
      The soldier's waypoints.
    • castleParts

      protected final ArrayList<Point> castleParts
      The location of the enemy Castle's Tile locations.
  • Constructor Details

    • Soldier

      public Soldier(Point position)
      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

      public ArrayList<Types> getTerrains()
      Returns which tiles the Solider can cross in an ArrayList.
      Returns:
      which tiles the Solider can cross in an ArrayList
    • getPath

      public ArrayList<Point> 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

      public String getImage()
      Description copied from class: Entity
      Gets the name of correct sprite.
      Overrides:
      getImage in class Entity
      Returns:
      name of image.
    • selectTarget

      public void selectTarget(Entity target)
      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

      public void addWaypoint(Point waypoint)
      Adds a waypoint to the Soldier's path.
      Parameters:
      waypoint - the waypoint to add
    • getWayPoints

      public ArrayList<Point> getWayPoints()
      Returns the waypoints of the Soldier in an ArrayList.
      Returns:
      the waypoints of the Soldier in an ArrayList
    • getAbsPath

      public ArrayList<Point> 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