using OTG.Lab06.Core; using UnityEngine; namespace OTG.Lab06.Combat { public sealed class Enemy : MonoBehaviour, IDamageable { [SerializeField] private float health = 80f; [SerializeField] private GameObject deathEffectPrefab; private bool isAlive = true; public Transform Transform => transform; public bool IsAlive => isAlive; public void TakeDamage(float amount) { if (!isAlive) { return; } health -= Mathf.Max(0f, amount); FloatingDamageManager.Show(amount, transform.position + Vector3.up * 2.1f); if (health <= 0f) { Die(); } } private void Die() { isAlive = false; if (deathEffectPrefab != null) { Instantiate(deathEffectPrefab, transform.position + Vector3.up * 0.6f, Quaternion.identity); } Destroy(gameObject, 0.05f); } } }