示例#1
0
 /// <summary>
 /// funt to update list of rooms
 /// </summary>
 /// <param name="roomList">list of info abt rooms</param>
 public override void OnRoomListUpdate(List <RoomInfo> roomList)
 {
     foreach (RoomInfo info in roomList)//loop through list
     {
         //remove from the list
         if (info.RemovedFromList)
         {
             int index = roomListings.FindIndex(x => x.roomInfo.Name == info.Name); //get index
             if (index != -1)                                                       //check for index is not equal to -1
             {
                 Destroy(roomListings[index].gameObject);                           //if not destroy index from list of rooms
                 roomListings.RemoveAt(index);                                      //remove from list
             }
         }
         //add it to the list
         else
         {
             int index = roomListings.FindIndex(x => x.roomInfo.Name == info.Name); //get index
             if (index == -1)                                                       //check to -1
             {
                 RoomListing listing = Instantiate(prefabListing, content);         //make listing and initialize with newly Instantiated list of prefabs and parent is content
                 if (listing != null)                                               //check listing to null
                 {
                     listing.SetRoom(info);                                         //set room from listing
                     roomListings.Add(listing);                                     //add listing to list of rooms
                 }
             }
         }
     }
 }
 public override void OnRoomListUpdate(List <RoomInfo> roomList)
 {
     foreach (RoomInfo info in roomList)
     {
         //Salas Removidas da Lista
         if (info.RemovedFromList)
         {
             int index = _listing.FindIndex(x => x.RoomInfo.Name == info.Name);
             if (index != -1)
             {
                 Destroy(_listing[index].gameObject);
                 _listing.RemoveAt(index);
             }
         }
         //Salas adicionadas da lista
         else
         {
             RoomListing listing = Instantiate(roomListing, content);
             if (listing != null)
             {
                 listing.SetRoom(info);
                 _listing.Add(listing);
             }
         }
     }
 }