public void Heal(int amount) { var prev = CurrentHealth; CurrentHealth = Mathf.Min(CurrentHealth + amount, MaximumHealth); Healed?.Invoke(this, new HealedEventArgs(CurrentHealth - prev)); }
/// <summary> /// Apply healing to the Health. If health value has reached zero, will not work unless allowRevival is true. /// </summary> /// <param name="amount">The amount of healing.</param> /// <returns>The actual healing amount applied.</returns> public virtual float Heal(float amount) { if (enabled && (!dead || allowRevival) && amount > 0) { HealingModifier?.Invoke(ref amount); float prevHealth = health; health += amount; health = Mathf.Min(health, maxHealth); amount = health - prevHealth; SendMessage("OnHeal", amount, SendMessageOptions.DontRequireReceiver); Healed?.Invoke(amount); if (dead) { dead = false; SendMessage("OnRevive", SendMessageOptions.DontRequireReceiver); Revived?.Invoke(); } } else { amount = 0; } return(amount); }
public void HealDamage(int healAmount) { _healthCurrent += healAmount; if (_healthCurrent > _healthMax) { _healthCurrent = _healthMax; } Healed.Invoke(); }
public void SubtractDamage(int damageSubtraction, HitInfo hit) { hit.damageChangeInfo.oldDamage = CurrentDamage; CurrentDamage -= Mathf.Abs(damageSubtraction); CurrentDamage = Mathf.Clamp(CurrentDamage, 0, maxDamage); hit.damageChangeInfo.oldDamage = CurrentDamage; Healed?.Invoke(hit); }
public void AddHealingEffect(PeriodicHealingEffect healingEffect) { void applyHealing() { Healed?.Invoke(this, healingEffect.HealingPerTick); } Coroutine coroutine = _coroutineOwner.StartCoroutine( PeriodicEffectCoroutine( healingEffect.TicksPerSecond, healingEffect.FirstTickImmediately, applyHealing ) ); AddPeriodicEffect(coroutine, _periodicHealingEffects, healingEffect.DurationSeconds); }
public void ToggleSelfHealing() { if (_selfHealing != null) { _coroutineOwner.StopCoroutine(_selfHealing); _selfHealing = null; } else { void applyHealing() { Healed?.Invoke(this, _selfHealingEffect.HealingPerTick); } _selfHealing = _coroutineOwner.StartCoroutine( PeriodicEffectCoroutine( _selfHealingEffect.TicksPerSecond, _selfHealingEffect.FirstTickImmediately, applyHealing ) ); } }
public void RestoreHealth(float amount) { //TODO Add BonusHealingReceived & HealingReduced Healed?.Invoke(this, new HealedEventArgs(amount)); }
public void Heal() { Healed.Invoke(); }
public void Heal(int healAmount) { Healed?.Invoke(this, new HealEventArgs(healAmount)); }
public void Heal(int damageHealed) { _currentHealth += damageHealed; CapHealth(); Healed?.Invoke(); }
private void OnHeal(EventArgs e) { Healed?.Invoke(this, e); }
protected virtual void OnHealed() { Healed?.Invoke(this, EventArgs.Empty); }
protected virtual void OnHealed(SourcedHeal heal) => Healed?.Invoke(this, heal);