chore():整理了一下文件夹和玩家的血量逻辑
This commit is contained in:
@@ -16,17 +16,20 @@ namespace UI
|
||||
ControllerLocator.Instance.TryGetWait<PlayerController>(OnGet);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_playerController != null)
|
||||
{
|
||||
hpText.text = "HP: " + _playerController.CurrentHealth;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnGet(PlayerController playerController)
|
||||
{
|
||||
_playerController = playerController;
|
||||
_playerController.OnHealthChanged += UpdateHpText;
|
||||
}
|
||||
|
||||
private void UpdateHpText(int currentHealth)
|
||||
{
|
||||
hpText.text = "HP: " + currentHealth;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
_playerController.OnHealthChanged -= UpdateHpText;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user