39 lines
No EOL
1,018 B
C#
39 lines
No EOL
1,018 B
C#
using Core.Extensions;
|
|
using UnityEngine;
|
|
|
|
public class EnemyAbility : Ability
|
|
{
|
|
[SerializeField] private float cooldownDelta;
|
|
[SerializeField] private bool willLookAtPlayer;
|
|
protected virtual void Start()
|
|
{
|
|
cooldown += Random.Range(-cooldownDelta, cooldownDelta);
|
|
currentCooldown = Random.Range(0, cooldown);
|
|
}
|
|
|
|
public override bool TryAbility()
|
|
{
|
|
if (willLookAtPlayer)
|
|
{
|
|
direction = WaveManager.instance.GetRandomPlayerPoint();
|
|
transform.Lookat2D(direction);
|
|
}
|
|
return base.TryAbility();
|
|
}
|
|
public void ShootProjectile(Projectile projectile, Vector3 location, float speed, bool aimed)
|
|
{
|
|
Projectile 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;
|
|
}
|
|
}
|
|
} |