First commit

This commit is contained in:
2026-06-29 19:26:37 +09:00
commit 9efb08fdf3
11 changed files with 338 additions and 0 deletions

35
Core/Health.cs Normal file
View File

@@ -0,0 +1,35 @@
using System;
namespace Core
{
public class Health : IHealthView
{
public int MaxHP { get; private set; }
public int CurrentHP { get; private set; }
public bool IsDead => CurrentHP <= 0; // 필드 대신 계산 (상태 중복 제거)
public event Action<int, int> HPChanged;
public event Action Died;
public Health(int maxHp)
{
MaxHP = maxHp;
CurrentHP = maxHp;
}
//데미지 받기
public void TakeDamage(int amount)
{
if (IsDead) return;
CurrentHP = Math.Max(0, CurrentHP - amount);
HPChanged?.Invoke(MaxHP, CurrentHP);
if (IsDead) Died?.Invoke();
}
public void Revive()
{
CurrentHP = MaxHP; // CurrentHP가 MaxHP가 되면 IsDead도 자동 false
HPChanged?.Invoke(MaxHP, CurrentHP);
}
}
}