타워 선택 건설 및 몹 웨이브 생성
Defence용 Scene 별도 생성
This commit is contained in:
@@ -4,20 +4,21 @@ using System;
|
||||
public class Core : MonoBehaviour, IDamageable
|
||||
{
|
||||
[SerializeField] private float maxHealth = 100f;
|
||||
private float _currentHealth;
|
||||
[SerializeField] private float currentHealth = 100f;
|
||||
private float CurrentHealth;
|
||||
|
||||
// 체력이 변경될 때 UI 등에 알리기 위한 이벤트 (Observer 패턴)
|
||||
public static event Action<float> OnHealthChanged;
|
||||
public static event Action OnCoreDestroyed;
|
||||
|
||||
void Awake() => _currentHealth = maxHealth;
|
||||
void Awake() => currentHealth = maxHealth;
|
||||
|
||||
public void TakeDamage(float amount)
|
||||
{
|
||||
_currentHealth -= amount;
|
||||
OnHealthChanged?.Invoke(_currentHealth / maxHealth);
|
||||
currentHealth -= amount;
|
||||
OnHealthChanged?.Invoke(currentHealth / maxHealth);
|
||||
|
||||
if (_currentHealth <= 0)
|
||||
if (currentHealth <= 0)
|
||||
OnCoreDestroyed?.Invoke();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user