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().ChangeValue(-manaCost); if (spawnUnderUser) { snapshotController = user.GetComponentInChildren(); if (snapshotController == null) { rot = Quaternion.LookRotation(user.transform.forward); } else { rot = Quaternion.LookRotation(user.GetComponentInChildren().aoeRayHitLocationSnapshot.position - user.transform.position); } instantiatedArea = Instantiate(aoePrefab, user.transform.position, rotateOnSpawn ? rot : Quaternion.identity); //instantiatedArea.transform.parent = user.transform; networkedAreaOfEffectWithImpactEvent = instantiatedArea.GetComponent(); 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(); if (snapshotController == null) { rot = Quaternion.LookRotation(user.transform.forward); } else { rot = Quaternion.LookRotation(user.GetComponentInChildren().aoeRayHitLocationSnapshot.position - user.transform.position); } instantiatedArea = Instantiate(aoePrefab, user.GetComponentInChildren().aoeRayHitLocationSnapshot.position, rotateOnSpawn ? rot : Quaternion.identity); networkedAreaOfEffectWithImpactEvent = instantiatedArea.GetComponent(); 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().ChangeValue(-manaCost); instantiatedArea = Instantiate(aoePrefab, point, Quaternion.identity); networkedAreaOfEffectWithImpactEvent = instantiatedArea.GetComponent(); networkedAreaOfEffectWithImpactEvent.ownerTag = user; networkedAreaOfEffectWithImpactEvent.ability = this; networkedAreaOfEffectWithImpactEvent.radius = radius; networkedAreaOfEffectWithImpactEvent.telegraphDelay = telegraphDelay; networkedAreaOfEffectWithImpactEvent.lifeSpan = lifeSpan; networkedAreaOfEffectWithImpactEvent.canHitSelf = canHitSelf; networkedAreaOfEffectWithImpactEvent.impactDelay = impactDelay; networkedAreaOfEffectWithImpactEvent.Init(); } }