Package com.csse3200.game.components
Class CombatStatsComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.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) Construct a combat Stats Component (Health + Attack System) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addHealth
(int health) Adds to the player's health.int
Returns the entity's health.int
Sets the entity's maximum healthisDead()
Checks whether this entity is dead.void
setHealth
(int health) Sets the entity's health.void
setMaxHealth
(int maxHealth) Sets the entity's Max Health.void
takeDamage
(int damage) void
Doubles player maximum health when player interacts with a HealthBench.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) Construct a combat Stats Component (Health + Attack System)- Parameters:
health
- initial health (values< 0
are clamped to0
)
-
-
Method Details
-
isDead
Checks whether this entity is dead.An entity is considered dead if its health is less than or equal to zero.
- Returns:
true
if the entity has 0 or less health,false
otherwise
-
getHealth
public int getHealth()Returns the entity's health.- Returns:
- entity's health
-
takeDamage
public void takeDamage(int damage) -
setHealth
public void setHealth(int health) Sets the entity's health. Health is always clamped between 0 and maxHealth.- Parameters:
health
- new health value
-
addHealth
public void addHealth(int health) Adds to the player's health. The amount added can be negative.- Parameters:
health
- health to add
-
setMaxHealth
public void setMaxHealth(int maxHealth) Sets the entity's Max Health. Max Health has a minimum bound of 0.- Parameters:
maxHealth
- the maximum health that an entity can have
-
getMaxHealth
public int getMaxHealth()Sets the entity's maximum health- Returns:
- the entity's maximum health (never negative)
-
upgradeMaxHealth
public void upgradeMaxHealth()Doubles player maximum health when player interacts with a HealthBench. Only applied once.
-