타워 공격 기능 추가
각 타워 외형 변경 및 투사체 생성
This commit is contained in:
33
Assets/Scripts/Enemy/EnemyHealth.cs
Normal file
33
Assets/Scripts/Enemy/EnemyHealth.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user