Beispiel #1
0
    private void RoomReceived(RoomInfo room)
    {
        int index = roomListingButtons.FindIndex(x => x.RoomName == room.Name);

        if (index == -1)
        {
            if (room.IsVisible && room.PlayerCount < room.MaxPlayers)
            {
                GameObject roomListingObj = Instantiate(roomListingPrefab, layoutGroup.transform, false);

                RoomListing roomListing = roomListingObj.GetComponent <RoomListing>();
                roomListingButtons.Add(roomListing);

                index = (roomListingButtons.Count - 1);
            }
        }

        if (index != -1)
        {
            RoomListing roomListing = roomListingButtons[index];
            roomListing.SetRoomName(room.Name);
            roomListing.SetPlayerCount(room.PlayerCount, room.MaxPlayers);
            roomListing.Updated = true;
        }
    }