42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using UnityEngine;
|
|
|
|
namespace Code.Gameplay.Enemies
|
|
{
|
|
public class FogEnemy : BaseEnemy
|
|
{
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
|
|
if (agent == null) return;
|
|
agent.enabled = false;
|
|
Destroy(agent);
|
|
}
|
|
|
|
protected override void HandleMovement()
|
|
{
|
|
if (!Player) return;
|
|
|
|
var direction = (Player.transform.position - transform.position).normalized;
|
|
transform.position += direction * (speed * Time.deltaTime);
|
|
}
|
|
|
|
protected override void HandleAttack()
|
|
{
|
|
if (!Player || PlayerHealth == null) return;
|
|
|
|
var distance = Vector3.Distance(transform.position, Player.transform.position);
|
|
|
|
if (!(distance < attackRange)) return;
|
|
|
|
PlayerHealth.GetDamage(PlayerHealth.MaxHealthPoints);
|
|
base.ApplyEffectsToPlayer();
|
|
}
|
|
|
|
private void OnDrawGizmosSelected()
|
|
{
|
|
Gizmos.color = new Color(0.3f, 0.3f, 0.8f, 0.4f);
|
|
Gizmos.DrawSphere(transform.position, attackRange);
|
|
}
|
|
}
|
|
} |