Example #1
0
 public virtual bool TakeDamage(float damage)
 {
     health -= damage;
     healthBar.SetHealth(health / maxHealth);
     if (health < 0)
     {
         Destroy(this.gameObject);
         return(true);
     }
     return(false);
 }
Example #2
0
    public bool DamageMob(float damage)
    {
        damage *= 1 - reductionPercent;
        damage -= reductionFlat;

        float remainder = 0;

        if (shields > 0)
        {
            shields -= damage;
            damage   = 0;
        }
        if (shields < 0)
        {
            remainder = shields;
            shields   = 0;
        }
        if (damage > 0)
        {
            health -= damage;
        }
        else
        {
            health -= remainder;
        }
        if (health <= 0)
        {
            KillMob();
            return(true);
        }
        else
        {
            healthOrb.SetHealth(health / healthMax);
        }
        return(false);
    }