using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; public class NetworkedSlashWithOnHitEvent : NetworkedSlash { public UnityEvent> onImpactHappened = new UnityEvent>(); protected override void CheckSurroundings() { hits = Physics.OverlapBox(hitBox.transform.position, hitBox.transform.localScale / 2, this.transform.rotation, abilityHitLayer); foreach (Collider collider in hits) { target = collider.GetComponentInParent(); if (target == null) continue; if (!target.IsValidTarget(ability.targettingTags)) continue; hitPositionCorrected = target.transform.position; hitPositionCorrected.y = this.transform.position.y; onTargetHit.Invoke(hitPositionCorrected); //Debug.Log("hit collider, added target: " + target.name); targets.Add(target); } foreach (BaseEffect effect in ability.abilityEffects) { effect.ApplyEffect(ownerTag, targets); } if (regenHealthOnHit) ownerHealth.ChangeValue(healthOnHit * targets.Count); if (regenManaOnHit) ownerMana.ChangeValue(manaOnHit * targets.Count); onImpactHappened.Invoke(ownerTag, targets); } }