Beispiel #1
0
    public void ApplyDamage(int dmg, Attack.DamageTypes damageType)
    {
        this.hitsTaken++;

        int damageAfterModifiers = dmg;

        for (int i = 0; i < this.modifiers.Count; i++)
        {
            damageAfterModifiers = this.modifiers[i].Apply(damageAfterModifiers, damageType);
        }

        this.HP = Mathf.Max(this.HP - damageAfterModifiers, 0);

        // Fire events
        if (this.HP <= 0)
        {
            if (Destroyed != null)
            {
                Destroyed.Invoke(this);
            }
        }
        else
        {
            if (TookDamage != null)
            {
                TookDamage.Invoke(this, damageAfterModifiers, this.HP);
            }
        }
    }
Beispiel #2
0
 public int Apply(int damage, Attack.DamageTypes dmgType)
 {
     return(damage + this.increase);
 }
 public int Apply(int damage, Attack.DamageTypes dmgType)
 {
     return(Mathf.RoundToInt(damage * this.multiplier));
 }
Beispiel #4
0
 public int Apply(int damage, Attack.DamageTypes dmgType)
 {
     return(Mathf.Max(damage - this.reduction, 0));
 }