/// <summary> /// Subtracts the given value from health and triggers death if health reaches 0 /// </summary> /// <param name="damage">Value to be subtracted</param> public void ApplyDamage(float damage) { health -= damage; if (health <= 0) { StartDeath(); healthBar?.SetHealth(0); } else { healthBar?.SetHealth(health); } }
//updates UI private void HealthChange(object sender, HealthController.OnHealthChangeEventArgs e) { if (healthUI) { healthUI.SetHealth(e.currentHealth); } }
public void LoseHealth() { if ((health != 0) && (remainingInvincibility <= 0.0f)) { healthBar.SetHealth(--health); if (health == 0) { GameMode.Instance.OnPlayerDeath(); } else { StartInvincibility(); } } }
void CheckHP() { HPBar.SetHealth(CurrentHP); if (CurrentHP <= 0) { Dies(); } else { return; } }
public void UpdateDynamicAttributesUI(DynamicAttributeContainer container) { foreach (var attribute in container.dynamicAttributes) { if (attribute.dynamicType == DynamicAttributeType.Health) { healthBar.SetHealth(attribute.currentValue); healthBar.SetMaxHealth(attribute.maxValue); } if (attribute.dynamicType == DynamicAttributeType.Mana) { manaBar.SetCurrentMana(attribute.currentValue); manaBar.SetMaxMana(attribute.maxValue); } if (attribute.dynamicType == DynamicAttributeType.Coin) { coinUI.SetValue(attribute.currentValue); } } }
void Update() { healthBar.SetHealth(currentHealth); currentInvincibilityFrames -= Time.deltaTime; //invFrames updater }