Just two Images + two textsmeshpro (in a Horizontal group layout).
For the script, pretty simple .
using GameDevTV.Inventories;
using RPG.Stats;
using TMPro;
using UnityEngine;
namespace RPG.UI
{
public class StatsUI : MonoBehaviour
{
[SerializeField] private TextMeshProUGUI powerText;
[SerializeField] private TextMeshProUGUI armorText;
private BaseStats baseStats;
private TraitStore traitStore;
private Equipment equipment;
void Start()
{
GameObject player = GameObject.FindGameObjectWithTag("Player");
baseStats = player.GetComponent<BaseStats>();
traitStore = player.GetComponent<TraitStore>();
equipment = player.GetComponent<Equipment>();
traitStore.traitsChanged += RedrawStatsUI;
equipment.equipmentUpdated += RedrawStatsUI;
RedrawStatsUI();
}
private void RedrawStatsUI()
{
float power = baseStats.GetStat(Stat.Damage);
powerText.text = power.ToString();
float defense = baseStats.GetStat(Stat.Defence);
armorText.text = defense.ToString();
}
}
}
The new event traitStore.traitsChanged is simply invoked in TraitStore Commit()
If you have something like an ability buff, this probably can also be also handled with a new event in the ActionStore.