using TMPro;
using UnityEngine;
///
/// On-screen match HUD binder: drives the authored MatchHudCanvas widgets from live match state -
/// the current sub-phase + countdown (top centre) and a hunter crosshair during the seek phase. The visual
/// layout lives in the scene; this component creates nothing at runtime, it only binds. Attach it to the
/// MatchHudCanvas and wire the references in the Inspector.
///
/// Passive overlay: the authored canvas has no and every graphic
/// is raycastTarget=false, so it never consumes pointer events, and its sortingOrder (90) sits below PaintHud's
/// (100) so tool panels always win. There is no change event for the phase/timer, so the values are polled once
/// per frame; the visible strings are only rebuilt when the displayed second / phase actually changes.
///
[DisallowMultipleComponent]
public class MatchHud : MonoBehaviour
{
[Tooltip("HUD canvas, toggled with the match. Empty = the Canvas on this GameObject.")]
[SerializeField] private Canvas _canvas;
[Tooltip("Sub-phase label in the top bar.")]
[SerializeField] private TMP_Text _phaseText;
[Tooltip("Countdown label in the top bar.")]
[SerializeField] private TMP_Text _timeText;
[Tooltip("Seconds until the next radar ping sweep; counts down from the interval and repeats. Shown only " +
"during the seek phase (blank otherwise).")]
[SerializeField] private TMP_Text _pingTimeText;
[SerializeField] private TMP_Text _hunterCount;
[SerializeField] private TMP_Text _hiderCount;
[Tooltip("Crosshair, shown only for the hunter during the seek phase.")]
[SerializeField] private GameObject _crosshair;
private int _lastSecond = -1;
private int _lastPingSecond = -1;
private int _lastHunters = -1;
private int _lastHiders = -1;
private MatchManager.MatchSubPhase _lastPhase = (MatchManager.MatchSubPhase)(-1);
private void Awake()
{
if (!_canvas) _canvas = GetComponent