protected override async void Run(Session session, C2M_CreateRoom message, Action <M2C_CreateRoom> reply) { M2C_CreateRoom response = new M2C_CreateRoom(); try { MatchRoomComponent matchRoomComponent = Game.Scene.GetComponent <MatchRoomComponent>(); //判断玩家 是否在其他游戏中 if (matchRoomComponent.JudgeUserIsGameIn(message.UserId, message.SessionActorId)) { return; } int needJeweNumCount = 0; long userJewel = message.User.Jewel; User friendsCreateUser = null; if (message.FriendsCircleId > 0) { friendsCreateUser = await GetFriendsCircleCreateUser(message.FriendsCircleId, response); if (friendsCreateUser == null) { reply(response); return; } userJewel = friendsCreateUser.Jewel; } MatchRoom room = matchRoomComponent.CreateRoom(message.RoomConfigLists, message.FriendsCircleId, message.ToyGameId, userJewel, response); if (room == null) { reply(response); return; } if (friendsCreateUser != null) { //记录亲友圈 主人的id room.FriendsCreateUserId = friendsCreateUser.UserId; } //创建者加入房间 matchRoomComponent.JoinRoom(room.RoomId, message.User, message.SessionActorId, response); response.RoomInfo = RoomInfoFactory.Creator(matchRoomComponent.GetRoomUserIdIn(message.UserId)); reply(response); RoomInfoFactory.Destroy(response.RoomInfo); } catch (Exception e) { ReplyError(response, e, reply); } }
protected override void Run(Session session, C2M_GetFriendsCircleRoomList message, Action <M2C_GetFriendsCircleRoomList> reply) { M2C_GetFriendsCircleRoomList response = new M2C_GetFriendsCircleRoomList(); try { if (MatchRoomComponent.Ins.FriendsCircleInMatchRoomDic.ContainsKey(message.FriendsCircleId)) { response.RoomInfos = RoomInfoFactory.Creator(MatchRoomComponent.Ins.FriendsCircleInMatchRoomDic[message.FriendsCircleId]); } reply(response); RoomInfoFactory.Destroy(response.RoomInfos); } catch (Exception e) { ReplyError(response, e, reply); } }
protected override async void Run(Session session, C2M_JoinRoom message, Action <M2C_JoinRoom> reply) { M2C_JoinRoom response = new M2C_JoinRoom(); try { MatchRoomComponent matchRoomComponent = Game.Scene.GetComponent <MatchRoomComponent>(); //判断玩家 是否在其他游戏中 if (matchRoomComponent.JudgeUserIsGameIn(message.UserId, message.SessionActorId)) { return; } MatchRoom matchRoom = matchRoomComponent.GetRoom(message.RoomId); if (matchRoom == null) { response.Message = "房间不存在"; reply(response); return; } if (matchRoom.IsAADeductJewel && matchRoom.NeedJeweNumCount > message.User.Jewel) { response.Message = "钻石不足 无法加入"; reply(response); return; } matchRoomComponent.JoinRoom(message.RoomId, message.User, message.SessionActorId, response); if (string.IsNullOrEmpty(response.Message)) { response.RoomInfo = RoomInfoFactory.Creator(matchRoomComponent.GetRoomUserIdIn(message.UserId)); } reply(response); await Game.Scene.GetComponent <TimerComponent>().WaitAsync(100); matchRoomComponent.DetetionRoomStartGame(message.RoomId); RoomInfoFactory.Destroy(response.RoomInfo); } catch (Exception e) { ReplyError(response, e, reply); } }