using Core; using Battle; namespace Units { public abstract class Unit : ComponentBase { //스탯 protected int MaxHP; protected int Atk; protected Health _health; public IHealthView HealthView => _health; public override void Awake() { Init(); _health = new Health(MaxHP); _health.Died += OnDied; //죽었을때 이벤트 } protected abstract void Init(); public void TakeDamage(int amount) { _health.TakeDamage(amount); } public void AttackDamage(Unit target, AttackType attackType) { target.TakeDamage(GetAttackDamage(attackType)); } //추상 메서드 //상속받은 쪽에서 반드시 구현 protected abstract int GetAttackDamage(AttackType attackType); //유닛별 데미지 계산식 적용 protected abstract void OnDied(); //죽었을때 이벤트 } }