Implemented health bar and diamond count in the new gui

This commit is contained in:
Max 2025-02-28 13:20:53 +01:00
parent 105055b307
commit c42406e615
14 changed files with 668 additions and 505 deletions

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UIElements;
@ -46,6 +47,10 @@ namespace UI
private List<Toggle> _armorUses = new List<Toggle>();
private int _armorUsesUsed = 0;
private List<VisualElement> _healthAreas;
private Label diamondCount;
public void OnEnable()
@ -58,7 +63,10 @@ namespace UI
GroupBox startingBlackDieGroupBox = root.Q<GroupBox>("StartingBlackDieUses");
startingBlackDieGroupBox.AddManipulator(new Clickable(evt => HandleStartingBlackDieAbilityClicked()));
GroupBox diceGroupBox = root.Q<GroupBox>("Dice");
VisualElement healthArea = root.Q<VisualElement>("HealthArea");
_healthAreas = healthArea.Children().ToList();
diamondCount = root.Q<Label>("DiamondCount");
foreach (Button diceButton in diceGroupBox.Children())
{
if (diceButton.name == "BlackDie")
@ -113,6 +121,26 @@ namespace UI
_rollOrPassButton = root.Q<Button>("RollPass");
_rollOrPassButton.clicked += HandleRollOrPassClicked;
}
public void SetDiamondCount(int count)
{
diamondCount.text = count.ToString();
}
public void SetHealth(int healthIndex)
{
for (int i = 0; i < _healthAreas.Count; i++)
{
if (i == healthIndex)
{
_healthAreas[i].SetEnabled(true);
}
else
{
_healthAreas[i].SetEnabled(false);
}
}
}
public void SetBlackDieAbilityEnabled()
{