Exemplo n.º 1
0
    void RoomReceived(RoomInfo room)
    {
        int index = m_roomListingButtons.FindIndex(x => x.m_roomName == room.Name);

        if (index == -1)
        {
            if (room.IsVisible && room.PlayerCount < room.MaxPlayers && room.PlayerCount > 0)
            {
                GameObject roomListingObj = Instantiate(m_roomListingPrefabs);
                roomListingObj.transform.SetParent(transform, false);

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

                index = (m_roomListingButtons.Count - 1);
            }
        }
        else
        {
            if (!(room.IsVisible && room.PlayerCount < room.MaxPlayers && room.PlayerCount > 0))
            {
                RoomListing roomListing = m_roomListingButtons[index];
                roomListing.m_updated = false;
            }
        }

        if (index != -1 && room.PlayerCount > 0)
        {
            RoomListing roomListing = m_roomListingButtons[index];
            roomListing.SetRoomNameText(room.Name);
            roomListing.SetNumPlayerText(room.PlayerCount.ToString() + "/" + room.MaxPlayers.ToString());
            roomListing.SetNumKillText(room.CustomProperties["NumKill"].ToString());
            roomListing.m_updated = true;
        }
    }