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

79 lines
3.0 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;
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>();
networkedProjectile.speed = projectileSpeed;
networkedProjectile.ownerTag = user;
networkedProjectile.ability = this;
networkedProjectile.lifeSpan = lifeSpan;
networkedProjectile.canPierce = canPierce;
networkedProjectile.canHitSelf = canHitSelf;
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>();
networkedProjectile.speed = projectileSpeed;
networkedProjectile.ownerTag = user;
networkedProjectile.ability = this;
networkedProjectile.lifeSpan = lifeSpan;
networkedProjectile.canPierce = canPierce;
networkedProjectile.canHitSelf = canHitSelf;
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>();
networkedProjectile.speed = projectileSpeed;
networkedProjectile.ownerTag = user;
networkedProjectile.ability = this;
networkedProjectile.lifeSpan = lifeSpan;
networkedProjectile.canPierce = canPierce;
networkedProjectile.canHitSelf = canHitSelf;
networkedProjectile.Init();
}
}