Add GameHud component to display player stats; include experience, coins, round time left, and health
This commit is contained in:
@@ -25,6 +25,7 @@ namespace Systems
|
||||
public float RoundTime => roundTime;
|
||||
public int MaxRounds => maxRounds;
|
||||
public bool StoreIsClosed { get; set; } = true;
|
||||
public float RoundTimeLeft => Mathf.Max(0, timer);
|
||||
|
||||
public event Action<int> OnRoundStart;
|
||||
public event Action<int> OnRoundEnd;
|
||||
|
3
Assets/Scripts/UI.meta
Normal file
3
Assets/Scripts/UI.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 72517a62486742de96c31c1f3a3a58d5
|
||||
timeCreated: 1752332352
|
28
Assets/Scripts/UI/GameHud.cs
Normal file
28
Assets/Scripts/UI/GameHud.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using Systems;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class GameHud : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TextMeshProUGUI expText;
|
||||
[SerializeField] private TextMeshProUGUI coinsText;
|
||||
[SerializeField] private TextMeshProUGUI roundTimeLeftText;
|
||||
[SerializeField] private Slider healthSlider;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var player = GameManager.Instance.Player;
|
||||
if (!player) return;
|
||||
|
||||
expText.text = $"EXP: {player.attributes.Experience}";
|
||||
coinsText.text = $"Coins: {GameManager.Instance.Coins}";
|
||||
roundTimeLeftText.text = $"{GameManager.Instance.RoundTimeLeft:F1}s";
|
||||
healthSlider.maxValue = player.attributes.MaxHealth;
|
||||
healthSlider.value = player.attributes.Health;
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/Scripts/UI/GameHud.cs.meta
Normal file
3
Assets/Scripts/UI/GameHud.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f17a4078172c4757abde33b7929f180e
|
||||
timeCreated: 1752332367
|
Reference in New Issue
Block a user