# Active Fights Display System ## Overview A complete system for tracking, displaying, and interacting with active fights between runners (AI agents) and monsters in the maze. ## Components Created ### 1. **FightTracker.cs** (Core Manager) - **Purpose**: Tracks all active fights in real-time - **Key Features**: - `StartFight(AIAgent runner, Monster monster)` - Called when combat begins - `EndFight(AIAgent runner, Monster monster)` - Called when combat ends - `GetDisplayFights()` - Returns sorted list of fights to display - Automatically cleans up old fights after `fightDisplayDuration` (default: 3 seconds after ending) - **Sorting**: Fights sorted by number of participants in room (descending), then by active status ### 2. **ActiveFightsUIPanel.cs** (UI Display) - **Purpose**: Displays active fights with zoom functionality - **Features**: - Shows runner name vs monster type - Each fight entry has: - Fight description text (e.g., "Alice vs Monster_12345") - Status indicator (red dot = active, orange dot = ended) - Zoom button to center camera on fight location - Panel positioned in top-right corner - Auto-updates every 0.5 seconds - Clean, dark-themed UI that doesn't obstruct gameplay ### 3. **MazeCameraController.cs** (Enhanced with zoom) - **New Method**: `ZoomToRoom(MazeRoom room, float zoomPadding = 1.3f, float transitionDuration = 0.5f)` - **Features**: - Smooth pan to room center - Smooth zoom with adjustable padding (1.3 = 30% larger than room) - Adjustable transition speed (default: 0.5 seconds) - Works with both orthographic and perspective cameras - Bound checks for camera limits ## Integration Points ### AIAgent.cs - Added `fightingMonsters` HashSet to track active fights - Modified `CombatUpdate()` to: - Report fight start when monster enters melee range - Report fight end when monster leaves range or dies - Track multiple concurrent fights - Modified `Die()` to end all active fights when agent dies ### Monster.cs - Added `previousTarget` tracking - Modified `AcquireTarget()` to: - Report fight start when acquiring new target - Report fight end when target is lost/killed - Modified `Die()` to report fight end ### MazeController.cs - Added `InitializeFightTracking()` in Start() - Automatically creates FightTracker and ActiveFightsUIPanel if not present - Ensures components are initialized before agents/monsters spawn ## Data Structure ### FightData (struct) ```csharp public string runnerName; // Agent's display name public int runnerId; // Agent's ID public string monsterType; // Monster identifier public MazeRoom room; // Room where fight occurs public bool isActive; // True if fight is ongoing public float timeSinceEnd; // Time since fight ended public AIAgent runner; // Reference to agent public Monster monster; // Reference to monster ``` ## Features ✅ **Real-time Fight Tracking** - Fights automatically detected when agents and monsters are in melee range ✅ **Smart Display** - Shows only active fights + recent fights (for a few seconds after they end) - Fights ranked by number of participants in the room (higher = more intense) ✅ **Interactive Zoom** - Click "Zoom" button to smoothly pan and zoom camera to fight location - Camera zooms to 30% larger than room size for good visibility - Smooth 0.5-second transition ✅ **Visual Feedback** - Red indicator dot for active fights - Orange indicator dot for recently-ended fights - Runner name vs monster type displayed - Clear, unobtrusive UI panel ✅ **Automatic Cleanup** - Old fights automatically removed from display - Dead fighters automatically cleaned up from tracking ## Configuration ### FightTracker Settings ```csharp [SerializeField] private float fightDisplayDuration = 3f; // How long to show ended fights ``` ### Camera Zoom Settings (in MazeCameraController) ```csharp [SerializeField] private float zoomMin = 5f; [SerializeField] private float zoomMax = 120f; ``` ### UI Panel Settings (in ActiveFightsUIPanel) ```csharp [SerializeField] private float updateInterval = 0.5f; // How often to update display [SerializeField] private float panelMaxHeight = 400f; // Maximum panel height ``` ## Usage Example ```csharp // FightTracker is a singleton - access it anywhere: FightTracker tracker = FightTracker.Instance; // Get current fights for display List fights = tracker.GetDisplayFights(); // Zoom to a room MazeCameraController camera = FindObjectOfType(); camera.ZoomToRoom(room, 1.3f, 0.5f); // zoom to room with 30% padding in 0.5s ``` ## Debug Information The system logs the following to console: - When fights start (via AIAgent and Monster combat methods) - When fights end (via death or separation) - Fight tracking status in FightTracker Enable debug logging in FightTracker, AIAgent, and Monster if needed for troubleshooting. ## Future Enhancements Potential additions: - Sound effects when fights start/end - Different colors/icons for different monster types - Fight statistics (damage dealt, healing, etc.) - Fight history/replay system - Animation transitions for UI panel entries - Custom zoom speeds/durations per difficulty level