First commit
This commit is contained in:
33
UI/HPBar.cs
Normal file
33
UI/HPBar.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user