![]() |
Platformer Pro
2.3.2
A platform game kit for Unity.
|
Tracks character health and triggers character death. More...
Public Member Functions | |
virtual void | Init (Character character) |
Init with the specified character. More... | |
virtual void | ResetHealth () |
Reset the health back to its starting value More... | |
virtual void | Heal (int amount) |
Heal the character by the specified amount. More... | |
virtual void | SetInvulnerable (float time) |
Makes the character invulnerable for the specified time. More... | |
virtual void | SetInvulnerable () |
Makes the character invulnerable for the specified time. More... | |
virtual void | SetVulnerable () |
Makes the character invulnerable for the specified time. More... | |
virtual void | Damage (int amount) |
Damage the character by the specified amount. More... | |
virtual void | Damage (DamageInfo info) |
Damage the character with the specified damage information. This is the preferred method of receiving damage as it allows the hazard and hit direction to be processed (for example you could have immunity or damage reduction for a certain hazard). More... | |
virtual void | Kill () |
Kills the character. More... | |
virtual void | Kill (DamageInfo info) |
Kills the character. More... | |
override void | ApplySaveData (object t) |
Applies the save data to the object. More... | |
override System.Type | SavedObjectType () |
Get the type of object this Persistable saves. More... | |
override void | ResetSaveData () |
Resets the save data back to default. More... | |
![]() | |
virtual System.Type[] | GetExtraTypes () |
Support complex object serialisation by passing additional types to seralizer. More... | |
![]() | |
virtual void | Validate (PlatformerProMonoBehaviour myTarget) |
Override this method if you want to provide custom validation. The actual code should be surrounded by the if UNITY_EDITOR / endif directive. More... | |
Public Attributes | |
int | startingHealth |
Health the character starts with. More... | |
int | maxHealth |
Maximum health of the character. More... | |
int | startingLives |
Lives the character starts with. Use 0 for no lives. More... | |
int | maxLives |
Maximum lives of the character. More... | |
float | invulnerableTime |
How long the character is invulnerable to damage after being hit. More... | |
DamageImmunity[] | damageImmunity |
The damage immunity. More... | |
DeathAction[] | deathActions |
What do we do on death. More... | |
bool | skipDamageAnimationOnDeath |
Should we not play a damage animation if we die (instead we might go straight to death animation). More... | |
bool | skipDeathActionsOnGameOver |
Should we do the death actions on game over or go straight to GameOver actions More... | |
bool | sendEventsOnZeroDamage |
If true send damage events even when damage amount is zero. More... | |
bool | saveHealthBetweenLevels |
If true send damage events even when damage amount is zero. More... | |
![]() | |
bool | usePersistenceDefaults = true |
Should we use the persistence defaults or override with our own values. More... | |
bool | enablePersistence = true |
Should we enable persistence. More... | |
bool | saveOnAnyChange |
Save whenever this value changes (Note: not supported by all objects). More... | |
PersistenceResetType | persistenceType |
When do we reset persistence? More... | |
Static Public Attributes | |
const string | UniqueDataIdentifier = "CharacterHealth.Lives" |
The player preference identifier. More... | |
![]() | |
const string | BasePlayerPrefId = "PP.Persistent." |
The base player preference identifier. More... | |
Protected Member Functions | |
virtual void | OnHealed (int amount) |
Raises the healed event. More... | |
virtual void | OnDamaged (DamageInfo info) |
Raises the damaged event. More... | |
virtual void | OnDied (DamageInfo info) |
Raises the died event. More... | |
virtual void | OnGameOver () |
Raises the game over event. More... | |
virtual void | OnGainLives (int amount) |
Raises the gain lives event. More... | |
virtual void | OnMaxValuesUpdated () |
Raises the max values updated event. More... | |
override void | ConfigureEventListeners () |
Init this instance. More... | |
virtual void | UpdateMaxHealth () |
virtual void | DoUpdateMaxHealth () |
virtual void | DoDeath (DamageInfo info) |
Do the death actions More... | |
virtual void | DoGameOver (DamageInfo info) |
End the game More... | |
override void | PhaseChange (object sender, GamePhaseEventArgs e) |
Handle a change of game phase, look for persistence event and apply. More... | |
virtual IEnumerator | DoDeathAction (DeathAction action, DamageInfo info) |
Does a death action. More... | |
![]() | |
virtual void | OnLoaded () |
Raises the loaded event. More... | |
virtual void | DoPendingSaves (object sender, PersistenceEventArgs e) |
Trigger any pending saves. More... | |
virtual void | HandleRespawn (object sender, CharacterEventArgs e) |
Handle a change of game phase, look for persistence event and apply. More... | |
virtual void | HandleWillExitScene (object sender, SceneEventArgs e) |
Handles the will exit scene event More... | |
virtual void | HandleGameOver (object sender, CharacterEventArgs e) |
Handles the game over event More... | |
virtual void | HandleDied (object sender, DamageInfoEventArgs e) |
Handles the died event. More... | |
Protected Attributes | |
int | health |
Characters current health. More... | |
int | lives |
Characters current lives. More... | |
float | invulnerableTimer |
Timer for invulnerability. Character is invulnerable when this is greater than zero. More... | |
Character | character |
Cached Character reference More... | |
bool | dying |
If we are dying ignore damage messages. More... | |
DamageInfoEventArgs | damageEventArgs |
Cached copy of damage event args to save on allocations. More... | |
bool | updateMaxHealthThisFrame |
Checks if we have calculated max health this frame. We only do this once per frame. More... | |
int | lastCalculatedMaxHealth |
Tracks value of last calculated max health which includes More... | |
![]() | |
bool | loaded |
Have we loaded the data yet? More... | |
bool | readyToSave |
Are we ready to save on the next save tick? More... | |
Persistable | latestSaveData |
Data to save when we trigger the next save tick. More... | |
Properties | |
override Character | Character [get, set] |
Gets the character reference. More... | |
virtual bool | IsInvulnerable [get] |
Is the character currently invulnerable? More... | |
virtual int? | CurrentHealth [get, set] |
Gets the current health More... | |
virtual int | MaxHealth [get, set] |
Gets or sets the max health More... | |
virtual int | MaxLives [get, set] |
Gets or sets the max lives More... | |
virtual float | CurrentHealthAsPercentage [get] |
Gets a value representing the current health as a percentage between 0 (none) and 1 (full). More... | |
virtual int | CurrentLives [get, set] |
Gets the current number of lives. More... | |
override object | SaveData [get] |
Gets the data to save. More... | |
override string | Identifier [get] |
Get a unique identifier to use when saving the data (for example this could be used for part of the file name or player prefs name). More... | |
![]() | |
virtual string | PlayerPrefsIdentifier [get] |
The player preference identifier. More... | |
virtual bool | EnablePersistence [get] |
Gets the value for persistence type taking in to account defaults. More... | |
virtual PersistenceResetType | PersistenceType [get] |
Gets the value for persistence type taking in to account defaults. More... | |
virtual bool | SaveOnChange [get] |
Gets the value for save on change type taking in to account defaults. More... | |
abstract Character | Character [get, set] |
Gets the character. More... | |
abstract object | SaveData [get] |
Gets the data to save. More... | |
abstract string | Identifier [get] |
Get a unique identifier to use when saving the data (for example this could be used for part of the file name or player prefs name). More... | |
![]() | |
virtual string | Header [get] |
Gets the header string used to describe the component. More... | |
virtual string | DocLink [get] |
Gets a link to documentation site. More... | |
virtual string | VideoLink [get] |
Gets a link to a youtube video. More... | |
virtual string | Deprecated [get] |
If non-null this component is deprecated. The string shows a message indicating how it should be replaced. More... | |
![]() | |
Character | Character [get, set] |
Get the character. More... | |
Events | |
System.EventHandler< HealedEventArgs > | Healed |
Event for health gain. More... | |
System.EventHandler< DamageInfoEventArgs > | Damaged |
Event for damage. More... | |
System.EventHandler< DamageInfoEventArgs > | Died |
Event for death. More... | |
System.EventHandler< CharacterEventArgs > | GameOver |
Event for game over. More... | |
System.EventHandler< HealedEventArgs > | GainLives |
Event for health gain. More... | |
System.EventHandler< HealedEventArgs > | MaxValuesUpdated |
Event for when max lives or health changes. More... | |
![]() | |
System.EventHandler< EmptyEventArgs > | Loaded |
Sent when this persistable is loaded. More... | |
Additional Inherited Members | |
![]() | |
static void | Save (Persistable p) |
Save the given persistable. More... | |
static void | SaveXml (Persistable p) |
Save the given persistable in XML format. More... | |
static void | SaveBinary (Persistable p) |
Save the given persistable in XML format. More... | |
static void | Load (Persistable p) |
Load the given persistable. More... | |
static void | Reset (Persistable p) |
Resets the given persistable. More... | |
![]() | |
static object | LoadSavedDataXml (Persistable p) |
Does the actual load and returns raw object. More... | |
static object | LoadSavedDataBinary (Persistable p) |
Does the actual load and returns raw object. More... | |
Tracks character health and triggers character death.
|
virtual |
Applies the save data to the object.
Implements PlatformerPro.Persistable.
|
protectedvirtual |
Init this instance.
Reimplemented from PlatformerPro.Persistable.
|
virtual |
Damage the character with the specified damage information. This is the preferred method of receiving damage as it allows the hazard and hit direction to be processed (for example you could have immunity or damage reduction for a certain hazard).
info | The damage info. |
|
virtual |
Damage the character by the specified amount.
amount | Amount. |
|
protectedvirtual |
Do the death actions
|
protectedvirtual |
Does a death action.
action | Action. |
|
protectedvirtual |
End the game
|
protectedvirtual |
|
virtual |
Heal the character by the specified amount.
amount | Amount. |
|
virtual |
Init with the specified character.
character | Character. |
|
virtual |
Kills the character.
|
virtual |
Kills the character.
|
protectedvirtual |
Raises the damaged event.
info | Info. |
|
protectedvirtual |
Raises the died event.
info | Info. |
|
protectedvirtual |
Raises the gain lives event.
amount | Amount. |
|
protectedvirtual |
Raises the game over event.
info | Info. |
|
protectedvirtual |
Raises the healed event.
amount | Amount healed. |
|
protectedvirtual |
Raises the max values updated event.
|
protectedvirtual |
Handle a change of game phase, look for persistence event and apply.
sender | Sender. |
e | E. |
Reimplemented from PlatformerPro.Persistable.
|
virtual |
Reset the health back to its starting value
|
virtual |
Resets the save data back to default.
Implements PlatformerPro.Persistable.
|
virtual |
Get the type of object this Persistable saves.
Implements PlatformerPro.Persistable.
|
virtual |
Makes the character invulnerable for the specified time.
time | How long the cahracter is unvulnerable for. |
|
virtual |
Makes the character invulnerable for the specified time.
time | How long the cahracter is unvulnerable for. |
|
virtual |
Makes the character invulnerable for the specified time.
time | How long the cahracter is unvulnerable for. |
|
protectedvirtual |
|
protected |
Cached copy of damage event args to save on allocations.
DamageImmunity [] PlatformerPro.CharacterHealth.damageImmunity |
The damage immunity.
DeathAction [] PlatformerPro.CharacterHealth.deathActions |
What do we do on death.
|
protected |
If we are dying ignore damage messages.
|
protected |
Characters current health.
float PlatformerPro.CharacterHealth.invulnerableTime |
How long the character is invulnerable to damage after being hit.
|
protected |
Timer for invulnerability. Character is invulnerable when this is greater than zero.
|
protected |
Tracks value of last calculated max health which includes
|
protected |
Characters current lives.
int PlatformerPro.CharacterHealth.maxHealth |
Maximum health of the character.
int PlatformerPro.CharacterHealth.maxLives |
Maximum lives of the character.
bool PlatformerPro.CharacterHealth.saveHealthBetweenLevels |
If true send damage events even when damage amount is zero.
bool PlatformerPro.CharacterHealth.sendEventsOnZeroDamage |
If true send damage events even when damage amount is zero.
bool PlatformerPro.CharacterHealth.skipDamageAnimationOnDeath |
Should we not play a damage animation if we die (instead we might go straight to death animation).
bool PlatformerPro.CharacterHealth.skipDeathActionsOnGameOver |
Should we do the death actions on game over or go straight to GameOver actions
int PlatformerPro.CharacterHealth.startingHealth |
Health the character starts with.
int PlatformerPro.CharacterHealth.startingLives |
Lives the character starts with. Use 0 for no lives.
|
static |
The player preference identifier.
|
protected |
Checks if we have calculated max health this frame. We only do this once per frame.
|
getset |
Gets the character reference.
The character.
|
getset |
Gets the current health
|
get |
Gets a value representing the current health as a percentage between 0 (none) and 1 (full).
|
getset |
Gets the current number of lives.
|
get |
Get a unique identifier to use when saving the data (for example this could be used for part of the file name or player prefs name).
The identifier.
|
get |
Is the character currently invulnerable?
The character.
|
getset |
Gets or sets the max health
|
getset |
Gets or sets the max lives
|
get |
Gets the data to save.
System.EventHandler<DamageInfoEventArgs> PlatformerPro.CharacterHealth.Damaged |
Event for damage.
System.EventHandler<DamageInfoEventArgs> PlatformerPro.CharacterHealth.Died |
Event for death.
System.EventHandler<HealedEventArgs> PlatformerPro.CharacterHealth.GainLives |
Event for health gain.
System.EventHandler<CharacterEventArgs> PlatformerPro.CharacterHealth.GameOver |
Event for game over.
System.EventHandler<HealedEventArgs> PlatformerPro.CharacterHealth.Healed |
Event for health gain.
System.EventHandler<HealedEventArgs> PlatformerPro.CharacterHealth.MaxValuesUpdated |
Event for when max lives or health changes.