Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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);
            }
        }
        protected override void Run(Session session, C2M_GetReconnectionRoomInfo message, Action <M2C_GetReconnectionRoomInfo> reply)
        {
            M2C_GetReconnectionRoomInfo response = new M2C_GetReconnectionRoomInfo();

            try
            {
                MatchRoom matchRoom = MatchRoomComponent.Ins.GetRoomUserIdIn(message.UserId);
                if (matchRoom == null)
                {
                    response.IsGameBeing = false;
                    response.Message     = "房间已经结算";
                    reply(response);
                    return;
                }
                response.IsGameBeing = true;
                if (matchRoom.IsGameBeing)
                {
                    Actor_UserRequestReconnectionRoom m2SUserRequest = new Actor_UserRequestReconnectionRoom();
                    m2SUserRequest.UserId      = message.UserId;
                    m2SUserRequest.UserActorId = matchRoom.GetPlayerInfo(message.UserId).SessionActorId;
                    ActorHelp.SendeActor(matchRoom.GameServeRoomActorId, m2SUserRequest);
                    if (matchRoom.IsVoteDissolveIn)//如果正在投票解散中 补发一条投票结果消息
                    {
                        ActorHelp.SendeActor(m2SUserRequest.UserActorId, matchRoom.VoteDissolveResult);
                    }
                }
                else
                {
                    response.RoomInfos = RoomInfoFactory.Creator(matchRoom);
                }
                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }