//玩家加入房间 public static void JoinRoom(this MatchRoomComponent matchRoomComponent, int roomId, User user, long sessionActorId, IResponse iResponse) { if (matchRoomComponent.UserIdInRoomIdDic.ContainsKey(user.UserId)) { //玩家已经在其他房间中 iResponse.Message = "正在其他房间游戏中"; return; } MatchRoom matchRoom = matchRoomComponent.GetRoom(roomId); if (matchRoom != null) { if (matchRoom.UserJoinRoom(user, sessionActorId)) { //玩家成功加入 matchRoomComponent.UserIdInRoomIdDic[user.UserId] = matchRoom; user.AddComponent <UserGateActorIdComponent>().ActorId = sessionActorId; iResponse.Message = string.Empty; return; } else { //玩家加入失败 房间已满 iResponse.Message = "房间已满"; return; } } //房间不存在 iResponse.Message = "房间不存在"; }