little refactor
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TopBarUI : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private TextMeshProUGUI _timeText;
|
||||
|
||||
[SerializeField]
|
||||
private TextMeshProUGUI _moneyText;
|
||||
|
||||
[SerializeField]
|
||||
public Slider _energy;
|
||||
|
||||
[SerializeField]
|
||||
public Slider _food;
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
TimeManager.Instance.OnMinuteChanged += UpdateTime;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
TimeManager.Instance.OnMinuteChanged -= UpdateTime;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
_moneyText.text = $"${Player.Instance.Stats[StatsId.Money].Value}";
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void UpdateTime()
|
||||
{
|
||||
if (_timeText != null)
|
||||
{
|
||||
_timeText.text = TimeManager.CurrentTime.ToString(@"hh\:mm");
|
||||
}
|
||||
|
||||
_energy.value = (float)Player.Instance.Stats[StatsId.Energy].Value;
|
||||
_food.value = (float)Player.Instance.Stats[StatsId.Food].Value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user