Bandidos
Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
com.mygdx.game.components.HealthComponent Class Reference
Inheritance diagram for com.mygdx.game.components.HealthComponent:
com.mygdx.game.engine.entities.components.BaseEntityComponent com.mygdx.game.engine.events.EventDispatcher

Public Member Functions

 HealthComponent (float health)
 
float getNormalizedHealth ()
 
float damage (float amount)
 
float heal (float amount)
 
void kill ()
 
boolean isAlive ()
 
float getHealth ()
 
float getMaxHealth ()
 
void awake ()
 
- Public Member Functions inherited from com.mygdx.game.engine.entities.components.BaseEntityComponent
EngineTween startTweenOnComponent (Tween tween, TweenStartType tweenStartType)
 
Timeline startTimelineOnComponent (Timeline timeline, boolean updateInGameTime)
 
EngineTween doFloat (TweenableFloat floatToTween, float newValue, float duration, TweenStartType tweenStartType)
 
void stopAllComponentTweens ()
 
void initialize (BaseEntity parentEntity)
 
BaseEntity getParentOfComponent ()
 
boolean isActive ()
 
boolean isDestroyed ()
 
void setActiveState (boolean activeState)
 
void destroy ()
 
void update (float deltaTime)
 
abstract void awake ()
 
- Public Member Functions inherited from com.mygdx.game.engine.events.EventDispatcher
void addEventListener (String type, IEventReceiver listeningClass)
 
void dispatchEvent (Event event)
 
void removeEventListener (String type, IEventReceiver listener)
 
boolean hasEventListener (String type)
 
ArrayList< ListenerItemgetAllListeners ()
 
void destroyAllListeners ()
 
void clean ()
 

Static Public Attributes

static final String EVENT_HEALTH_HEALED = "EventHealthHealed"
 
static final String EVENT_HEALTH_DAMAGED = "EventHealthDamaged"
 
static final String EVENT_HEALTH_DIED = "EventHealthDied"
 

Protected Member Functions

void updated (float deltaTime)
 
void destroyed ()
 
void activeStateChanged ()
 
- Protected Member Functions inherited from com.mygdx.game.engine.entities.components.BaseEntityComponent
abstract void updated (float deltaTime)
 
abstract void destroyed ()
 
abstract void activeStateChanged ()
 

Detailed Description

This component holds all the info for health. It can be damaged and healed. It also dispatches events on these occasions

Author
Ramses Di Perna

Constructor & Destructor Documentation

◆ HealthComponent()

com.mygdx.game.components.HealthComponent.HealthComponent ( float  health)

This will set the maximum health and current health for the component.

Parameters
health

Member Function Documentation

◆ activeStateChanged()

void com.mygdx.game.components.HealthComponent.activeStateChanged ( )
protected

◆ awake()

void com.mygdx.game.components.HealthComponent.awake ( )

◆ damage()

float com.mygdx.game.components.HealthComponent.damage ( float  amount)

Damages the component, affecting the health amount in a negative way. This will also trigger the EVENT_HEALTH_DAMAHED and, when the component has no health left, EVENT_HEALTH_DIED The component can not be damaged when it is already dead.

Parameters
amountto take off of the health
Returns
new current health

◆ destroyed()

void com.mygdx.game.components.HealthComponent.destroyed ( )
protected

◆ getHealth()

float com.mygdx.game.components.HealthComponent.getHealth ( )

Returns the current health value of the component

Returns
Current health

◆ getMaxHealth()

float com.mygdx.game.components.HealthComponent.getMaxHealth ( )

Returns the maximum health this component can have

Returns
The Max Health.

◆ getNormalizedHealth()

float com.mygdx.game.components.HealthComponent.getNormalizedHealth ( )

Returns the normalized value of the current health in relation to the MaxHealth

Returns

◆ heal()

float com.mygdx.game.components.HealthComponent.heal ( float  amount)

Heals the component, affecting the health amount in a positive way. This will also trigger the EVENT_HEALTH_HEALED. The component can not be healed when it is dead or when it has full health.

Parameters
amountto add to the current health
Returns
new current health

◆ isAlive()

boolean com.mygdx.game.components.HealthComponent.isAlive ( )

Returns whether the component still has health left.

Returns
If the health is not below or equal to 0. If it is it returns false, else it returns true.

◆ kill()

void com.mygdx.game.components.HealthComponent.kill ( )

Calls the Damage() method with enough damage to kill the component.

◆ updated()

void com.mygdx.game.components.HealthComponent.updated ( float  deltaTime)
protected

Member Data Documentation

◆ EVENT_HEALTH_DAMAGED

final String com.mygdx.game.components.HealthComponent.EVENT_HEALTH_DAMAGED = "EventHealthDamaged"
static

This event type is fired by the HealthComponent when it is damaged

◆ EVENT_HEALTH_DIED

final String com.mygdx.game.components.HealthComponent.EVENT_HEALTH_DIED = "EventHealthDied"
static

This event type is fired by the HealthComponent when it is killed

◆ EVENT_HEALTH_HEALED

final String com.mygdx.game.components.HealthComponent.EVENT_HEALTH_HEALED = "EventHealthHealed"
static

This event type is fired by the HealthComponent when it is healed


The documentation for this class was generated from the following file: