feat: Player

This commit is contained in:
2026-10-07 15:46:51 +02:00
parent 074eb51084
commit d21f0c9b6c
45 changed files with 1801 additions and 74 deletions

View File

@@ -0,0 +1,60 @@
using TMPro;
using UnityEngine;
using Arena.Combat;
namespace Arena.UI
{
/// <summary>
/// Displays a Health as "current / max".
/// </summary>
public class HealthView : MonoBehaviour
{
[System.Serializable]
public struct References
{
public TMP_Text Label;
}
#region Fields
[SerializeField] private References _references;
private Health _health;
#endregion
#region Unity Lifecycle
private void OnDestroy()
{
// Every subscription has its unsubscription
if (_health != null)
_health.OnChange -= HandleHealthChange;
}
#endregion
#region Public Methods
/// <summary>
/// Starts displaying a Health. Called by the UiManager.
/// </summary>
public void Bind(Health health)
{
_health = health;
_health.OnChange += HandleHealthChange;
HandleHealthChange(_health.Current, _health.Max);
}
#endregion
#region Private Methods
private void HandleHealthChange(int current, int max)
{
_references.Label.SetText("{0} / {1}", current, max);
}
#endregion
}
}