Implemented health bar and diamond count in the new gui
This commit is contained in:
parent
105055b307
commit
c42406e615
14 changed files with 668 additions and 505 deletions
|
|
@ -5,10 +5,11 @@ using UnityEngine.Serialization;
|
|||
|
||||
public class Player : MonoBehaviour
|
||||
{
|
||||
public event Action<int> DiamondCountUpdated;
|
||||
public event Action<int> HealthUpdated;
|
||||
|
||||
[SerializeField] private int maxHealth;
|
||||
[SerializeField] private int diamonds;
|
||||
[FormerlySerializedAs("healthGameObject")] [SerializeField] private GameObject healthGO;
|
||||
[FormerlySerializedAs("DiamondsGO")] [SerializeField] private GameObject diamondsGO;
|
||||
[SerializeField] private GameObject rooms;
|
||||
private int _healthIndex = 0;
|
||||
private readonly int[] _healthBar = {0, 0, -1, -2, -4, -6, -9, -12, -16, -20};
|
||||
|
|
@ -56,8 +57,8 @@ public class Player : MonoBehaviour
|
|||
|
||||
private void UpdateGUI()
|
||||
{
|
||||
healthGO.GetComponent<TextMeshProUGUI>().text = _healthBar[_healthIndex].ToString();
|
||||
diamondsGO.GetComponent<TextMeshProUGUI>().text = diamonds.ToString();
|
||||
DiamondCountUpdated?.Invoke(diamonds);
|
||||
HealthUpdated?.Invoke(_healthIndex);
|
||||
}
|
||||
|
||||
private void HandleDiamondAndLifeAbilitySelected()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue