![]() |
Eye of the Nile Docs
Everything you need to know to get started!
|
Functionality of ObjectHealth, specifically for the player. This script inherits from ObjectHealth. Here are the key changes:
Documentation updated 8/30/2024
Public Member Functions | |||||||
override void | TakeDamage (Transform attacker, int damage) | ||||||
Apply damage to the player. If something attacks the player, it will run PlayerHealth.TakeDamage(). See detailed view for key differences between this an ObjectHealth.TakeDamage(), as well as the steps this function takes. | |||||||
void | HealInstant (int healValue) | ||||||
Instantly heals the player. | |||||||
int | GetHealth () | ||||||
Returns the amount of health the player currently has. | |||||||
void | InvokeHealthChange () | ||||||
Checks if the player's health is above the max health, and if so, corrects it. Also invokes onPlayerHealthChange. Used to update the player's health when changed from outside the script. | |||||||
![]() | |||||||
virtual void | ResetHealth () | ||||||
Set currentHealth back to maxHealth. | |||||||
virtual void | TakeDamage (int damage) | ||||||
If something attacks the object, it will run ObjectHealth.TakeDamage() | |||||||
IEnumerator | SetOnFire (int damageCount, float damageSpeed, int damage) | ||||||
Starts damaging the object (with FireDamage()) repeatedly. A fire sprite will appear over the object while it's on fire.
| |||||||
void | FireImmunity (float seconds) | ||||||
Start a coroutine for FireImmunityTimer(). | |||||||
int | GetMaxHealth () | ||||||
\breif Return the object's max health. | |||||||
Protected Member Functions | |
override void | FireDamage (int damage) |
Similar functionality to TakeDamage(), but no invincibility is triggered and no animation players. Used when on fire. | |
override void | Die () |
Runs when the player dies to stop gameplay and run AfterDeath(). Runs an animation, disables collision, physics, and player movement, and starts a corountine for AfterDeath(). | |
![]() | |
IEnumerator | Invincibility () |
Makes object invincible for invincibleDuration seconds. Toggles transparency every invincibleFlash seconds. | |
void | ToggleTransparency (bool isOn) |
Toggles the reduced opacity of the sprite that is used to create the flashing effect when invincible. | |
IEnumerator | FireImmunityTimer (float seconds) |
Make the object immune to fire for the given amount of seconds. | |
Private Member Functions | |
void | OnEnable () |
Subscribe to health potion used event. | |
void | OnDisable () |
Unsubscribe from health potion used event. | |
void | Awake () |
Initialize references and invincibleFlash. Start/restart healing without delay. | |
void | Start () |
Set the current health of the player to the data manager's copy of it, and invoke onPlayerHealthChange. | |
IEnumerator | AfterDeath () |
After the player has died, load Anubis.unity and renable critical components. See detailed view for steps. | |
void | StartHealingCoroutine (bool withDelay=true) |
Stop any ongoing healAfterDamage coroutines and start a new one. | |
IEnumerator | healAfterDamage (float delay, float speed, int amount) |
Wait delay seconds, then heal the player by amount every speed seconds. GOes until full health or coroutine is cancelled. | |
Private Attributes | |
DataManager | dataManager |
Reference to the data manager. | |
Player Stats | |
These variables are retrieved from the PlayerStatHolder component, rather than being stored in here. (see StatsAE for more info) | |
PlayerStatHolder | PStats [get, private set] |
int | MaxHealth [get] |
The maximum health of the player. | |
int | DamageResistance [get] |
The amount of damage resistance the player currently has. This value is subtracted from any amount of non-fire damage the player takes. If the resulting number is <= 0, no damage is done at all. | |
int | FireResistance [get] |
The amount of fire reistance the player currently has. The value is subtracted from any amount of fire damage the player takes. If the resulting number is <= 0, no damage is done at all. | |
Dying and Post-Death | |
Information related to the the transition to Anubis.unity after the player dies, and what joke Anubis should tell. | |
string | currentDeathMessage [get, private set] |
The current joke for Anubis to read after the player dies. If the attacking object doesn't have a CustomDeathMessage component, this will either be set to [DEFAULT] or [FIRE]. | |
float | deadFadeDelay = 1f |
float | deadFadeLength = 1f |
The amount of time given for the fade to black animation to play when loading Anubis.unity after death, in seconds. | |
string | deathSceneName = "Anubis" |
The name of the scene to load after the player dies (Anubis.unity). | |
string | defaultDeathMessage = "[DEFAULT]" |
If currentDeathMessage is set to this, AnubisJokeTextbox will know to read from the default list of jokes. | |
string | fireDeathMessage = "[FIRE]" |
Healing | |
The player slowly heals after taking damage. These are variables related to that. | |
float | healDelay = 5f |
float | healSpeed = 0.2f |
How many seconds should be between each health increase when healing. | |
int | healAmount = 1 |
How much to heal the player by when healing. | |
Coroutine | healingCoroutine |
Reference to the coroutine responsible for healing the player over time. | |
Events | |
When these events occur, other scripts subscribed to these events can be notified and trigger their functionality | |
static Action | onPlayerDeath |
static Action | onPlayerRespawn |
Triggers any subscribes functions when the player respawns. | |
static Action< int > | onPlayerDamage |
Triggers any subscribes functions when the player takes damage. | |
static Action< int > | onPlayerHealthChange |
Triggers any subscribes functions when the player's health changes. | |
static Action< string > | deathMessageChange |
Triggers any subscribes functions when the player's custom death message changes. | |
Additional Inherited Members | |
![]() | |
UnityEvent | OnDeath |
Invokes any subscribed functions when the object dies. | |
![]() | |
SpriteRenderer | sRenderer |
Reference to the object’s sprite renderer. | |
Animator | animator |
Transform | hurtEffect |
SpriteRenderer | onFireSprite |
EventReference | deathSfxName |
Reference to the sound effect the object should play when it dies. Nothing will play if left blank. | |
bool | enableDamageParticles = true |
If enabled, the object will spawn the given hurtEffect particles when taking damage. | |
bool | disableColliderOnDeath = true |
If enabled, the object's Collider2D component will be disabled when it dies. | |
bool | disableRigidbodyOnDeath = true |
If enabled, the object's Rigidbody2D component will be disabled when it dies. | |
bool | destroyOnDeath = false |
If enabled, the object will be destroyed when it dies. | |
int | maxHealth = 100 |
The maximum health the object can have. | |
int | soulsDroppedOnDeath = 0 |
The amount of souls the object should grant the player upon death. To disable, set to <= 0. | |
int | godSoulsDroppedOnDeath = 0 |
The amount of god souls the object should grant the player upon death. To disable, set to <= 0. | |
bool | canBeInvincible = false |
If enabled, the object will be invincible for a short duration after taking damage (invincibility frames). | |
float | invincibleDuration = 3f |
In seconds, how long invincibility lasts for after taking damage. | |
float | flashDuration = 0.25f |
In seconds, how often the sprite should swap between being opaque and transparent (creating a flashing effect). | |
WaitForSeconds | invincibleFlash |
The WaitForSeconds variable that is used to implement flashDuration. | |
bool | isInvincible = false |
If the object is currently invincible. | |
bool | canBeOnFire = true |
Whether or not the object can be set on fire. | |
bool | onFire = false |
Whether or not the object is currently on fire. | |
bool | fireImmune = false |
Whether or not the object currently has immunity to fire (usually from an ability). | |
![]() | |
bool | IsDead [get] |
The object is dead if the currentHealth falls to 0. | |
int | currentHealth [get, protected set] |
The amount of health the object currently has. | |
![]() | |
static Action< int > | soulsDropped |
Triggered when the object dies (if soulsDroppedOnDeath > 0), telling the DataManager that the amount of souls the player has collected has increased. | |
static Action< int > | godSoulsDropped |
Triggered when the object dies (if godSoulsDroppedOnDeath > 0), telling the DataManager that the amount of god souls the player has collected has increased. | |
|
private |
After the player has died, load Anubis.unity and renable critical components. See detailed view for steps.
Steps:
|
private |
Initialize references and invincibleFlash. Start/restart healing without delay.
|
protectedvirtual |
Runs when the player dies to stop gameplay and run AfterDeath(). Runs an animation, disables collision, physics, and player movement, and starts a corountine for AfterDeath().
Reimplemented from ObjectHealth.
|
protectedvirtual |
Similar functionality to TakeDamage(), but no invincibility is triggered and no animation players. Used when on fire.
damage | The amount of damage being delt to the player. |
Reimplemented from ObjectHealth.
int PlayerHealth.GetHealth | ( | ) |
Returns the amount of health the player currently has.
|
private |
Wait delay seconds, then heal the player by amount every speed seconds. GOes until full health or coroutine is cancelled.
void PlayerHealth.HealInstant | ( | int | healValue | ) |
Instantly heals the player.
healValue | Amount of health to heal the player by. |
void PlayerHealth.InvokeHealthChange | ( | ) |
Checks if the player's health is above the max health, and if so, corrects it. Also invokes onPlayerHealthChange. Used to update the player's health when changed from outside the script.
|
private |
Unsubscribe from health potion used event.
|
private |
Subscribe to health potion used event.
|
private |
Set the current health of the player to the data manager's copy of it, and invoke onPlayerHealthChange.
|
private |
Stop any ongoing healAfterDamage coroutines and start a new one.
|
virtual |
Apply damage to the player. If something attacks the player, it will run PlayerHealth.TakeDamage(). See detailed view for key differences between this an ObjectHealth.TakeDamage(), as well as the steps this function takes.
Key differences between this an ObjectHealth.TakeDamage():
Steps:
attacker | Reference to the object that is attacking the player. |
damage | The amount of damage being delt to the player. |
Reimplemented from ObjectHealth.
|
private |
Reference to the data manager.
|
private |
The amount of time to wait after death before loading Anubis.unity, in seconds.
|
private |
The amount of time given for the fade to black animation to play when loading Anubis.unity after death, in seconds.
|
private |
The name of the scene to load after the player dies (Anubis.unity).
|
private |
If currentDeathMessage is set to this, AnubisJokeTextbox will know to read from the default list of jokes.
|
private |
If currentDeathMessage is set to this, AnubisJokeTextbox will know to read from the fire list of jokes (as in fire related. They are fire jokes though).
|
private |
How much to heal the player by when healing.
|
private |
How long (in seconds) to wait after taking damage to start healing.
|
private |
Reference to the coroutine responsible for healing the player over time.
|
private |
How many seconds should be between each health increase when healing.
|
getprivate set |
The current joke for Anubis to read after the player dies. If the attacking object doesn't have a CustomDeathMessage component, this will either be set to [DEFAULT] or [FIRE].
|
get |
The amount of damage resistance the player currently has. This value is subtracted from any amount of non-fire damage the player takes. If the resulting number is <= 0, no damage is done at all.
|
get |
The amount of fire reistance the player currently has. The value is subtracted from any amount of fire damage the player takes. If the resulting number is <= 0, no damage is done at all.
|
get |
The maximum health of the player.
|
getprivate set |
Reference to the PlayerStatHolder itself. Holds various information that ability stat modifiers (StatsAE) can modify.
|
static |
Triggers any subscribes functions when the player's custom death message changes.
|
static |
Triggers any subscribes functions when the player takes damage.
|
static |
Triggers any subscribes functions when the player dies.
|
static |
Triggers any subscribes functions when the player's health changes.
|
static |
Triggers any subscribes functions when the player respawns.