From 9c03acdd07cc93d956a7d12fabc6dfc65d093696 Mon Sep 17 00:00:00 2001 From: Hazim Bin Ijaz Date: Tue, 10 Dec 2024 12:15:50 +0500 Subject: [PATCH] Added platform ids --- Assets/Scripts/Platform.cs | 12 ++++++++++++ Assets/Scripts/PlatformManager.cs | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/Assets/Scripts/Platform.cs b/Assets/Scripts/Platform.cs index 9e386ef..195e6bf 100644 --- a/Assets/Scripts/Platform.cs +++ b/Assets/Scripts/Platform.cs @@ -6,6 +6,8 @@ namespace Unity.Multiplayer.Samples.BossRoom [RequireComponent(typeof(Collider))] public class Platform : MonoBehaviour { + + public int PlatformID { get; private set; } public bool IsOccupied => Occupier != null; public ServerCharacter Occupier { get; private set; } @@ -21,6 +23,16 @@ namespace Unity.Multiplayer.Samples.BossRoom } } + /// + /// Sets the unique ID for the platform. + /// + /// The unique ID to assign. + public void AssignID(int id) + { + PlatformID = id; + Debug.Log($"Platform {name} assigned ID: {PlatformID}"); + } + /// /// Marks this platform as occupied by a specific player. /// diff --git a/Assets/Scripts/PlatformManager.cs b/Assets/Scripts/PlatformManager.cs index b754ca1..0e7d1a5 100644 --- a/Assets/Scripts/PlatformManager.cs +++ b/Assets/Scripts/PlatformManager.cs @@ -12,6 +12,13 @@ namespace Unity.Multiplayer.Samples.BossRoom private void Start() { m_Platforms = GetComponentsInChildren().ToList(); + // Assign unique IDs to each platform + for (int i = 0; i < m_Platforms.Count; i++) + { + m_Platforms[i].AssignID(i + 1); // IDs start from 1 + } + + Debug.Log("All platforms have been assigned unique IDs."); } ///