Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public override void OnRoomListUpdate(List<RoomInfo> roomList)
- {
- Debug.Log("roomList updating, number of lobbies found: " + roomList.Count);
- //This is done for debugging reasons
- foreach (RoomInfo room in roomList)
- {
- if (room.IsOpen)
- {
- Debug.Log("room is open");
- }
- else if (room.RemovedFromList || !room.IsOpen || !room.IsVisible)
- {
- Debug.Log("Room has been removed from list");
- }
- }
- //UpdateRoomList(roomList);
- MatchMakingManager m = MatchMakingManager.singleton;
- m.AddMatches(roomList);
- }
- public void AddMatches(List<RoomInfo> rooms)
- {
- SetDirtyRooms();
- foreach (RoomInfo room in rooms)
- {
- RoomButton createdRoom = GetRoomFromDict(room.Name);
- Debug.Log(createdRoom);
- if (createdRoom == null)
- {
- Debug.Log("New match found");
- AddMatch(room);
- }
- else
- {
- Debug.Log("Match is still there");
- createdRoom.isValid = true;
- }
- }
- ClearNonValidRooms();
- }
- private void SetDirtyRooms()
- {
- List<RoomButton> allRooms = new List<RoomButton>();
- allRooms.AddRange(roomsDict.Values);
- foreach (RoomButton r in allRooms)
- {
- r.isValid = false;
- Debug.Log(r.roomInfo.Name + " has been set to: " + r.isValid);
- }
- }
- public void AddMatch(RoomInfo roomInfo)
- {
- GameObject go = Instantiate(matchPrefab);
- go.transform.SetParent(matchesParent);
- MatchSpawnPosition p = GetSpawnPos();
- p.isUsed = true;
- go.transform.position = p.pos.position;
- go.transform.localScale = Vector3.one;
- RoomButton roomButton = go.GetComponent<RoomButton>();
- roomButton.roomInfo = roomInfo;
- roomButton.isRoomCreated = true;
- roomButton.isValid = true;
- roomButton.room = ScriptableObject.CreateInstance<Room>();
- object sceneObj = null;
- roomInfo.CustomProperties.TryGetValue("scene", out sceneObj);
- string sceneName = (string)sceneObj;
- roomButton.room.sceneName = sceneName;
- roomButton.room.roomName = roomInfo.Name;
- roomsDict.Add(roomInfo.Name, roomButton);
- }
- private void ClearNonValidRooms()
- {
- List<RoomButton> allRooms = new List<RoomButton>();
- allRooms.AddRange(roomsDict.Values);
- foreach (RoomButton r in allRooms)
- {
- if (!r.isValid)
- {
- Debug.Log(r.roomInfo.Name + " is not valid");
- roomsDict.Remove(r.roomInfo.Name);
- Destroy(r.gameObject);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement