private void Damage(Collider[] colliders, Attackable origin, ICollection <Attackable> targets) { foreach (Collider collider in colliders) { Attackable attackable = collider.GetComponent <Attackable>(); if (attackable == null || attackable == origin) { continue; } Attackable attackableRoot = attackable.GetAttackableRoot(); if (!targets.Contains(attackableRoot) && attackable.CanDamage()) { attackable.Damage(damageAmount, damageType); targets.Add(attackableRoot); } } }
public void DoDamage(float damageRatio, ICollection <Attackable> targets) { for (int i = 0; i < weaponParts.Length; ++i) { foreach (Collider collider in GetCollidersInBoxCollider(weaponParts[i].collider)) { Attackable attackable = collider.GetComponent <Attackable>(); if (attackable == null || attackable == (Attackable)wielder) { continue; } attackable = attackable.GetAttackableRoot(); if (!targets.Contains(attackable) && attackable.CanDamage()) { targets.Add(attackable); attackable.Damage(damageRatio * weaponParts[i].damageAmount, weaponParts[i].damageType); } } } }