90 lines
4.0 KiB
C#
90 lines
4.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[CreateAssetMenu(fileName = "AoEWithImpactEventAbility", menuName = "RiftMayhem/AbilitySystem/Abilities/Area of Effect With Impact Event Ability", order = 0)]
|
|
public class AreaOfEffectWithImpactEventAbility : AreaOfEffectAbility
|
|
{
|
|
public float impactDelay;
|
|
|
|
private NetworkedAreaOfEffectWithImpactEvent networkedAreaOfEffectWithImpactEvent;
|
|
|
|
|
|
public override void Execute(Taggable user)
|
|
{
|
|
user.GetComponent<Mana>().ChangeValue(-manaCost);
|
|
|
|
if (spawnUnderUser)
|
|
{
|
|
snapshotController = user.GetComponentInChildren<AoERayHitLocationSnapshotController>();
|
|
if (snapshotController == null)
|
|
{
|
|
rot = Quaternion.LookRotation(user.transform.forward);
|
|
}
|
|
else
|
|
{
|
|
rot = Quaternion.LookRotation(user.GetComponentInChildren<AoERayHitLocationSnapshotController>().aoeRayHitLocationSnapshot.position - user.transform.position);
|
|
}
|
|
instantiatedArea = Instantiate(aoePrefab, user.transform.position, rotateOnSpawn ? rot : Quaternion.identity);
|
|
//instantiatedArea.transform.parent = user.transform;
|
|
networkedAreaOfEffectWithImpactEvent = instantiatedArea.GetComponent<NetworkedAreaOfEffectWithImpactEvent>();
|
|
|
|
networkedAreaOfEffectWithImpactEvent.ownerTag = user;
|
|
networkedAreaOfEffectWithImpactEvent.ability = this;
|
|
networkedAreaOfEffectWithImpactEvent.radius = radius;
|
|
networkedAreaOfEffectWithImpactEvent.telegraphDelay = telegraphDelay;
|
|
networkedAreaOfEffectWithImpactEvent.lifeSpan = lifeSpan;
|
|
networkedAreaOfEffectWithImpactEvent.canHitSelf = canHitSelf;
|
|
networkedAreaOfEffectWithImpactEvent.impactDelay = impactDelay;
|
|
|
|
networkedAreaOfEffectWithImpactEvent.Init();
|
|
return;
|
|
}
|
|
snapshotController = user.GetComponentInChildren<AoERayHitLocationSnapshotController>();
|
|
if (snapshotController == null)
|
|
{
|
|
rot = Quaternion.LookRotation(user.transform.forward);
|
|
}
|
|
else
|
|
{
|
|
rot = Quaternion.LookRotation(user.GetComponentInChildren<AoERayHitLocationSnapshotController>().aoeRayHitLocationSnapshot.position - user.transform.position);
|
|
}
|
|
instantiatedArea = Instantiate(aoePrefab, user.GetComponentInChildren<AoERayHitLocationSnapshotController>().aoeRayHitLocationSnapshot.position, rotateOnSpawn ? rot : Quaternion.identity);
|
|
|
|
networkedAreaOfEffectWithImpactEvent = instantiatedArea.GetComponent<NetworkedAreaOfEffectWithImpactEvent>();
|
|
|
|
networkedAreaOfEffectWithImpactEvent.ownerTag = user;
|
|
networkedAreaOfEffectWithImpactEvent.ability = this;
|
|
networkedAreaOfEffectWithImpactEvent.radius = radius;
|
|
networkedAreaOfEffectWithImpactEvent.telegraphDelay = telegraphDelay;
|
|
networkedAreaOfEffectWithImpactEvent.lifeSpan = lifeSpan;
|
|
networkedAreaOfEffectWithImpactEvent.canHitSelf = canHitSelf;
|
|
networkedAreaOfEffectWithImpactEvent.impactDelay = impactDelay;
|
|
|
|
|
|
networkedAreaOfEffectWithImpactEvent.Init();
|
|
|
|
}
|
|
|
|
public override void Execute(Taggable user, Vector3 point)
|
|
{
|
|
user.GetComponent<Mana>().ChangeValue(-manaCost);
|
|
|
|
instantiatedArea = Instantiate(aoePrefab, point, Quaternion.identity);
|
|
|
|
networkedAreaOfEffectWithImpactEvent = instantiatedArea.GetComponent<NetworkedAreaOfEffectWithImpactEvent>();
|
|
|
|
networkedAreaOfEffectWithImpactEvent.ownerTag = user;
|
|
networkedAreaOfEffectWithImpactEvent.ability = this;
|
|
networkedAreaOfEffectWithImpactEvent.radius = radius;
|
|
networkedAreaOfEffectWithImpactEvent.telegraphDelay = telegraphDelay;
|
|
networkedAreaOfEffectWithImpactEvent.lifeSpan = lifeSpan;
|
|
networkedAreaOfEffectWithImpactEvent.canHitSelf = canHitSelf;
|
|
networkedAreaOfEffectWithImpactEvent.impactDelay = impactDelay;
|
|
|
|
|
|
|
|
networkedAreaOfEffectWithImpactEvent.Init();
|
|
}
|
|
}
|