예제 #1
0
    public override void OnRoomListUpdate(List <RoomInfo> roomList)
    {
        print("OnRoomListUpdate Called");
        RoomList = roomList;
        foreach (RoomInfo RoomInfomation in RoomList)
        {
            int Index = RoomListings.FindIndex(x => x.RoomName == RoomInfomation.Name);
            if (Index == -1)
            {
                if (RoomInfomation.IsVisible && RoomInfomation.PlayerCount < RoomInfomation.MaxPlayers)
                {
                    RoomListing   temp     = Instantiate(RoomPrefab);
                    RectTransform TempRect = temp.GetComponent <RectTransform>();
                    TempRect.SetParent(RT, false);
                    RoomListings.Add(temp);
                    temp.Updated = true;
                    //temp.UpdateInfo(Room.);

                    Index = RoomListings.Count - 1;
                }
            }

            if (Index != -1)
            {
                RoomListing RL = RoomListings[Index];
                RL.SetRoomIdentifier(RoomInfomation.Name);
                string RoomName = (string)RoomInfomation.CustomProperties["RoomNameKey"];
                string RoomType = (string)RoomInfomation.CustomProperties["RoomTypeKey"];

                int RoomPing = PhotonNetwork.GetPing();
                RL.UpdateInfo(RoomName, RoomType, RoomPing, RoomInfomation.PlayerCount, RoomInfomation.MaxPlayers);
            }
        }
        base.OnRoomListUpdate(roomList);

        RemoveOldRooms();
    }