started adding enemy factory
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using Darkmatter.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Presentation
|
||||
{
|
||||
public class EnemyAnimController : HumonoidAnim, IEnemyAnimController
|
||||
{
|
||||
private readonly int walkHash = Animator.StringToHash("walk");
|
||||
private readonly int chaseHash = Animator.StringToHash("chase");
|
||||
private readonly int attackHash = Animator.StringToHash("attack");
|
||||
private readonly int deadHash = Animator.StringToHash("dead");
|
||||
|
||||
public void PlayWalkAnim(bool value)
|
||||
{
|
||||
animator.SetBool(walkHash, value);
|
||||
}
|
||||
|
||||
public void PlayAttackAnim(bool value)
|
||||
{
|
||||
animator.SetBool(attackHash, value);
|
||||
}
|
||||
|
||||
public void PlayeChaseAnim(bool value)
|
||||
{
|
||||
animator.SetBool(chaseHash, value);
|
||||
}
|
||||
|
||||
public void PlayDeadAnim()
|
||||
{
|
||||
animator.SetTrigger(deadHash);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Presentation
|
||||
{
|
||||
public class EnemyAnimationController : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,16 +7,8 @@ namespace Darkmatter.Presentation
|
||||
{
|
||||
public Animator animator;
|
||||
|
||||
protected readonly int moveXhash = Animator.StringToHash("MoveX");
|
||||
protected readonly int moveYhash = Animator.StringToHash("MoveY");
|
||||
protected readonly int jumpHash = Animator.StringToHash("Jump");
|
||||
|
||||
public void PlayMovementAnim(Vector2 velocity)
|
||||
{
|
||||
animator.SetFloat(moveXhash, velocity.x,0.4f,Time.deltaTime);
|
||||
animator.SetFloat(moveYhash, velocity.y,0.4f, Time.deltaTime);
|
||||
}
|
||||
|
||||
public void PlayJumpAnim()
|
||||
{
|
||||
animator.SetTrigger(jumpHash);
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace Darkmatter.Presentation
|
||||
public class PlayerAnimController : HumonoidAnim, IPlayerAnim
|
||||
{
|
||||
private readonly int shootHash = Animator.StringToHash("IsShooting");
|
||||
protected readonly int moveXhash = Animator.StringToHash("MoveX");
|
||||
protected readonly int moveYhash = Animator.StringToHash("MoveY");
|
||||
private readonly int reloadHash = Animator.StringToHash("Reload");
|
||||
public TwoBoneIKConstraint HandOnGunIK; //for gunHand Ik
|
||||
private Coroutine reloadCoroutine;
|
||||
@@ -59,6 +61,12 @@ namespace Darkmatter.Presentation
|
||||
}
|
||||
|
||||
|
||||
public void PlayMovementAnim(Vector2 velocity)
|
||||
{
|
||||
animator.SetFloat(moveXhash, velocity.x, 0.4f, Time.deltaTime);
|
||||
animator.SetFloat(moveYhash, velocity.y, 0.4f, Time.deltaTime);
|
||||
}
|
||||
|
||||
public void PlayShootAnim()
|
||||
{
|
||||
Debug.Log("player Shoot");
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7cc0904e9eef2eb42860484c3c0d2675
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Presentation
|
||||
{
|
||||
public class TargetProvider : MonoBehaviour, ITargetProvider
|
||||
public class PlayerAimTargetProvider : MonoBehaviour, ITargetProvider
|
||||
{
|
||||
private Camera mainCamera;
|
||||
[SerializeField] private LayerMask aimLayer;
|
||||
@@ -43,6 +43,7 @@ namespace Darkmatter.Presentation
|
||||
private void PlayBulletHitEffectParticle()
|
||||
{
|
||||
var damageable = hitPoint.transform.GetComponent<IDamageable>();
|
||||
Debug.Log(hitPoint.transform);
|
||||
if (damageable != null)
|
||||
{
|
||||
damageable.TakeDamage(10f);
|
||||
|
||||
Reference in New Issue
Block a user