RiftMayhem/Assets/Scripts/AbilitySystem/ProjectileAreaOfEffectOverTimeAbility.cs
2025-02-21 18:35:51 +00:00

87 lines
3.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "ProjectileAreaOfEffectOverTimeAbility", menuName = "RiftMayhem/AbilitySystem/Abilities/Projectile Area Of Effect Over Time Ability", order = 0)]
public class ProjectileAreaOfEffectOverTimeAbility : AreaOfEffectAbility
{
[Header("Projectile:")]
public ProjectileAbility projectileAbility;
[Header("AreaOfEffectOverTime:")]
public float duration;
public bool followUser;
public bool followTarget;
public bool damageFollowingTarget;
private NetworkedProjectileAreaOfEffectOverTimeWithTickEvent networkedAreaOfEffectOverTime;
public override void Execute(Taggable user)
{
SpendResourcesNecessary(user);
if (spawnUnderUser)
{
instantiatedArea = Instantiate(aoePrefab, user.transform.position, Quaternion.identity);
//instantiatedArea.transform.parent = user.transform;
networkedAreaOfEffectOverTime = instantiatedArea.GetComponent<NetworkedProjectileAreaOfEffectOverTimeWithTickEvent>();
SetupValues(user);
networkedAreaOfEffectOverTime.Init();
return;
}
instantiatedArea = Instantiate(aoePrefab, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.position, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.rotation);
networkedAreaOfEffectOverTime = instantiatedArea.GetComponent<NetworkedProjectileAreaOfEffectOverTimeWithTickEvent>();
SetupValues(user);
networkedAreaOfEffectOverTime.Init();
}
public override void Execute(Taggable user, Vector3 point)
{
SpendResourcesNecessary(user);
instantiatedArea = Instantiate(aoePrefab, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.position, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.rotation);
networkedAreaOfEffectOverTime = instantiatedArea.GetComponent<NetworkedProjectileAreaOfEffectOverTimeWithTickEvent>();
SetupValues(user);
networkedAreaOfEffectOverTime.Init();
}
public override void Execute(Taggable user, Transform target)
{
SpendResourcesNecessary(user);
instantiatedArea = Instantiate(aoePrefab, target.position, Quaternion.identity);
networkedAreaOfEffectOverTime = instantiatedArea.GetComponent<NetworkedProjectileAreaOfEffectOverTimeWithTickEvent>();
SetupValues(user);
networkedAreaOfEffectOverTime.Init(target);
}
private void SetupValues(Taggable user)
{
networkedAreaOfEffectOverTime.ownerTag = user;
networkedAreaOfEffectOverTime.ability = this;
networkedAreaOfEffectOverTime.radius = radius;
networkedAreaOfEffectOverTime.telegraphDelay = telegraphDelay;
networkedAreaOfEffectOverTime.lifeSpan = lifeSpan;
networkedAreaOfEffectOverTime.duration = duration;
networkedAreaOfEffectOverTime.followUser = followUser;
networkedAreaOfEffectOverTime.followTarget = followTarget;
networkedAreaOfEffectOverTime.damageFollowingTarget = damageFollowingTarget;
networkedAreaOfEffectOverTime.canHitSelf = canHitSelf;
networkedAreaOfEffectOverTime.projectileAbility = projectileAbility;
}
}