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.
health: the current health of the entity
baseAttack: the base attack of the entity
fullHealth: the full health of the entity
state: the current state of the entity (full health above 66%, half health above 33%, low health below 33%)
drops: the items that the entity drops when it dies
closeRangeAbilities: the Melee abilities (close range) of the entity
longRangeAbilities: the Projectile abilities (long range) of the entity
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCombatStatsComponent
(int health, int baseAttack) CombatStatsComponent
(int health, int baseAttack, ArrayList<Currency> drops, ArrayList<Melee> closeRangeAbilities, ArrayList<ProjectileConfig> longRangeAbilities) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addHealth
(int health) Adds to the player's health.void
Change the state of the enemy based on the healthdrop()
int
Returns the entity's base attack damage.int
Returns the entity's health.int
Returns the entity's fullHealth value (note that this does not influence the ability to set its actual health)getState()
Return the state of the enemy fullHealth: above 66% of full health midHealth: above 33% of full health lowHealth: below 33% of full healthReturn a close range attack if the target is within range, else return a long range attackvoid
hit
(CombatStatsComponent attacker) void
Decrease the health of the entity based on the damage provided.isDead()
Returns true if the entity's has 0 health, otherwise false.If there are long range attacks provided, return a random one, else return nullint
pickRandom
(ArrayList pickFrom) Picks a random number from range 0 to the size of the list provided.void
setBaseAttack
(int attack) Sets the entity's attack damage.void
setHealth
(int health) Sets the entity's health.void
setMaxHealth
(int newMaxHealth) Sets the entity's fullHealth variable.void
updateHealth
(int setTo) Update the health of the enemy.withinRange
(Entity target) Check if the target is within range of any of the close range attacks.Methods inherited from class com.csse3200.game.components.Component
create, dispose, earlyUpdate, getEntity, 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
-
getMaxHealth
public int getMaxHealth()Returns the entity's fullHealth value (note that this does not influence the ability to set its actual health)- Returns:
- The entity's fullHealth variable
-
setMaxHealth
public void setMaxHealth(int newMaxHealth) Sets the entity's fullHealth variable. Intended for when the entity's maximum health must be changed after creation, like upgrading a turret's HP.- Parameters:
newMaxHealth
- The new value fullHealth should be set to
-
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
Decrease the health of the entity based on the damage provided. -
hit
-
pickRandom
Picks a random number from range 0 to the size of the list provided. -
drop
-
longRangeAttack
If there are long range attacks provided, return a random one, else return null -
withinRange
Check if the target is within range of any of the close range attacks. Return a list of close range attacks which can be used -
getWeapon
Return a close range attack if the target is within range, else return a long range attack -
changeState
public void changeState()Change the state of the enemy based on the health -
getState
Return the state of the enemy fullHealth: above 66% of full health midHealth: above 33% of full health lowHealth: below 33% of full health -
updateHealth
public void updateHealth(int setTo) Update the health of the enemy. Used in WaveFactory to increase difficulty of enemies
-