52 lines
1.3 KiB
C#
52 lines
1.3 KiB
C#
using Photon.Pun;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
public class NetworkedAreaOfEffectWithImpactEvent : NetworkedAreaOfEffect
|
|
{
|
|
public float impactDelay;
|
|
|
|
public UnityEvent<PhotonView, Taggable> onImpactHappened = new UnityEvent<PhotonView, Taggable>();
|
|
|
|
public override void Init()
|
|
{
|
|
if (photonView.IsMine)
|
|
{
|
|
photonView.RPC(nameof(RPC_RemoteInit), RpcTarget.Others, AbilityIndexer.Instance.Abilities.IndexOf(ability));
|
|
|
|
StartCoroutine(ApplyTelegraphDelay(impactDelay));
|
|
}
|
|
}
|
|
|
|
[PunRPC]
|
|
protected override void RPC_RemoteInit(int abilityIndex)
|
|
{
|
|
ability = (AreaOfEffectWithImpactEventAbility)AbilityIndexer.Instance.Abilities[abilityIndex];
|
|
}
|
|
|
|
protected override IEnumerator ApplyTelegraphDelay(float delay)
|
|
{
|
|
effectVisual.SetActive(true);
|
|
|
|
yield return new WaitForSeconds(impactDelay);
|
|
|
|
CheckSurroundings();
|
|
}
|
|
|
|
protected override void ApplyArea()
|
|
{
|
|
|
|
}
|
|
|
|
protected override void CheckSurroundings()
|
|
{
|
|
base.CheckSurroundings(); //TODO: spread the total value over ticks, for now just apply the instant effect every tick, manage tick values on effect applied
|
|
|
|
onImpactHappened.Invoke(owner, ownerTag);
|
|
|
|
StartCoroutine(SelfDestruct());
|
|
}
|
|
}
|