Files

49 lines
948 B
C#
Raw Permalink Normal View History

2026-06-04 20:14:47 +03:00
using UnityEngine;
public class Enemy : MonoBehaviour
{
public string enemyType = "Goblin";
public int health = 100;
public bool IsDead { get; private set; }
public void TakeDamage(int amount)
{
if (IsDead || amount <= 0)
{
return;
}
health -= amount;
if (health <= 0)
{
Die();
}
else if (NotificationUI.Instance != null)
{
NotificationUI.Instance.Show($"{enemyType}: {health} HP");
}
}
public void Die()
{
if (IsDead)
{
return;
}
IsDead = true;
if (QuestManager.Instance != null)
{
QuestManager.Instance.OnEnemyKilled(enemyType);
}
if (NotificationUI.Instance != null)
{
NotificationUI.Instance.Show($"{enemyType} уничтожен");
}
Destroy(gameObject);
}
}