Package model

Class Building

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Barracks, Castle, Tower

public abstract class Building extends Entity implements Serializable
Implements the Building Entity type.
See Also:
  • Field Details

    • canUpgrade

      protected boolean canUpgrade
      Returns if the building can be upgraded.
    • isDestroyed

      protected boolean isDestroyed
      Returns if the building is destroyed.
    • isUpgraded

      protected boolean isUpgraded
      Determines if the Barrack instance is upgraded to train special units.
    • upgradeCost

      protected int upgradeCost
      Returns the building's upgrade cost.
  • Constructor Details

    • Building

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

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

    • destroy

      public void destroy()
      Destroys the Building instance, converts it to a ruin.
    • isDestroyed

      public boolean isDestroyed()
      Returns if the Building instance is a ruin.
      Returns:
      if the Building instance is a ruin
    • setDestroyed

      public void setDestroyed(boolean destroyed)
      Sets if the Building instance is destroyed.
      Parameters:
      destroyed - if the Building instance is destroyed
    • getImage

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

      public abstract void upgrade()
      Upgrades the Building instance, implementation depends on Building type.
    • getUpgradeCost

      public abstract int getUpgradeCost()
      Returns the upgrade cost of the Building instance.
      Returns:
      the upgrade cost of the Building instance