using System.Collections.Generic; using System.Linq; using Unity.BossRoom.Gameplay.GameplayObjects.Character; using UnityEngine; namespace Unity.Multiplayer.Samples.BossRoom { public class PlatformManager : MonoBehaviour { private List m_Platforms; private void Start() { m_Platforms = GetComponentsInChildren().ToList(); } /// /// Finds an unoccupied platform and assigns the player to it. /// /// The ServerCharacter to assign. /// True if successfully assigned, false otherwise. public bool AssignPlayerToPlatform(ServerCharacter player) { var platform = m_Platforms.FirstOrDefault(p => !p.IsOccupied); if (platform != null) { platform.Occupy(player); return true; } Debug.LogWarning($"No unoccupied platforms available for {player.name}."); return false; } /// /// Finds the platform currently occupied by the given player. /// /// The ServerCharacter to search for. /// The platform occupied by the player, or null if not found. public Platform GetPlatformOccupiedByPlayer(ServerCharacter player) { return m_Platforms.FirstOrDefault(p => p.Occupier == player); } /// /// Checks if a specific platform is occupied. /// /// The platform to check. /// True if the platform is occupied, false otherwise. public bool IsPlatformOccupied(Platform platform) { return platform.IsOccupied; } } }