feat():完成3种模式的基本运行框架
This commit is contained in:
32
Assets/Script/Gameplay/UI/PlayerHpViewer.cs
Normal file
32
Assets/Script/Gameplay/UI/PlayerHpViewer.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using Core;
|
||||
using Gameplay.Player;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class PlayerHpViewer : UIBase
|
||||
{
|
||||
private PlayerController _playerController;
|
||||
public Text hpText;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
ControllerLocator.Instance.TryGetWait<PlayerController>(OnGet);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_playerController != null)
|
||||
{
|
||||
hpText.text = "HP: " + _playerController.CurrentHealth;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnGet(PlayerController playerController)
|
||||
{
|
||||
_playerController = playerController;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user