//移除房间 public static void RemoveRoom(this MatchRoomComponent matchRoomComponent, int roomId) { if (matchRoomComponent.MatchRoomDic.ContainsKey(roomId)) { foreach (var playerInfo in matchRoomComponent.MatchRoomDic[roomId].PlayerInfoDic) { if (matchRoomComponent.UserIdInRoomIdDic.ContainsKey(playerInfo.Value.User.UserId)) { matchRoomComponent.UserIdInRoomIdDic.Remove(playerInfo.Value.User.UserId);//移除所有房间里的玩家 } } MatchRoom matchRoom = matchRoomComponent.MatchRoomDic[roomId]; //得到该房间信息实体 matchRoomComponent.DestroyFriendsCircleRoom(matchRoom); //如果是亲友圈房间 还要从亲友圈中移除 matchRoom.Dispose(); //销毁房间 matchRoomComponent.MatchRoomDic.Remove(roomId); //从列表里移除房间 } else { Log.Error("要移除房间不存在:" + roomId); } }