Package com.csse3200.game.components
Class CombatStatsComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.CombatStatsComponent
- Direct Known Subclasses:
DeathZoneComponent,TrapComponent
Component used to store information related to combat such as health, attack, etc.
Any entities which engage in combat should have an instance of this class registered.
This class can be extended for more specific combat needs.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHealth(int health) Adds to the player's health.intReturns the entity's base attack damage.intReturns the entity's health.booleanGets the last attacker which caused the entity to take damage.voidhit(CombatStatsComponent attacker) Called when this entity is hit by an attacker.isDead()Returns true if the entity's has 0 health, otherwise false.voidsetBaseAttack(int attack) Sets the entity's attack damage.voidsetHealth(int health) Sets the entity's health.voidsetIsInvulnerable(boolean status) voidsetLastAttacker(Entity lastAttacker) Sets the last attacker which caused the entity to take damage.Methods inherited from class com.csse3200.game.components.Component
create, dispose, earlyUpdate, getEntity, getPrio, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
CombatStatsComponent
public CombatStatsComponent(int health, int baseAttack) -
CombatStatsComponent
-
-
Method Details
-
isDead
Returns true if the entity's has 0 health, otherwise false.- Returns:
- is player dead
-
getHealth
public int getHealth()Returns the entity's health.- Returns:
- entity's health
-
setHealth
public void setHealth(int health) Sets the entity's health. Health has a minimum bound of 0.- Parameters:
health- health
-
addHealth
public void addHealth(int health) Adds to the player's health. The amount added can be negative.- Parameters:
health- health to add
-
getLastAttacker
Gets the last attacker which caused the entity to take damage.- Returns:
- the entity that last attacked this entity
-
setLastAttacker
Sets the last attacker which caused the entity to take damage. This is public so that if something calls setHealth, we can still register the death cause by manually calling this.- Parameters:
lastAttacker- the entity that last attacked this entity
-
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
-
hit
Called when this entity is hit by an attacker.- Parameters:
attacker- the attacker's CombatStatsComponent
-
setIsInvulnerable
public void setIsInvulnerable(boolean status) -
getIsInvulnerable
public boolean getIsInvulnerable()
-