示例#1
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);
        }
 public virtual bool Revive(float revPercent)
 {
     health          = (maxHealth * revPercent);
     effectiveHealth = health;
     Revived.Invoke();
     return(true);
 }
    public virtual bool Revive(int healthLeft)
    {
        health          = healthLeft;
        effectiveHealth = health;
        Revived.Invoke();

        return(true);
    }
示例#4
0
 /// <summary>Makes object alive again.</summary>
 internal void Revive()
 {
     if (IsDeleted)
     {
         IsDeleted = false;
         OnRevived();
         Revived?.Invoke(this, EventArgs.Empty);
     }
 }
示例#5
0
 protected virtual void OnRevived()
 {
     Revived?.Invoke(this, EventArgs.Empty);
 }