chore():整理了一下文件夹和玩家的血量逻辑

This commit is contained in:
2025-10-18 15:41:43 +08:00
parent ab403fac4b
commit b709d1219f
17 changed files with 214 additions and 33 deletions

View File

@@ -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;
}
}
}