added enemy factory and pool
This commit is contained in:
@@ -9,8 +9,9 @@ namespace Darkmatter.Presentation
|
||||
{
|
||||
public class EnemyMotor : MonoBehaviour, IEnemyPawn
|
||||
{
|
||||
public static event Action<IEnemyPawn> OnEnemyDead;
|
||||
public GameObject GameObject => this.gameObject;
|
||||
[SerializeField] private NavMeshAgent enemyAI;
|
||||
[Inject] private EnemyConfigSO enemyConfig;
|
||||
|
||||
public Transform PlayerTarget { get; private set; }
|
||||
public NavMeshAgent EnemyAI => enemyAI;
|
||||
@@ -24,6 +25,7 @@ namespace Darkmatter.Presentation
|
||||
|
||||
public void Die()
|
||||
{
|
||||
if(isDead) return;
|
||||
isDead = true;
|
||||
enemyAI.enabled = false;
|
||||
Invoke(nameof(Hide), 8f);
|
||||
@@ -31,7 +33,7 @@ namespace Darkmatter.Presentation
|
||||
|
||||
private void Hide()
|
||||
{
|
||||
this.gameObject.SetActive(false);
|
||||
OnEnemyDead?.Invoke(this);
|
||||
}
|
||||
|
||||
public Vector3 ReturnMyPos()
|
||||
@@ -51,14 +53,6 @@ namespace Darkmatter.Presentation
|
||||
OnHealthDecreased?.Invoke(Health);
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
Gizmos.color = Color.yellow;
|
||||
Gizmos.DrawWireSphere(transform.position, enemyConfig.visionRange);
|
||||
Gizmos.color = Color.red;
|
||||
Gizmos.DrawWireSphere(transform.position, enemyConfig.attackRange);
|
||||
}
|
||||
|
||||
public void InitializeFromFactory(Transform player, List<Transform> patrolPoints)
|
||||
{
|
||||
this.PlayerTarget = player;
|
||||
|
||||
Reference in New Issue
Block a user