RiftMayhem/Assets/Scripts/AbilitySystem/ProjectileAreaOfEffectOverTimeAbility.cs

99 lines
4.1 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;
networkedAreaOfEffectOverTime.projectileSpeed = projectileAbility.projectileSpeed;
networkedAreaOfEffectOverTime.canPierce = projectileAbility.canPierce;
networkedAreaOfEffectOverTime.useSpeedCurve = projectileAbility.useSpeedCurve;
networkedAreaOfEffectOverTime.enableCurving = projectileAbility.enableCurving;
networkedAreaOfEffectOverTime.curveAxis = projectileAbility.curveAxis;
networkedAreaOfEffectOverTime.curveStrength = projectileAbility.curveStrength;
networkedAreaOfEffectOverTime.curveAmplitude = projectileAbility.curveAmplitude;
networkedAreaOfEffectOverTime.enableRicochet = projectileAbility.enableRicochet;
networkedAreaOfEffectOverTime.maxRicochets = projectileAbility.maxRicochets;
networkedAreaOfEffectOverTime.ricochetSpread = projectileAbility.ricochetSpread;
}
}