ReisenYoumuOuting/Assets/Scripts/Projectiles/DelayedAimShot.cs

42 lines
767 B
C#

using System;
using UnityEngine;
public class DelayedAimShot : Projectile
{
[SerializeField] private float aimDelay;
[SerializeField] private float aimedSpeed;
[SerializeField] private float movementDelay;
private Vector3 GetAimedDirection()
{
return (WaveManager.instance.GetRandomPlayerPoint() - transform.position).normalized;
}
private void Update()
{
if (aimDelay > 0)
{
aimDelay -= Time.deltaTime;
if (aimDelay <= 0)
{
speed = aimedSpeed;
if (movementDelay <= 0)
{
direction = GetAimedDirection();
}
else
{
direction = Vector2.zero;
}
}
}
else if (movementDelay > 0)
{
movementDelay -= Time.deltaTime;
if (movementDelay <= 0)
{
direction = GetAimedDirection();
}
}
}
}