Exemplo n.º 1
0
    public void Damage(int damageAmount)
    {
        for (int i = hpList.Count - 1; i >= 0; i--)
        {
            HP hp = hpList[i];
            if (damageAmount > hp.GetFragmentAmount())
            {
                damageAmount -= hp.GetFragmentAmount();
                hp.Damage(hp.GetFragmentAmount());
            }
            else
            {
                hp.Damage(damageAmount);
                break;
            }
        }

        if (OnDamaged != null)
        {
            OnDamaged(this, EventArgs.Empty);
        }

        if (IsDead())
        {
            if (OnDead != null)
            {
                OnDead(this, EventArgs.Empty);
            }
        }
    }