Eye of the Nile Docs
Everything you need to know to get started!
Loading...
Searching...
No Matches
BossHealth Class Reference

Detailed Description

Functionality of ObjectHealth for bosses. This script inherits from ObjectHealth. What changed:

  • This script updates how full the boss healthbar is.
  • This script sets the display name of the boss above the healthbar.

This script DOES NOT control when the boss healthbar is visible, that is up to the boss behavior scripts.

Documentation updated 12/27/2024

Author
Alexander Art

Public Attributes

BossHealthbarHUD bossHealthbar
 Reference to the boss healthbar HUD script.
 
- Public Attributes inherited from ObjectHealth
UnityEvent OnDeath
 Invokes any subscribed functions when the object dies.
 

Protected Attributes

string bossDisplayName
 The display name of this boss that will appear above the healthbar.
 
- Protected Attributes inherited from ObjectHealth
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).
 

Private Member Functions

void Start ()
 Set the name on the boss healthbar and duplicate ObjectHealth's Start() because this overrides it.
 
void Update ()
 Check for changes in the boss's health and update the healthbar.
 

Private Attributes

int previousHealth
 Used for checking when the health of the boss changes.
 

Additional Inherited Members

- Public Member Functions inherited from ObjectHealth
virtual void ResetHealth ()
 Set currentHealth back to maxHealth.
 
virtual void TakeDamage (int damage)
 If something attacks the object, it will run ObjectHealth.TakeDamage()
 
virtual void TakeDamage (Transform attacker, int damage)
 If something attacks the object, it will run ObjectHealth.TakeDamage() This overload allows for damage particles to come from the direction of the attack.
 
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.

Parameters
damageCountThe amount of times the fire will deal damage before the object stops being on fire.
damageSpeedThe amount of seconds between each round of dealing damage.
damageThe amount of damage to deal each time.

 
void FireImmunity (float seconds)
 Start a coroutine for FireImmunityTimer().
 
int GetMaxHealth ()
 \breif Return the object's max health.
 
- Protected Member Functions inherited from ObjectHealth
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.
 
virtual void FireDamage (int damage)
 Similar functionality to TakeDamage(), but no invincibility is triggered and no animation players. Used when on fire.
 
virtual void Die ()
 Triggered when the object runs out of health. Plays a death sound and animation, drops souls/god souls, and disables the object.
 
IEnumerator FireImmunityTimer (float seconds)
 Make the object immune to fire for the given amount of seconds.
 
- Properties inherited from ObjectHealth
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.
 
- Events inherited from ObjectHealth
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.
 

Member Function Documentation

◆ Start()

void BossHealth.Start ( )
private

Set the name on the boss healthbar and duplicate ObjectHealth's Start() because this overrides it.

◆ Update()

void BossHealth.Update ( )
private

Check for changes in the boss's health and update the healthbar.

Member Data Documentation

◆ bossDisplayName

string BossHealth.bossDisplayName
protected

The display name of this boss that will appear above the healthbar.

◆ bossHealthbar

BossHealthbarHUD BossHealth.bossHealthbar

Reference to the boss healthbar HUD script.

◆ previousHealth

int BossHealth.previousHealth
private

Used for checking when the health of the boss changes.


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