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

18
Core/ComponentBase.cs Normal file
View File

@@ -0,0 +1,18 @@
namespace Core
{
public class ComponentBase
{
public virtual void Awake() { }
public virtual void Start() { }
public virtual void Update() { }
public virtual void OnDestroy() { }
//소멸
public void Destroy()
{
OnDestroy();
//객체 삭제 로직
}
}
}

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);
}
}
}

14
Core/IHealthView.cs Normal file
View File

@@ -0,0 +1,14 @@
using System;
namespace Core
{
public interface IHealthView
{
int CurrentHP { get; }
int MaxHP { get; }
bool IsDead { get; }
event Action<int, int> HPChanged; //<Max,Current>
event Action Died;
}
}