started adding enemy factory
This commit is contained in:
@@ -1,22 +1,64 @@
|
||||
using Darkmatter.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
using VContainer;
|
||||
|
||||
namespace Darkmatter.Presentation
|
||||
{
|
||||
public class EnemyMotor : MonoBehaviour
|
||||
public class EnemyMotor : MonoBehaviour, IEnemyPawn
|
||||
{
|
||||
[SerializeField] NavMeshAgent enemyAI;
|
||||
public Transform playerTransform;
|
||||
[SerializeField] private NavMeshAgent enemyAI;
|
||||
[SerializeField] private Transform playerTransform;
|
||||
[SerializeField] private List<Transform> patrolPoints = new List<Transform>();
|
||||
[Inject] private EnemyConfigSO enemyConfig;
|
||||
|
||||
[Header("Enemy Data")]
|
||||
public float walkSpeed = 3f;
|
||||
public float chaseSpeed = 5f;
|
||||
public float visionRange = 15f;
|
||||
public float attackRange = 2f;
|
||||
public Transform PlayerTarget => playerTransform;
|
||||
public NavMeshAgent EnemyAI => enemyAI;
|
||||
public List<Transform> PatrolPoints => patrolPoints;
|
||||
|
||||
private void Start()
|
||||
public float Health { get; set; } = 100;
|
||||
|
||||
public bool isDead { get; set; } = false;
|
||||
|
||||
public event Action<float> OnHealthDecreased;
|
||||
|
||||
public void Die()
|
||||
{
|
||||
enemyAI.SetDestination(playerTransform.position);
|
||||
isDead = true;
|
||||
enemyAI.enabled = false;
|
||||
Invoke(nameof(Hide), 8f);
|
||||
}
|
||||
|
||||
private void Hide()
|
||||
{
|
||||
this.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public Vector3 ReturnMyPos()
|
||||
{
|
||||
return this.transform.position;
|
||||
}
|
||||
|
||||
|
||||
public void SetDestination(Vector3 destination)
|
||||
{
|
||||
enemyAI.SetDestination(destination);
|
||||
}
|
||||
|
||||
public void TakeDamage(float damage)
|
||||
{
|
||||
Health -= damage;
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user