using System; using System.Collections.Generic; using UnityEngine; namespace MazeGen { /// /// Displays a clickable list of all agents with their status. Allows the player to follow /// an agent's perspective. Narrates status as dead, reached exit, fighting, or exploring with HP. /// public class AgentPanelUI { private Vector2 scrollPosition; public AgentPanelUI() { } /// /// Draw the agent list panel. Returns the clicked agent (if any) or null. /// public MazeAgent Draw(List agents, MazeAgent currentlyFollowed, bool hasFollowedAgent, Action onStopFollowing) { GUILayout.BeginArea(new Rect(10, 360, 280, Screen.height - 380), GUI.skin.box); if (hasFollowedAgent && GUILayout.Button("Stop following")) onStopFollowing?.Invoke(); GUILayout.Space(6); GUILayout.Label("Agents (click to follow):"); scrollPosition = GUILayout.BeginScrollView(scrollPosition); MazeAgent clickedAgent = null; foreach (var agent in agents) { bool isFollowed = agent == currentlyFollowed; string status = DescribeStatus(agent); GUI.color = agent.IsDead ? new Color(0.55f, 0.55f, 0.55f) : Color.white; if (GUILayout.Button($"{(isFollowed ? "> " : "")}{agent.DisplayName} - {status}")) clickedAgent = agent; } GUI.color = Color.white; GUILayout.EndScrollView(); GUILayout.EndArea(); return clickedAgent; } private string DescribeStatus(MazeAgent agent) { if (agent.IsDead) return "dead"; if (agent.IsFinished) return "reached exit"; if (agent.IsEngaged) return "fighting"; return $"exploring ({agent.CharacterSheet.Stats.CurrentHealth:0}hp)"; } } }