Exemplo n.º 1
0
        public void Heal(int amount)
        {
            var prev = CurrentHealth;

            CurrentHealth = Mathf.Min(CurrentHealth + amount, MaximumHealth);
            Healed?.Invoke(this, new HealedEventArgs(CurrentHealth - prev));
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
 public void HealDamage(int healAmount)
 {
     _healthCurrent += healAmount;
     if (_healthCurrent > _healthMax)
     {
         _healthCurrent = _healthMax;
     }
     Healed.Invoke();
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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
                        )
                    );
            }
        }
Exemplo n.º 7
0
 public void RestoreHealth(float amount)
 {
     //TODO Add BonusHealingReceived & HealingReduced
     Healed?.Invoke(this, new HealedEventArgs(amount));
 }
Exemplo n.º 8
0
 public void Heal()
 {
     Healed.Invoke();
 }
Exemplo n.º 9
0
 public void Heal(int healAmount)
 {
     Healed?.Invoke(this, new HealEventArgs(healAmount));
 }
Exemplo n.º 10
0
 public void Heal(int damageHealed)
 {
     _currentHealth += damageHealed;
     CapHealth();
     Healed?.Invoke();
 }
 private void OnHeal(EventArgs e)
 {
     Healed?.Invoke(this, e);
 }
Exemplo n.º 12
0
 protected virtual void OnHealed()
 {
     Healed?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 13
0
 protected virtual void OnHealed(SourcedHeal heal) => Healed?.Invoke(this, heal);