- Fixed issue on projectile hit events that triggered multiple times. - Implemented % costs for health and mana - Updated key binding UI slots to show health costs if present - New Necromancer projectile AoEOverTime ability: Bonestorm. - New Vamp/Cultist/Satanist summon ability: Bloody Shadow.
104 lines
3.1 KiB
C#
104 lines
3.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>>();
|
|
|
|
public UnityEvent<PhotonView, Taggable, List<Taggable>> onTargetHitByProjectile = new UnityEvent<PhotonView, Taggable, List<Taggable>>();
|
|
|
|
NetworkedAntiProjectile possibleBlock;
|
|
|
|
protected List<Taggable> processedTargets = new List<Taggable>();
|
|
protected List<Taggable> projectileTargets = new List<Taggable>();
|
|
|
|
private void Update()
|
|
{
|
|
if (!photonView.IsMine) return;
|
|
|
|
if (waitingForDestroy) return;
|
|
|
|
this.transform.position += this.transform.forward * projectileAbility.projectileSpeed * Time.deltaTime;
|
|
}
|
|
|
|
protected override void OnTickPerformed()
|
|
{
|
|
if (targets.Count > 0)
|
|
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;
|
|
|
|
//Debug.Log($"TT[{Time.frameCount}] Past validation checks for {target.name}");
|
|
|
|
if (processedTargets.Contains(target)) return;
|
|
|
|
processedTargets.Add(target);
|
|
|
|
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;
|
|
}
|
|
|
|
//Debug.Log($"TT[{Time.frameCount}] About to process effects");
|
|
|
|
projectileTargets.Clear();
|
|
|
|
projectileTargets.Add(target);
|
|
|
|
foreach (BaseEffect effect in projectileAbility.abilityEffects)
|
|
{
|
|
//Debug.Log($"TT[{Time.frameCount}] Applying effect: {effect.name}");
|
|
effect.ApplyEffect(ownerTag, projectileTargets);
|
|
}
|
|
|
|
if(projectileTargets.Count > 0)
|
|
{
|
|
//Debug.Log($"TT[{Time.frameCount}] OnProjectileHit {projectileTargets.Count}");
|
|
onTargetHitByProjectile.Invoke(owner, ownerTag, projectileTargets);
|
|
}
|
|
|
|
if (!projectileAbility.canPierce)
|
|
{
|
|
waitingForDestroy = true;
|
|
StartCoroutine(DelayedDestroy());
|
|
}
|
|
}
|
|
}
|