platformer
Public Member Functions | Public Attributes | List of all members
UnityPlatformer.CharacterHealth Class Reference

Tracks character health and lives. More...

Inheritance diagram for UnityPlatformer.CharacterHealth:

Public Member Functions

delegate void HurtCallback (Damage dt, CharacterHealth to)
 Callback type for onHurt More...
 
void Start ()
 check missconfiguration and initialization More...
 
void SetInvulnerable (float time)
 Turns a character invulnerable, but still can be killed using Kill More...
 
void SetVulnerable ()
 disable invulnerability More...
 
bool IsInvulnerable ()
 Character is invulnerable? More...
 
void Kill ()
 Kill the character even if it's invulnerable More...
 
void Damage (Damage dmg)
 Try to Damage the Character More...
 
bool Damage (int amount, DamageType dt, CharacterHealth causer=null)
 Try to Damage the Character More...
 
bool Damage (int amount=1, CharacterHealth causer=null)
 Try to Damage the Character More...
 
bool isDead ()
 No healt More...
 
void Heal (int amount=1)
 increse health character if possible maxHealth not reached. Trigger onMaxHealth More...
 
void DisableAllHitBoxes ()
 
void Die ()
 Disable HitBox(es) and DamageType(s) Trigger onDeath More...
 

Public Attributes

Alignment alignment = Alignment.None
 Character alignment More...
 
bool friendlyFire = false
 Can recieve Damage from friends (same alignment) More...
 
int startingHealth = 1
 Health the character will have when game starts More...
 
int maxHealth = 1
 Maximum health (-1 no maximum). NOTE if startingHealth == maxHealth will trigger onMaxHealth on Start. More...
 
int startingLives = 1
 Lives the character starts with (-1 no lives) More...
 
int maxLives = 1
 Maximum lives of the character. 2,147,483,647 is the maximum :) More...
 
float invulnerabilityTimeAfterDamage = 2.0f
 After any Damage how much time the character will be invulnerable to any Damage (0 to disable) More...
 
DamageType immunity = 0
 List of damages that are ignored More...
 
Action onMaxHealth
 Fired when Character heal and now it's at maxHealth More...
 
Action onDamage
 Fired when character is damaged. More...
 
Action onImmunity
 Fired after onDamage and Character is inmmune to given Damage More...
 
HurtCallback onInjured
 This Character health is reduced, will fire after onDamage More...
 
HurtCallback onHurt
 This Character deal damage to other More...
 
Action onHeal
 Display some greenish starts floating around! More...
 
Action onDeath
 Play death animation, turn off the music... those sort of things More...
 
Action onGameOver
 Credits... More...
 
Action onInvulnerabilityStart
 Play that funky music! Quake-damage! More...
 
Action onInvulnerabilityEnd
 Stop that funky music! More...
 
Action onRespawn
 After death when there are lives player can respawn More...
 
int health = 0
 Character health More...
 
int lives = 0
 Character lives More...
 
Character character
 Character owner of this CharacterHealth More...
 

Detailed Description

Tracks character health and lives.

Triggers character damage/death

Member Function Documentation

◆ Damage() [1/3]

void UnityPlatformer.CharacterHealth.Damage ( Damage  dmg)
inline

Try to Damage the Character

◆ Damage() [2/3]

bool UnityPlatformer.CharacterHealth.Damage ( int  amount,
DamageType  dt,
CharacterHealth  causer = null 
)
inline

Try to Damage the Character

◆ Damage() [3/3]

bool UnityPlatformer.CharacterHealth.Damage ( int  amount = 1,
CharacterHealth  causer = null 
)
inline

Try to Damage the Character

triggers onDamage triggers onDeath NOTE this won't trigger onHurtCharacter

◆ Die()

void UnityPlatformer.CharacterHealth.Die ( )
inline

Disable HitBox(es) and DamageType(s) Trigger onDeath

◆ Heal()

void UnityPlatformer.CharacterHealth.Heal ( int  amount = 1)
inline

increse health character if possible maxHealth not reached. Trigger onMaxHealth

◆ HurtCallback()

