31 lines
781 B
C#
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");
|
|
}
|
|
}
|
|
}
|