using UnityEngine; using UnityEngine.UIElements; using System.Collections.Generic; using System.Linq; using UnityEngine.SceneManagement; using System.Collections; /// /// Controls the TeamOverview UI panel on the right side of the map scene. /// Displays current team information, stats, and provides navigation controls. /// Works with the main map UI document. /// public class TeamOverviewController : MonoBehaviour, IClickBlocker { [Header("Settings")] [SerializeField] public bool showDebugLogs = false; // UI Elements private VisualElement teamOverviewPanel; private ScrollView teamMembersList; private Button manageTeamButton; private Button saveGameButton; private Label memberCountLabel; private Label totalGoldLabel; private Label averageLevelLabel; private Toggle perceptionVisualizationToggle; // UI Document reference (shared with map) private UIDocument uiDocument; // Team data private List currentTeam; void Awake() { // Get the UIDocument component from this GameObject uiDocument = GetComponent(); if (uiDocument == null) { Debug.LogError("❌ TeamOverviewController: No UIDocument component found on this GameObject!"); } } void Start() { // Ensure GameStateManager has loaded data if it exists if (GameStateManager.Instance != null && PlayerPrefs.HasKey("GameSaved")) { GameStateManager.Instance.LoadGame(); } SetupUI(); LoadTeamData(); ShowTeamOverview(); } /// /// Sets up the UI elements and event handlers /// private void SetupUI() { if (uiDocument?.rootVisualElement == null) { Debug.LogError("❌ TeamOverviewController: UIDocument not found or has no root element!"); return; } var root = uiDocument.rootVisualElement; // Find UI elements - using the correct button names from TeamOverview.uxml teamOverviewPanel = root.Q("TeamOverviewPanel"); teamMembersList = root.Q("TeamMembersList"); manageTeamButton = root.Q