52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using Photon.Pun;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
public class NetworkedSlashWithOnHitEvent : NetworkedSlash
|
|
{
|
|
public UnityEvent<PhotonView, Taggable, List<Taggable>> onImpactHappened = new UnityEvent<PhotonView, Taggable, List<Taggable>>();
|
|
|
|
|
|
protected override void CheckSurroundings()
|
|
{
|
|
hits = Physics.OverlapBox(hitBox.transform.position, hitBox.transform.localScale / 2, this.transform.rotation, abilityHitLayer);
|
|
|
|
foreach (Collider collider in hits)
|
|
{
|
|
possibleTarget = collider.GetComponentInParent<PhotonView>();
|
|
if (possibleTarget != null)
|
|
if (possibleTarget == owner) continue;
|
|
|
|
target = collider.GetComponentInParent<Taggable>();
|
|
|
|
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);
|
|
}
|
|
|
|
if (!photonView.IsMine) return;
|
|
|
|
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(owner, ownerTag, targets);
|
|
}
|
|
}
|