- new Projectile + Area of effect over time with tick event implemented - New Tornado projectile+AoEOverTime ability for Barb/Naturalist
78 lines
2.1 KiB
C#
78 lines
2.1 KiB
C#
using Photon.Pun;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
public class NetworkedProjectileAreaOfEffectOverTimeWithTickEvent : NetworkedAreaOfEffectOverTime
|
|
{
|
|
[Header("Visuals")]
|
|
[SerializeField] private GameObject hitParticlesPrefab;
|
|
|
|
public ProjectileAbility projectileAbility;
|
|
|
|
public UnityEvent<PhotonView, Taggable, List<Taggable>> onTickHappened = new UnityEvent<PhotonView, Taggable, List<Taggable>>();
|
|
|
|
NetworkedAntiProjectile possibleBlock;
|
|
|
|
private void Update()
|
|
{
|
|
if (!photonView.IsMine) return;
|
|
|
|
if (waitingForDestroy) return;
|
|
|
|
this.transform.position += this.transform.forward * projectileAbility.projectileSpeed * Time.deltaTime;
|
|
}
|
|
|
|
protected override void OnTickPerformed()
|
|
{
|
|
onTickHappened.Invoke(owner, ownerTag, targets);
|
|
}
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (waitingForDestroy) return;
|
|
|
|
possibleTarget = other.GetComponentInParent<PhotonView>();
|
|
if (possibleTarget != null)
|
|
{
|
|
if (!canHitSelf)
|
|
if (possibleTarget == owner) return;
|
|
}
|
|
|
|
target = other.GetComponentInParent<Taggable>();
|
|
|
|
if (target == null) return;
|
|
|
|
if (!target.IsValidTarget(projectileAbility.targettingTags)) return;
|
|
|
|
hitPositionCorrected = target.transform.position;
|
|
hitPositionCorrected.y = this.transform.position.y;
|
|
onTargetHit.Invoke(hitPositionCorrected);
|
|
|
|
if (!photonView.IsMine) return;
|
|
|
|
possibleBlock = target.GetComponentInParent<NetworkedAntiProjectile>();
|
|
if (possibleBlock != null)
|
|
{
|
|
waitingForDestroy = true;
|
|
|
|
possibleBlock.SendBlockNotice();
|
|
|
|
StartCoroutine(DelayedDestroy());
|
|
return;
|
|
}
|
|
|
|
foreach (BaseEffect effect in projectileAbility.abilityEffects)
|
|
{
|
|
effect.ApplyEffect(ownerTag, new List<Taggable> { target });
|
|
}
|
|
|
|
if (!projectileAbility.canPierce)
|
|
{
|
|
waitingForDestroy = true;
|
|
StartCoroutine(DelayedDestroy());
|
|
}
|
|
}
|
|
}
|