Files
MobileShooter/Assets/Darkmatter/Code/Presentation/Enemies/Enemy.cs
2025-12-30 17:51:20 -08:00

31 lines
781 B
C#

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