Package com.deco2800.game.components
Class CombatStatsComponent
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.components.CombatStatsComponent
Component used to store information related to combat such as health, attack, etc. Any entities
which engage it combat should have an instance of this class registered. This class can be
extended for more specific combat needs.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionCombatStatsComponent(int health, int baseAttack, int baseDefence) CombatStatsComponent(int troops, int health, int baseAttack, int baseDefence, float landSpeed) CombatStatsComponent(int troops, int health, int baseAttack, int baseDefence, float landSpeed, int range) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHealth(int health) Adds to the player's health.voiddecreaseHealth(int damage) intReturns the entity's base attack damage.intReturns the entity's base defence.intReturns the entity's health.floatReturns the land movement speed of the unitintGet's the entity's maximum health.intgetRange()Returns the attack range for unitintReturns number of troops the unit hasvoidhit(CombatStatsComponent attacker) Manages the entity being hit by an attacking enemy.isDead()Returns true if the entity's has 0 health, otherwise false.voidsetBaseAttack(int attack) Sets the entity's attack damage.voidsetBaseDefence(int defence) Sets the entity's defence from attacks.voidsetHealth(int health) Sets the entity's health.voidsetLandSpeed(float landSpeed) Sets the land movement speed of unitvoidsetMaxHealth(int maxHealth) Sets the entity's maximum health.voidsetRange(int range) Sets the attack range for a unitvoidsetTroops(int troops) Sets the number of troops the unit hasvoidupdate()Called once per frame of the game, and should be used for most component logic.Methods inherited from class com.deco2800.game.components.Component
create, dispose, earlyUpdate, getEntity, isAnimationRenderComponent, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
Constructor Details
-
CombatStatsComponent
public CombatStatsComponent(int health, int baseAttack, int baseDefence) -
CombatStatsComponent
public CombatStatsComponent(int troops, int health, int baseAttack, int baseDefence, float landSpeed) -
CombatStatsComponent
public CombatStatsComponent(int troops, int health, int baseAttack, int baseDefence, float landSpeed, int range)
-
-
Method Details
-
update
public void update()Description copied from class:ComponentCalled once per frame of the game, and should be used for most component logic. Not called if component is disabled. -
getRange
public int getRange()Returns the attack range for unit- Returns:
- entity's attack range
-
setRange
public void setRange(int range) Sets the attack range for a unit- Parameters:
range- attack for unit
-
getTroops
public int getTroops()Returns number of troops the unit has- Returns:
- entity's troop count
-
setTroops
public void setTroops(int troops) Sets the number of troops the unit has- Parameters:
troops- number of troops to set.
-
getLandSpeed
public float getLandSpeed()Returns the land movement speed of the unit- Returns:
- land movement speed of unit
-
setLandSpeed
public void setLandSpeed(float landSpeed) Sets the land movement speed of unit- Parameters:
landSpeed- land movement speed to set
-
isDead
Returns true if the entity's has 0 health, otherwise false.- Returns:
- is player dead
-
isMaxHealth
-
getHealth
public int getHealth()Returns the entity's health.- Returns:
- entity's health
-
getMaxHealth
public int getMaxHealth()Get's the entity's maximum health.- Returns:
- entity's maximum health
-
setHealth
public void setHealth(int health) Sets the entity's health. Health has a minimum bound of 0.- Parameters:
health- health
-
setMaxHealth
public void setMaxHealth(int maxHealth) Sets the entity's maximum health. Maximum Health must be greater than or equal to 0.- Parameters:
maxHealth- Maximum health an entity can have
-
addHealth
public void addHealth(int health) Adds to the player's health. The amount added can be negative.- Parameters:
health- health to add
-
getBaseAttack
public int getBaseAttack()Returns the entity's base attack damage.- Returns:
- base attack damage
-
setBaseAttack
public void setBaseAttack(int attack) Sets the entity's attack damage. Attack damage has a minimum bound of 0.- Parameters:
attack- Attack damage
-
setBaseDefence
public void setBaseDefence(int defence) Sets the entity's defence from attacks. Defence has a minimum bound of 0.- Parameters:
defence- Attack defence
-
getBaseDefence
public int getBaseDefence()Returns the entity's base defence.- Returns:
- base defence
-
hit
Manages the entity being hit by an attacking enemy. Combatant takes damage equal to the attacker's attack less this entity's defence, with a minimum bound of 1.- Parameters:
attacker- The Combat Stats of an attacking entity
-
decreaseHealth
public void decreaseHealth(int damage)
-