Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2019
897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. Dictionary<string,RoomPanel> m_roomPanelList = new Dictionary<string,RoomPanel>();
  2.  
  3. public override void OnRoomListUpdate(List<RoomInfo> roomList)
  4. {
  5. foreach (var entry in roomList)
  6. {
  7. if (m_roomPanelList.ContainsKey(entry.Name))
  8. {
  9.  
  10. if (entry.RemovedFromList)
  11. {
  12. RemoveRoomPanel(entry);
  13. }
  14. }
  15. else
  16. {
  17. if (!entry.RemovedFromList)
  18. {
  19. AddRoomPanel(entry);
  20. }
  21. }
  22. }
  23. }
  24.  
  25. void AddRoomPanel(RoomInfo room)
  26. {
  27. var gbj = Instantiate(m_roomPanel, m_panelRect, false);
  28. var panel = gbj.GetComponent<RoomPanel>();
  29.  
  30. panel.SetRoom(room);
  31. panel.JoinButton.onClick.AddListener(() => OnClickJoinRoom(panel.RoomName, room));
  32. m_roomPanelList.Add(room.Name,panel);
  33. }
  34.  
  35. private void RemoveRoomPanel(RoomInfo room)
  36. {
  37. var panel = m_roomPanelList[room.Name];
  38. m_roomPanelList.Remove(room.Name);
  39. Destroy(panel.gameObject);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement