public void TakeDamage(float damage, DamageType type)
    {
        if (state == State.Alive)
        {
            if (type == immunity)
            {
                return;
            }

            if (onHit != null)
            {
                onHit.Invoke(damage);
            }

            health -= (damage / Mathf.Max(1f, resistance));

            EndRegen();

            if (health <= 0f)
            {
                Die();
                hasKnockback = true;
                return;
            }
            else
            {
                StartCoroutine(HitAnimation());

                if (type == DamageType.Explosions && canFallOver && onKnockedOver != null)
                {
                    onKnockedOver.Invoke();
                }
            }

            if (!smokes)
            {
                return;
            }

            if (smokeEffect == null)
            {
                if (healthPercentage <= 0.5f)
                {
                    smokeEffect = EffectFollow.Create("SmokeEffect", smokeCenter);
                }
            }

            if (fireEffect == null)
            {
                if (healthPercentage <= 0.25f)
                {
                    fireEffect = EffectFollow.Create("FireEffect", smokeCenter);
                }
            }
        }
    }
 void EndRegen()
 {
     if (curRegenEffect != null)
     {
         curRegenEffect.End();
         curRegenEffect = null;
     }
     waitTimer = regenWait;
     regening  = false;
 }
    public static EffectFollow Create(string name, Transform parent)
    {
        if (!prefabsSet)
        {
            LoadPrefabs();
        }

        GameObject   newEffect = (GameObject)Instantiate(prefabs[name], parent.position, Quaternion.identity);
        EffectFollow follower  = newEffect.GetComponent <EffectFollow> ();

        follower.Init(parent);
        follower.effectName = name;
        return(follower);
    }
 void StartRegen()
 {
     curRegenEffect = EffectFollow.Create("RegenEffect", transform);
     regening       = true;
 }