delegate void UnityPlatformer.CharacterHealth.HurtCallback ( Damage  dt,
CharacterHealth  to 
)

Callback type for onHurt

◆ isDead()

bool UnityPlatformer.CharacterHealth.isDead ( )
inline

No healt

◆ IsInvulnerable()

bool UnityPlatformer.CharacterHealth.IsInvulnerable ( )
inline

Character is invulnerable?

◆ Kill()

void UnityPlatformer.CharacterHealth.Kill ( )
inline

Kill the character even if it's invulnerable

◆ SetInvulnerable()

void UnityPlatformer.CharacterHealth.SetInvulnerable ( float  time)
inline

Turns a character invulnerable, but still can be killed using Kill

NOTE use float.MaxValue for unlimited time

◆ SetVulnerable()

void UnityPlatformer.CharacterHealth.SetVulnerable ( )
inline

disable invulnerability

◆ Start()

void UnityPlatformer.CharacterHealth.Start ( )
inline

check missconfiguration and initialization

Member Data Documentation

◆ alignment

Alignment UnityPlatformer.CharacterHealth.alignment = Alignment.None

Character alignment

◆ character

Character UnityPlatformer.CharacterHealth.character

Character owner of this CharacterHealth

◆ friendlyFire

bool UnityPlatformer.CharacterHealth.friendlyFire = false

Can recieve Damage from friends (same alignment)

◆ health

int UnityPlatformer.CharacterHealth.health = 0

Character health

◆ immunity

DamageType UnityPlatformer.CharacterHealth.immunity = 0

List of damages that are ignored

NOTE: this can give your character super powers! use it with caution!

◆ invulnerabilityTimeAfterDamage

float UnityPlatformer.CharacterHealth.invulnerabilityTimeAfterDamage = 2.0f

After any Damage how much time the character will be invulnerable to any Damage (0 to disable)

◆ lives

int UnityPlatformer.CharacterHealth.lives = 0

Character lives

◆ maxHealth

int UnityPlatformer.CharacterHealth.maxHealth = 1

Maximum health (-1 no maximum). NOTE if startingHealth == maxHealth will trigger onMaxHealth on Start.

◆ maxLives

int UnityPlatformer.CharacterHealth.maxLives = 1

Maximum lives of the character. 2,147,483,647 is the maximum :)

◆ onDamage

Action UnityPlatformer.CharacterHealth.onDamage

Fired when character is damaged.

Will be fired even it the character is inmmune

◆ onDeath

Action UnityPlatformer.CharacterHealth.onDeath

Play death animation, turn off the music... those sort of things

◆ onGameOver

Action UnityPlatformer.CharacterHealth.onGameOver

Credits...

◆ onHeal

Action UnityPlatformer.CharacterHealth.onHeal

Display some greenish starts floating around!

◆ onHurt

HurtCallback UnityPlatformer.CharacterHealth.onHurt

This Character deal damage to other

dt is the Damage dealed to is the CharacterHealth hurted

◆ onImmunity

Action UnityPlatformer.CharacterHealth.onImmunity

Fired after onDamage and Character is inmmune to given Damage

◆ onInjured

HurtCallback UnityPlatformer.CharacterHealth.onInjured

This Character health is reduced, will fire after onDamage

dt is the Damage dealed to is the CharacterHealth that hurt me, if possible, could be null

◆ onInvulnerabilityEnd

Action UnityPlatformer.CharacterHealth.onInvulnerabilityEnd

Stop that funky music!

◆ onInvulnerabilityStart

Action UnityPlatformer.CharacterHealth.onInvulnerabilityStart

Play that funky music! Quake-damage!

NOTE this can be fired many times before onInvulnerabilityEnd

◆ onMaxHealth

Action UnityPlatformer.CharacterHealth.onMaxHealth

Fired when Character heal and now it's at maxHealth

◆ onRespawn

Action UnityPlatformer.CharacterHealth.onRespawn

After death when there are lives player can respawn

◆ startingHealth

int UnityPlatformer.CharacterHealth.startingHealth = 1

Health the character will have when game starts

◆ startingLives

int UnityPlatformer.CharacterHealth.startingLives = 1

Lives the character starts with (-1 no lives)


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