Added platform ids

dev-ali
Hazim Bin Ijaz 2 days ago
parent 4d5f2d663f
commit 9c03acdd07

@ -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
}
}
/// <summary>
/// Sets the unique ID for the platform.
/// </summary>
/// <param name="id">The unique ID to assign.</param>
public void AssignID(int id)
{
PlatformID = id;
Debug.Log($"Platform {name} assigned ID: {PlatformID}");
}
/// <summary>
/// Marks this platform as occupied by a specific player.
/// </summary>

@ -12,6 +12,13 @@ namespace Unity.Multiplayer.Samples.BossRoom
private void Start()
{
m_Platforms = GetComponentsInChildren<Platform>().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.");
}
/// <summary>

Loading…
Cancel
Save