public override void ExplodeCore() { Vector3 explosionPos = transform.position; Collider[] victims = Physics.OverlapSphere(explosionPos, effectiveRadius, LayerMask.GetMask("Player")); foreach (var victim in victims) { if (ItemUtils.IsPlayer(victim.gameObject)) { PlayerManager playerManager = victim.GetComponent <PlayerManager>(); playerManager.OnHeal(centerHealing); } } }
public virtual void OnExplode() { Vector3 explosionPos = transform.position; Collider[] victims = Physics.OverlapSphere(explosionPos, effectiveRadius, LayerMask.GetMask("Default", "Player")); foreach (var victim in victims) { if (ItemUtils.IsPlayer(victim.gameObject)) { PlayerManager playerManager = victim.GetComponent <PlayerManager>(); playerManager.OnAttacked(Mathf.Lerp(centerDamage, 0, Vector3.Distance(victim.transform.position, explosionPos) / effectiveRadius)); playerManager.AddImpact(victim.transform.position - explosionPos, impactForce); } else { victim.GetComponent <Rigidbody>()?.AddExplosionForce(impactForce, explosionPos, effectiveRadius, 2); } } }