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

36 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "AntiProjectileAbility", menuName = "RiftMayhem/AbilitySystem/Abilities/Anti Projectile Ability", order = 0)]
public class AntiProjectileAbility : BaseAbility
{
public GameObject antiProjectilePrefab;
public float duration;
public bool followUser;
public bool breakOnHit;
private GameObject instantiatedProjectile;
private NetworkedAntiProjectile networkedAntiProjectile;
public override void Execute(Taggable user)
{
base.Execute(user);
//Debug.Log($"Player {user.name} casted {this.name} and spent {manaCost} mana.");
instantiatedProjectile = Instantiate(antiProjectilePrefab, user.transform.position, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.rotation);
networkedAntiProjectile = instantiatedProjectile.GetComponent<NetworkedAntiProjectile>();
networkedAntiProjectile.duration = duration;
networkedAntiProjectile.ownerTag = user;
networkedAntiProjectile.ability = this;
networkedAntiProjectile.followUser = followUser;
networkedAntiProjectile.breakOnHit = breakOnHit;
networkedAntiProjectile.Init();
}
}