50 lines
1.1 KiB
C#
50 lines
1.1 KiB
C#
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.GetDayName()} {TimeManager.CurrentTime.ToString(@"hh\:mm")} day ({TimeManager.CurrentTime.Days})";
|
|
}
|
|
|
|
_energy.value = (float)Player.Instance.Stats[StatsId.Energy].Value;
|
|
_food.value = (float)Player.Instance.Stats[StatsId.Food].Value;
|
|
}
|
|
}
|