Files
ProjectMD/Assets/Scripts/Enemy/EnemyHealth.cs
Dal4segno 745166803c 타워 공격 기능 추가
각 타워 외형 변경 및 투사체 생성
2026-01-14 01:45:59 +09:00

33 lines
795 B
C#

using UnityEngine;
public class EnemyHealth : MonoBehaviour, IDamageable
{
public float maxHealth = 50f;
private float _currentHealth;
void Start()
{
_currentHealth = maxHealth;
}
public void TakeDamage(float damage)
{
_currentHealth -= damage;
Debug.Log($"{gameObject.name} 남은 체력: {_currentHealth}");
// 데미지 입었을 때 반짝이는 효과를 여기서 호출해도 좋습니다.
// 예: GetComponent<EnemyAttack>().StartFlash();
if (_currentHealth <= 0)
{
Die();
}
}
private void Die()
{
Debug.Log($"{gameObject.name} 사망!");
// 여기서 파티클 생성이나 점수 추가 등을 처리합니다.
Destroy(gameObject);
}
}