95 lines
3.6 KiB
C#
95 lines
3.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[CreateAssetMenu(fileName = "ProjectileAbility", menuName = "RiftMayhem/AbilitySystem/Abilities/Projectile Ability", order = 0)]
|
|
public class ProjectileAbility : BaseAbility
|
|
{
|
|
public GameObject projectilePrefab;
|
|
|
|
public float projectileSpeed;
|
|
public float lifeSpan;
|
|
public bool canPierce;
|
|
public bool canHitSelf;
|
|
|
|
[Header("Movement Behaviour")]
|
|
public AnimationCurve speedOverLifetime = AnimationCurve.Linear(0, 1, 1, 1);
|
|
public bool useSpeedCurve = false;
|
|
public bool enableCurving = false;
|
|
public Vector3 curveAxis = Vector3.up;
|
|
public float curveStrength = 1f;
|
|
public float curveAmplitude = 45f;
|
|
|
|
public bool enableRicochet = false;
|
|
public int maxRicochets = 1;
|
|
public float ricochetSpread = 10f;
|
|
|
|
|
|
private GameObject instantiatedProjectile;
|
|
private NetworkedProjectile networkedProjectile;
|
|
|
|
public override void Execute(Taggable user)
|
|
{
|
|
base.Execute(user);
|
|
|
|
//Debug.Log($"Player {user.name} casted {this.name} and spent {manaCost} mana.");
|
|
|
|
instantiatedProjectile = Instantiate(projectilePrefab, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.position, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.rotation);
|
|
|
|
networkedProjectile = instantiatedProjectile.GetComponent<NetworkedProjectile>();
|
|
|
|
SetupProjectileInstance(user);
|
|
|
|
networkedProjectile.Init();
|
|
}
|
|
|
|
public override void Execute(Taggable user, Vector3 point)
|
|
{
|
|
base.Execute(user, point);
|
|
|
|
//Debug.Log($"Player {user.name} casted {this.name} and spent {manaCost} mana.");
|
|
|
|
instantiatedProjectile = Instantiate(projectilePrefab, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.position, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.rotation);
|
|
|
|
networkedProjectile = instantiatedProjectile.GetComponent<NetworkedProjectile>();
|
|
|
|
SetupProjectileInstance(user);
|
|
|
|
networkedProjectile.Init();
|
|
}
|
|
|
|
public override void Execute(Taggable user, Transform target)
|
|
{
|
|
base.Execute(user, target);
|
|
|
|
//Debug.Log($"Player {user.name} casted {this.name} and spent {manaCost} mana.");
|
|
|
|
instantiatedProjectile = Instantiate(projectilePrefab, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.position, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.rotation);
|
|
|
|
networkedProjectile = instantiatedProjectile.GetComponent<NetworkedProjectile>();
|
|
|
|
SetupProjectileInstance(user);
|
|
|
|
networkedProjectile.Init();
|
|
}
|
|
|
|
protected virtual void SetupProjectileInstance(Taggable user)
|
|
{
|
|
networkedProjectile.speed = projectileSpeed;
|
|
networkedProjectile.ownerTag = user;
|
|
networkedProjectile.ability = this;
|
|
networkedProjectile.lifeSpan = lifeSpan;
|
|
networkedProjectile.canPierce = canPierce;
|
|
networkedProjectile.canHitSelf = canHitSelf;
|
|
networkedProjectile.speedOverLifetime = speedOverLifetime;
|
|
networkedProjectile.useSpeedCurve = useSpeedCurve;
|
|
networkedProjectile.enableCurving = enableCurving;
|
|
networkedProjectile.curveAxis = curveAxis;
|
|
networkedProjectile.curveStrength = curveStrength;
|
|
networkedProjectile.curveAmplitude = curveAmplitude;
|
|
networkedProjectile.enableRicochet = enableRicochet;
|
|
networkedProjectile.maxRicochets = maxRicochets;
|
|
networkedProjectile.ricochetSpread = ricochetSpread;
|
|
}
|
|
}
|