Package model
Class Troop
java.lang.Object
model.Troop
- Direct Known Subclasses:
Aeroplane
,Soldier
,TeleporterTroop
public abstract class Troop
extends java.lang.Object
A troop is a unit that moves on a path from start to goal region. It has a specified amount of health, speed,
price and appearance.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Troop()
-
Method Summary
Modifier and Type Method Description Region
getCurrentRegion()
java.lang.Integer
getHealth()
java.lang.String
getName()
Position
getPosition()
java.lang.Integer
getPrice()
java.lang.Integer
getSpeed()
java.awt.image.BufferedImage
getTroopImage()
java.lang.Boolean
inGoal()
inGoal()boolean
isFlying()
isFlying()void
move()
move() - Moves the troop towards the location given.void
setCurrentRegion(Region r)
void
setHealth(java.lang.Integer health)
void
setInGoal(java.lang.Boolean b)
setInGoal()void
setPosition(Position position)
void
setTroopImage(java.awt.image.BufferedImage img)
void
subtractHealth(java.lang.Integer damage)
subtractHealth() - Subtracts health from troop.
-
Field Details
-
Constructor Details
-
Troop
public Troop()
-
-
Method Details
-
getHealth
public java.lang.Integer getHealth() -
getSpeed
public java.lang.Integer getSpeed() -
getPosition
-
getPrice
public java.lang.Integer getPrice() -
getName
public java.lang.String getName() -
getTroopImage
public java.awt.image.BufferedImage getTroopImage() -
getCurrentRegion
-
setHealth
public void setHealth(java.lang.Integer health) -
setPosition
-
setTroopImage
public void setTroopImage(java.awt.image.BufferedImage img) -
setCurrentRegion
-
move
public void move()move() - Moves the troop towards the location given. Since the troop can only move in 4 directions, either the row or the column will be the same as the troop is currently in. Troops col/row is calculated by its x/y divided by 40. -
subtractHealth
public void subtractHealth(java.lang.Integer damage)subtractHealth() - Subtracts health from troop.- Parameters:
damage
- - Damage to be subtracted.
-
inGoal
public java.lang.Boolean inGoal()inGoal()- Returns:
- True if troop has reached goal. False otherwise.
-
setInGoal
public void setInGoal(java.lang.Boolean b)setInGoal()- Parameters:
b
- - True if troop is to be set in goal. False otherwise.
-
isFlying
public boolean isFlying()isFlying()- Returns:
- - True if the troop is a flying type. False otherwise.
-