64 lines
No EOL
1.7 KiB
C#
64 lines
No EOL
1.7 KiB
C#
using Core.Extensions;
|
|
using UnityEngine;
|
|
|
|
public class CirnoIceBall : EnemyAbility
|
|
{
|
|
[Header("Ice Ball")]
|
|
[SerializeField] private IceBall iceBall;
|
|
|
|
private IceBall iceballInstance;
|
|
[SerializeField] private float timeUntilShatter;
|
|
private float currentTimeOnSpawn;
|
|
[Header("Effects")]
|
|
[SerializeField] private float sweepDissipationTime;
|
|
private float currentDissipationTime;
|
|
[SerializeField] private GameObject swordSweepEffect;
|
|
protected override void AbilityEffects()
|
|
{
|
|
iceballInstance = ShootProjectile(iceBall, WaveManager.instance.GetRandomPlayerPoint(), iceBall.speed, false);
|
|
currentTimeOnSpawn = timeUntilShatter;
|
|
}
|
|
|
|
protected override void Update()
|
|
{
|
|
base.Update();
|
|
if (currentTimeOnSpawn > 0)
|
|
{
|
|
currentTimeOnSpawn -= Time.deltaTime;
|
|
if (currentTimeOnSpawn <= 0)
|
|
{
|
|
transform.Lookat2D(WaveManager.instance.GetRandomPlayerPoint());
|
|
swordSweepEffect.SetActive(true);
|
|
currentDissipationTime = sweepDissipationTime;
|
|
iceballInstance.Shatter();
|
|
}
|
|
}
|
|
|
|
if (currentDissipationTime > 0)
|
|
{
|
|
currentDissipationTime -= Time.deltaTime;
|
|
if (currentDissipationTime <= 0)
|
|
{
|
|
swordSweepEffect.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
private IceBall ShootProjectile(IceBall projectile, Vector3 location, float speed, bool aimed)
|
|
{
|
|
IceBall newProjectile = Instantiate(projectile, origin.position, Quaternion.identity);
|
|
Vector3 projectileDirection = location;
|
|
if (aimed)
|
|
{
|
|
projectileDirection = WaveManager.instance.GetRandomPlayerPoint();
|
|
}
|
|
newProjectile.transform.Lookat2D(projectileDirection);
|
|
newProjectile.damage = power;
|
|
newProjectile.tag = tag;
|
|
if (speed > 0f)
|
|
{
|
|
newProjectile.speed = speed;
|
|
}
|
|
|
|
return newProjectile;
|
|
}
|
|
} |