added enemy dead animation

This commit is contained in:
Mausham
2025-12-30 17:51:20 -08:00
parent 0ec69f66c9
commit b59d12631f
16 changed files with 41248 additions and 54 deletions

View File

@@ -26,19 +26,39 @@ namespace Darkmatter.Presentation
IEnumerator ReloadRoutine(IWeapon currentWeapon)
{
animator.SetLayerWeight(1, 1);
yield return BlendLayerWeight(1, 1, 0.2f);
//animator.SetLayerWeight(1,1);
HandOnGunIK.weight = 0f;
animator.SetTrigger(reloadHash);
yield return new WaitForSeconds(3f); //gave the length of the animation very bad practice
animator.SetLayerWeight(1, 0);
// animator.SetLayerWeight(1, 0);
yield return BlendLayerWeight(1, 0, 0.2f);
HandOnGunIK.weight = 1f;
currentWeapon.Reload();
reloadCoroutine = null;
}
IEnumerator BlendLayerWeight(int layerIndex, float targetWeight, float blendTime)
{
float startWeight = animator.GetLayerWeight(layerIndex);
float time = 0f;
while (time < blendTime)
{
time += Time.deltaTime;
float t = time / blendTime;
float weight = Mathf.Lerp(startWeight, targetWeight, t);
animator.SetLayerWeight(layerIndex, weight);
yield return null;
}
animator.SetLayerWeight(layerIndex, targetWeight);
}
public void PlayShootAnim()
{
Debug.Log("player Shoot");

View File

@@ -7,19 +7,24 @@ namespace Darkmatter.Presentation
{
public float health = 100f;
public Animator enemyAnimator;
public bool isDead = false;
public void Die()
{
isDead = true;
Debug.Log("Dead");
this.gameObject.SetActive(false);
enemyAnimator.SetLayerWeight(0, 1);
enemyAnimator.SetTrigger("Death");
Destroy(this.gameObject, 5f);
}
public void TakeDamage(float damage)
{
{ if(isDead) return;
health -= damage;
enemyAnimator.SetLayerWeight(1, 1);
enemyAnimator.SetTrigger("Hit");
if (health <= 0) Die();
Debug.Log("Damage Taken");
enemyAnimator.SetLayerWeight(1, 1);
enemyAnimator.SetTrigger("Hit");
}
}
}

View File

@@ -14,13 +14,14 @@ namespace Darkmatter.Presentation
[Header("Weapon Data")]
public float fireRate = 0.1f;
public override int AmmoCount { get; protected set; } = 40;
[SerializeField] private int ammoCount = 40;
private float lastUsedTime;
public GameObject BulletHole;
public override string WeaponName => "Rifel";
public override int AmmoCount { get => this.ammoCount; set => ammoCount = value; }
public override bool canAttack => Time.time >= lastUsedTime + fireRate && AmmoCount > 0;
public override bool canAttack => Time.time >= lastUsedTime + fireRate && ammoCount > 0;
[Inject] private ITargetProvider targetProvider;
private RaycastHit hitPoint => targetProvider.hitPoint;
@@ -30,7 +31,7 @@ namespace Darkmatter.Presentation
public override void Attack()
{
lastUsedTime = Time.time;
AmmoCount--;
ammoCount--;
PlayMuzzleFlash();
if (hitPoint.transform != null) PlayBulletHitEffectParticle();
@@ -61,7 +62,7 @@ namespace Darkmatter.Presentation
public override void Reload()
{
base.Reload();
AmmoCount = 40;
ammoCount = maxAmmoCount;
}
private void PlayMuzzleFlash()