Пример #1
0
    public void ReceiveDamage(int damage, bool cover)
    {
        int dmg = (int)(damage * (cover ? 0.5f : 1));

        Debug.Log(gameObject.name + " Recive " + dmg + "Points of damage!");
        if (shield > 0)
        {
            if (shield > dmg)
            {
                shield -= dmg;
            }
            else
            {
                dmg        -= shield;
                shield      = 0;
                realHealth -= dmg;
                if (realHealth > 0)
                {
                    health = realHealth;
                }
                else
                {
                    health = 0;
                }
            }
        }
        else
        {
            realHealth -= dmg;
            if (realHealth > 0)
            {
                health = realHealth;
            }
            else
            {
                health = 0;
            }
        }
        StartCoroutine(DamageFeedback());
        healthBar.ActualziateHealthBar(health, maxHealth);
    }