//更新房间列表 public void UpdateRoom(SockRoomInfo room) { if (m_dicRoomList.ContainsKey(room.roomId)) { m_dicRoomList [room.roomId].InitRoomItem(room); } }
//添加房间 public void AddRoom(SockRoomInfo room) { if (!m_dicRoomList.ContainsKey(room.roomId)) { //to add... Object prefab = PrefabLoader.loadFromPack("ZQ/roomItem"); if (prefab != null) { GameObject obj = Instantiate(prefab) as GameObject; RED.AddChild(obj, m_grid.gameObject); RadarRoomItem roomItem = obj.GetComponent <RadarRoomItem> (); roomItem.InitRoomItem(room); m_dicRoomList.Add(room.roomId, roomItem); } else { RED.LogWarning("ZQ/roomItem not find"); } m_grid.Reposition(); } else { UpdateRoom(room); } }
public void InitRoomItem(SockRoomInfo room) { m_data = room; m_txtLv.text = "Lv" + room.masterLevel.ToString(); m_txtCount.text = room.nowRoomMemberNum.ToString() + "/" + room.roomMaxMemberNum.ToString(); m_txtName.text = room.masterName; m_btnJoin.isEnabled = (room.joinState == 1); }
//删除房间 public void DelRoom(SockRoomInfo room) { if (m_dicRoomList.ContainsKey(room.roomId)) { m_dicRoomList [room.roomId].transform.parent = null; Destroy(m_dicRoomList [room.roomId].gameObject); m_grid.Reposition(); } }
//创建房间成功 public void CreateRoomSuc(SockCreatRoomResponse resp) { m_dicRoomList.Clear(); SockRoomInfo room = new SockRoomInfo(); room.roomId = resp.data.room.roomId; room.joinState = 1; room.roomMaxMemberNum = resp.data.room.roomMaxMemberNum; room.nowRoomMemberNum = resp.data.room.nowRoomMemberNum; room.masterName = Core.Data.playerManager.RTData.nickName; room.masterLevel = Core.Data.playerManager.RTData.curLevel; m_dicRoomList.Add(resp.data.room.roomId, room); curRoom = resp.data; }