Package model

Class Tower

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Barricade, Shotgun, Sniper

public abstract class Tower extends Building
Implementation of the Tower Building type.
See Also:
  • Field Details

    • level

      protected int level
      The level of the Tower.
    • targets

      protected ArrayList<Soldier> targets
      The targets of the Tower in an ArrayList.
    • canAttack

      protected boolean canAttack
      Determines if the Tower can attack.
    • range

      protected int range
      The attack range of the Tower.
    • attackSpeed

      protected int attackSpeed
      The Tower's attacking speed.
    • targetCount

      protected int targetCount
      The maximum amount of targets the Tower can attack at once.
    • targetsPerAttack

      protected int targetsPerAttack
      The amount of targets the Tower can attack at once.
  • Constructor Details

    • Tower

      public Tower(Point position, Sides side)
      Constructs a new Tower instance.
      Parameters:
      position - the tower's position on the Map
      side - the side it belongs to
    • Tower

      public Tower(Point position)
      Constructs a new Tower instance.
      Parameters:
      position - the tower's position on the Map
  • Method Details

    • transform

      public Tower transform(Types type)
      Transforms the Tower's subclass to a new Tower subclass.
      Parameters:
      type - the type to convert to
      Returns:
      the new Tower subclass instance
    • upgrade

      public void upgrade()
      Upgrades the Tower.
      Specified by:
      upgrade in class Building
    • getUpgradeCost

      public int getUpgradeCost()
      Description copied from class: Building
      Returns the upgrade cost of the Building instance.
      Specified by:
      getUpgradeCost in class Building
      Returns:
      the upgrade cost of the Building instance
    • selectTargets

      public void selectTargets(ArrayList<Soldier> entities)
      Selects the Tower's targets.
      Parameters:
      entities - the entities to select
    • getLevel

      public int getLevel()
      Returns the Tower's level.
      Returns:
      the Tower's level
    • getImage

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

      public ArrayList<Soldier> getTargets()
      Returns the Tower's targets in an ArrayList.
      Returns:
      the Tower's targets in an ArrayList
    • isCanAttack

      public boolean isCanAttack()
      Returns if the Tower can attack.
      Returns:
      if the Tower can attack
    • getRange

      public int getRange()
      Returns the Tower's range.
      Returns:
      the Tower's range
    • attack

      public void attack()
      Attacks the targets.
    • takeDamage

      public void takeDamage(int damage)
      Takes damage from an attack.
      Overrides:
      takeDamage in class Entity
      Parameters:
      damage - the damage to take
    • getAttackSpeed

      public int getAttackSpeed()
      Returns the attack speed of the Tower.
      Returns:
      the attack speed of the Tower