Package model
Class Tower
java.lang.Object
model.Entity
model.Building
model.Tower
- All Implemented Interfaces:
Serializable
Implementation of the Tower Building type.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
The Tower's attacking speed.protected boolean
Determines if the Tower can attack.protected int
The level of the Tower.protected int
The attack range of the Tower.protected int
The maximum amount of targets the Tower can attack at once.The targets of the Tower in an ArrayList.protected int
The amount of targets the Tower can attack at once.Fields inherited from class model.Building
canUpgrade, isDestroyed, isUpgraded, upgradeCost
Fields inherited from class model.Entity
animObj, damage, healthPoints, isAlive, isAnimated, maxHealthPoints, owner, position, side, size, type, value
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
attack()
Attacks the targets.int
Returns the attack speed of the Tower.getImage()
Gets the name of correct sprite.int
getLevel()
Returns the Tower's level.int
getRange()
Returns the Tower's range.Returns the Tower's targets in an ArrayList.int
Returns the upgrade cost of the Building instance.boolean
Returns if the Tower can attack.void
selectTargets
(ArrayList<Soldier> entities) Selects the Tower's targets.void
takeDamage
(int damage) Takes damage from an attack.Transforms the Tower's subclass to a new Tower subclass.void
upgrade()
Upgrades the Tower.Methods inherited from class model.Building
destroy, isDestroyed, setDestroyed
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
-
Field Details
-
level
protected int levelThe level of the Tower. -
targets
The targets of the Tower in an ArrayList. -
canAttack
protected boolean canAttackDetermines if the Tower can attack. -
range
protected int rangeThe attack range of the Tower. -
attackSpeed
protected int attackSpeedThe Tower's attacking speed. -
targetCount
protected int targetCountThe maximum amount of targets the Tower can attack at once. -
targetsPerAttack
protected int targetsPerAttackThe amount of targets the Tower can attack at once.
-
-
Constructor Details
-
Tower
Constructs a new Tower instance.- Parameters:
position
- the tower's position on the Mapside
- the side it belongs to
-
Tower
Constructs a new Tower instance.- Parameters:
position
- the tower's position on the Map
-
-
Method Details
-
transform
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. -
getUpgradeCost
public int getUpgradeCost()Description copied from class:Building
Returns the upgrade cost of the Building instance.- Specified by:
getUpgradeCost
in classBuilding
- Returns:
- the upgrade cost of the Building instance
-
selectTargets
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
Description copied from class:Entity
Gets the name of correct sprite. -
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 classEntity
- Parameters:
damage
- the damage to take
-
getAttackSpeed
public int getAttackSpeed()Returns the attack speed of the Tower.- Returns:
- the attack speed of the Tower
-