started adding enemy factory

This commit is contained in:
Mausham
2025-12-31 17:14:20 -08:00
parent 3aabc42bf8
commit 8eafd8bb60
130 changed files with 49524 additions and 46086 deletions

View File

@@ -1,30 +0,0 @@
using Darkmatter.Core;
using UnityEngine;
namespace Darkmatter.Presentation
{
public class Enemy : MonoBehaviour, IDamageable
{
public float health = 100f;
public Animator enemyAnimator;
public bool isDead = false;
public void Die()
{
isDead = true;
Debug.Log("Dead");
enemyAnimator.SetLayerWeight(0, 1);
enemyAnimator.SetTrigger("Death");
Destroy(this.gameObject, 5f);
}
public void TakeDamage(float damage)
{ if(isDead) return;
health -= damage;
if (health <= 0) Die();
Debug.Log("Damage Taken");
enemyAnimator.SetLayerWeight(1, 1);
enemyAnimator.SetTrigger("Hit");
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 7cc0904e9eef2eb42860484c3c0d2675

View File

@@ -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);
}
}