Class CombatStatsComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.combat.CombatStatsComponent
- All Implemented Interfaces:
com.badlogic.gdx.utils.Json.Serializable
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addHealth
(int health) Adds to the player's health.void
create()
Called when the entity is created and registered.void
Early update called once per frame of the game, before update().int
Returns the entity's base attack damage.int
Returns the entity's health.void
void
hit
(CombatStatsComponent attacker) void
hitFromEntity
(Entity attacker) boolean
isDead()
Returns true if the entity's has 0 health, otherwise false.void
read
(com.badlogic.gdx.utils.Json json, com.badlogic.gdx.utils.JsonValue jsonValue) void
setBaseAttack
(int attack) Sets the entity's attack damage.void
setHealth
(int health) Sets the entity's health.void
write
(com.badlogic.gdx.utils.Json json) Methods inherited from class com.csse3200.game.components.Component
dispose, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
CombatStatsComponent
public CombatStatsComponent(int health, int baseAttack)
-
-
Method Details
-
create
public void create()Description copied from class:Component
Called when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished. -
isDead
public boolean 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
-
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
-
handleDeath
public void handleDeath() -
hitFromEntity
-
earlyUpdate
public void earlyUpdate()Description copied from class:Component
Early update called once per frame of the game, before update(). Use this only for logic that must run before other updates, such as physics. Not called if component is disabled.- Overrides:
earlyUpdate
in classComponent
-
write
public void write(com.badlogic.gdx.utils.Json json) -
read
public void read(com.badlogic.gdx.utils.Json json, com.badlogic.gdx.utils.JsonValue jsonValue)
-