using UnityEngine; using UnityEngine.UI; using Subsystems; using GeoSus.Client; using System.Collections.Generic; using System; using TMPro; namespace Subsystems { /// /// Manages UI for the GameManager. Canvas references are only valid in Client.unity; /// Art-menu scenes use their own lightweight UI scripts that read from GameManager.Instance. /// public class GameManager_UI { private GameClient _gameClient; // Set by GameManager after Client.unity loads (called from GameManager.OnSceneLoaded) public Canvas ClientCreateJoinLobby; // fallback join-code canvas in Client.unity public Canvas ClientInLobby; // InLobby canvas in Client.unity (unused now, kept compat) public Canvas ClientLoadingScreen; public Canvas ClientGameScreen; // parent of all HUD elements // HUD elements (children of ClientGameScreen, resolved at runtime) private TMP_Text _roleText; private TMP_Text _taskListText; private TMP_Text _taskProgressText; private Button _actionButton; private TMP_Text _actionButtonText; private TMP_Text _killCooldownText; private GameObject _sabotagePanel; private TMP_Text _sabotageTimerText; private GameObject _meetingPanel; private GameObject _gameEndPanel; private TMP_Text _gameEndText; // Runtime state private bool _isDead; private bool _commsBlackout; private DateTime _sabotageMeltdownDeadline; private bool _sabotageTimerActive; // Lobby-changed flag — set from network thread, consumed in Update private volatile bool _lobbyDirty; public GameManager_UI(GameClient gameClient) { _gameClient = gameClient; } /// Called by Network subsystem when lobby player list changes. public void NotifyLobbyChanged() => _lobbyDirty = true; // ── Called from GameManager after Client.unity loads ────────────────── public void BindClientScene(Canvas createJoin, Canvas inLobby, Canvas loading, Canvas game) { ClientCreateJoinLobby = createJoin; ClientInLobby = inLobby; ClientLoadingScreen = loading; ClientGameScreen = game; EnsureCanvasReady(createJoin); EnsureCanvasReady(inLobby); EnsureCanvasReady(loading); EnsureCanvasReady(game); if (createJoin) createJoin.gameObject.SetActive(false); if (inLobby) inLobby.gameObject.SetActive(false); if (loading) loading.gameObject.SetActive(false); if (game) game.gameObject.SetActive(false); if (game != null) { _roleText = FindTMP(game.transform, "Role"); _taskListText = FindTMP(game.transform, "TaskList"); _taskProgressText = FindTMP(game.transform, "TaskProgress"); _killCooldownText = FindTMP(game.transform, "KillCooldown"); _sabotageTimerText = FindTMP(game.transform, "SabotageTimer"); _gameEndText = FindTMP(game.transform, "GameEndText"); var actionGO = game.transform.Find("ActionButton"); if (actionGO != null) { _actionButton = actionGO.GetComponent