Пример #1
0
    public void SetHealth(float h)
    {
        currentHealth = h;

        if (isAlive)
        {
            if (h < Mathf.Epsilon)
            {
                Kill();
                return;
            }
        }
        else
        {
            if (h > Mathf.Epsilon)
            {
                isDestroyed = false;
                if (OnResurrect != null)
                {
                    OnResurrect(this);
                }
                m_OnResurrected.Invoke();
            }
        }
        if (OnHealthChanged != null)
        {
            OnHealthChanged(this);
        }
    }
Пример #2
0
 public void Destroy()
 {
     if (OnDestroyed != null)
     {
         OnDestroyed(this);
     }
     m_OnDestroyed.Invoke();
 }
Пример #3
0
 public void Destroy()
 {
     isDestroyed = true;
     Kill();
     if (OnDestroyed != null)
     {
         OnDestroyed(this);
     }
     m_OnDestroyed.Invoke();
 }
Пример #4
0
 void Die()
 {
     if (OnDeath != null)
     {
         OnDeath(this);
     }
     m_OnDeath.Invoke();
     if (deactivateOnDeath)
     {
         gameObject.SetActive(false);
     }
 }