34 lines
676 B
C#
34 lines
676 B
C#
using Core;
|
|
|
|
namespace UI
|
|
{
|
|
public class HPBar : ComponentBase
|
|
{
|
|
private IHealthView _target;
|
|
|
|
public void Bind(IHealthView target)
|
|
{
|
|
Unbind();
|
|
|
|
_target = target;
|
|
if (_target == null) return;
|
|
|
|
_target.HPChanged += RefreshHP;
|
|
RefreshHP(target.MaxHP, target.CurrentHP);
|
|
}
|
|
|
|
public void Unbind()
|
|
{
|
|
if (_target != null) _target.HPChanged -= RefreshHP;
|
|
_target = null;
|
|
}
|
|
|
|
public void RefreshHP(int maxHP,int currentHP)
|
|
{
|
|
//UI 갱신
|
|
}
|
|
|
|
public override void OnDestroy() => Unbind();
|
|
}
|
|
}
|