First commit
This commit is contained in:
44
Units/Champion.cs
Normal file
44
Units/Champion.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Battle; // BattleManager.CurrentGameSeconds 참조
|
||||
|
||||
namespace Units
|
||||
{
|
||||
public class Champion : Unit
|
||||
{
|
||||
private int _championAtk;
|
||||
private int _championMaxHP;
|
||||
|
||||
private int _reviveAt;
|
||||
private int GetReviveDelay() => 5;
|
||||
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
MaxHP = _championMaxHP;
|
||||
Atk = _championAtk;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (_health.IsDead && BattleManager.CurrentGameSeconds >= _reviveAt)
|
||||
Revive(); // 시간 도달 시 부활
|
||||
}
|
||||
|
||||
protected override int GetAttackDamage(AttackType attackType)
|
||||
{
|
||||
//데미지 계산
|
||||
return Atk;
|
||||
}
|
||||
|
||||
protected override void OnDied()
|
||||
{
|
||||
_reviveAt = BattleManager.CurrentGameSeconds + GetReviveDelay(); // 예약
|
||||
}
|
||||
|
||||
private void Revive()
|
||||
{
|
||||
_health.Revive();
|
||||
|
||||
//부활 지점에서 스폰 로직
|
||||
}
|
||||
}
|
||||
}
|
||||
34
Units/Minion.cs
Normal file
34
Units/Minion.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Battle;
|
||||
|
||||
namespace Units
|
||||
{
|
||||
public class Minion : Unit
|
||||
{
|
||||
private int _minionAtk;
|
||||
private int _minionMaxHP;
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
MaxHP = _minionMaxHP;
|
||||
Atk = GetAtkByGameTime();
|
||||
}
|
||||
|
||||
protected override int GetAttackDamage(AttackType attackType)
|
||||
{
|
||||
//데미지 계산
|
||||
|
||||
return Atk;
|
||||
}
|
||||
|
||||
protected override void OnDied()
|
||||
{
|
||||
//소멸
|
||||
Destroy();
|
||||
}
|
||||
|
||||
private int GetAtkByGameTime()
|
||||
{
|
||||
return _minionAtk * BattleManager.CurrentGameSeconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
44
Units/Tower.cs
Normal file
44
Units/Tower.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Battle;
|
||||
|
||||
namespace Units
|
||||
{
|
||||
public class Tower : Unit
|
||||
{
|
||||
private int _towerAtk;
|
||||
private int _towerMaxHP;
|
||||
|
||||
public bool IsDestroyed { get; private set; } // 영구 파괴 여부
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
MaxHP = _towerMaxHP;
|
||||
Atk = _towerAtk;
|
||||
}
|
||||
|
||||
protected override int GetAttackDamage(AttackType attackType)
|
||||
{
|
||||
//데미지 계산
|
||||
|
||||
return Atk;
|
||||
}
|
||||
|
||||
protected override void OnDied()
|
||||
{
|
||||
//영구 파괴
|
||||
IsDestroyed = true;
|
||||
|
||||
StopFunction(); // 공격/타겟팅 등 기능 정지
|
||||
SwitchToWreckage(); // '파괴된 구조물' 잔해 비주얼로 전환 (파괴되었지만 구조물의 흔적은 남아있음)
|
||||
}
|
||||
|
||||
private void StopFunction()
|
||||
{
|
||||
// 공격·상호작용 비활성화
|
||||
}
|
||||
|
||||
private void SwitchToWreckage()
|
||||
{
|
||||
// 부서진 잔해로 모델 교체
|
||||
}
|
||||
}
|
||||
}
|
||||
39
Units/Unit.cs
Normal file
39
Units/Unit.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
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(); //죽었을때 이벤트
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user