2025-08-12 12:39:09 +05:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
[CreateAssetMenu(menuName = "Abilities/Fireball")]
|
|
|
|
public class FireballAbility : Ability
|
|
|
|
{
|
|
|
|
public GameObject projectilePrefab;
|
|
|
|
public float speed = 22f;
|
|
|
|
public float damage = 20f;
|
|
|
|
public float lifeTime = 4f;
|
|
|
|
|
|
|
|
public override void Activate(AbilityUser user)
|
|
|
|
{
|
|
|
|
if (!user || !projectilePrefab) return;
|
|
|
|
|
2025-08-31 17:49:35 +04:00
|
|
|
Vector3 dir = Camera.main.transform.forward;
|
|
|
|
|
|
|
|
//var go = Instantiate(projectilePrefab, user.CastPos(), Quaternion.LookRotation(user.Forward()));
|
|
|
|
var go = Instantiate(projectilePrefab, user.CastPos(), Quaternion.LookRotation(dir));
|
2025-08-12 12:39:09 +05:00
|
|
|
var rb = go.GetComponent<Rigidbody>();
|
2025-08-31 17:49:35 +04:00
|
|
|
if (rb) rb.velocity = dir * speed;
|
2025-08-12 12:39:09 +05:00
|
|
|
|
|
|
|
var dmg = go.GetComponent<ProjectileDamage>();
|
|
|
|
if (!dmg) dmg = go.AddComponent<ProjectileDamage>();
|
|
|
|
dmg.damage = damage;
|
|
|
|
|
|
|
|
Destroy(go, lifeTime);
|
|
|
|
}
|
|
|
|
}
|