68 lines
2.2 KiB
C#
68 lines
2.2 KiB
C#
using Code.Configs;
|
|
using Reflex.Attributes;
|
|
using UnityEngine;
|
|
|
|
namespace Code.Gameplay.Enemies
|
|
{
|
|
public class Fog : BaseEnemy
|
|
{
|
|
[Inject]
|
|
private void Construct(FogConfig fogConfig)
|
|
{
|
|
Damage = fogConfig.damage;
|
|
AttackCooldown = fogConfig.attackCooldown;
|
|
|
|
DetectionRange = fogConfig.detectionRange;
|
|
AttackRange = fogConfig.attackRange;
|
|
|
|
Speed = fogConfig.speed;
|
|
|
|
IsStunnable = fogConfig.isStunnable;
|
|
StunDuration = fogConfig.stunDuration;
|
|
|
|
UsesIdleMovement = fogConfig.usesIdleMovement;
|
|
IdleWanderRadius = fogConfig.idleWanderRadius;
|
|
IdleMoveDurationMin = fogConfig.idleMoveDurationMin;
|
|
IdleMoveDurationMax = fogConfig.idleMoveDurationMax;
|
|
IdleMoveDurationMin = fogConfig.idleMoveDurationMin;
|
|
IdleMoveDurationMax = fogConfig.idleMoveDurationMax;
|
|
IdlePauseDurationMin = fogConfig.idlePauseDurationMin;
|
|
IdlePauseDurationMax = fogConfig.idlePauseDurationMax;
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
} |