RiftMayhem/Assets/Scripts/Networking/NetworkedSlashWithOnHitEvent.cs
Pedro Gomes e1081a2bf4 Necromancer and Minions update
- Necromancer class playable
- Savage minion ability & npc
- Mage minion ability & npc
- rogue minion ability & npc
- warrior minion ability & npc
- golem minion ability & npc
- minion abilities
- Class resource (used to automatically summon minions based on the amount of souls drained, in case of necromancer)
- class resource spender (auto cast from priority list)
- class resource regen instant effect option
2024-07-22 16:46:13 +01:00

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);
}
}