コード例 #1
0
        protected override void Run(Session session, C2G_GetRoomInfo_Req message, Action <G2C_GetRoomInfo_Res> reply)
        {
            G2C_GetRoomInfo_Res response = new G2C_GetRoomInfo_Res();

            try
            {
                if (!GateHelper.SingSession(session))
                {
                    response.Error   = ErrorCode.ERR_SessionError;
                    response.Message = " 当前的session已经断开  !!!";
                    reply(response);
                    return;
                }

                response.RoomData = (RoomData)RoomHelper.GetRoomInfo(message.GameId, message.AreaId, message.UserId, message.RoomId);

                if (response.RoomData == null)
                {
                    response.Error   = ErrorCode.ERR_GetRoomInfoError;
                    response.Message = " 获取房间信息失败  !!!";
                    reply(response);
                    return;
                }

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
コード例 #2
0
        protected override void Run(Session session, C2G_IsBoltback_Req message, Action <G2C_IsBoltback_Res> reply)
        {
            G2C_IsBoltback_Res response = new G2C_IsBoltback_Res();

            try
            {
                if (!GateHelper.SingSession(session))
                {
                    response.Error   = ErrorCode.ERR_SessionError;
                    response.Message = " 非法的 siesson 链接请求";
                    return;
                }

                var userInfo = Game.Scene.GetComponent <PlayerManagerComponent>().Get(message.UserId);

                if (userInfo == null)
                {
                    response.Error   = ErrorCode.ERR_IsBoltBackError;
                    response.Message = "玩家不在线。";
                    return;
                }

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
コード例 #3
0
        protected override void Run(Session session, C2G_DDZPrepare_Req message, Action <G2C_DDZPrepare_Res> reply)
        {
            G2C_DDZPrepare_Res response = new G2C_DDZPrepare_Res();

            try
            {
                if (!GateHelper.SingSession(session))
                {
                    response.Error   = ErrorCode.ERR_SessionError;
                    response.Message = " 当前的session已经断开  !!!";
                    reply(response);
                    return;
                }

                int restul = RoomHelper.Prepare(message.GameId, message.AreaId, message.RoomId, message.UserId);
                if (restul == -1)
                {
                    response.Error   = ErrorCode.ERR_DDZPrepareError;
                    response.Message = " 准备失败  !!!";
                    reply(response);
                    return;
                }

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
コード例 #4
0
        protected async override void Run(Session session, C2G_QuitRoom_Req message, Action <G2C_QuitRoom_Res> reply)
        {
            G2C_QuitRoom_Res response = new G2C_QuitRoom_Res();

            try
            {
                if (!GateHelper.SingSession(session))
                {
                    response.Error   = ErrorCode.ERR_SessionError;
                    response.Message = " 当前的session已经断开  !!!";
                    reply(response);
                    return;
                }

                var Result = await RoomHelper.QuitRoom(message.GameId, message.AreaId, message.UserId, message.RoomId);

                if (Result != "0" && Result != "1")
                {
                    response.Error   = ErrorCode.ERR_QuitRoomError;
                    response.Message = Result;
                    reply(response);
                    return;
                }

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
コード例 #5
0
        protected override void Run(Session session, C2G_DDZPlayCard_Req message, Action <G2C_DDZPlayCard_Res> reply)
        {
            G2C_DDZPlayCard_Res response = new G2C_DDZPlayCard_Res();

            try
            {
                if (!GateHelper.SingSession(session))
                {
                    response.Error   = ErrorCode.ERR_SessionError;
                    response.Message = " 当前的session已经断开  !!!";
                    reply(response);
                    return;
                }

                response = (G2C_DDZPlayCard_Res)RoomHelper.PlayCard(message.GameId, message.AreaId, message.RoomId, message);

                response.UserId = message.UserId;

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
コード例 #6
0
        protected async override void Run(Session session, C2G_ChangerRoom_Req message, Action <G2C_ChangerRoom_Res> reply)
        {
            G2C_ChangerRoom_Res response = new G2C_ChangerRoom_Res();

            try
            {
                if (!GateHelper.SingSession(session))
                {
                    response.Error   = ErrorCode.ERR_SessionError;
                    response.Message = " 当前的session已经断开  !!!";
                    reply(response);
                    return;
                }

                int[] restul = RoomHelper.ChangerRoom(message.GameId, message.AreaId, message.RoomId, session.Id);

                if (restul[0] == -1)
                {
                    response.Error   = ErrorCode.ERR_ChangerRoomError;
                    response.Message = "换桌失败";
                    reply(response);
                    return;
                }

                var myLastRoomInfo = Game.Scene.GetComponent <PlayerManagerComponent>().Get(message.UserId).GetComponent <MyLastJionRoom>().MyLastJionRoomList;

                if (myLastRoomInfo.Count == 0)
                {
                    myLastRoomInfo.Add(new MyLastJionRoomData());
                }

                myLastRoomInfo.First().GameId = message.GameId;
                myLastRoomInfo.First().AreaId = message.AreaId;
                myLastRoomInfo.First().RoomId = restul[0];


                response.GameId = message.GameId;
                response.AreaId = message.AreaId;
                response.RoomId = restul[0];
                response.Index  = restul[1];

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
コード例 #7
0
        protected override void Run(Session session, C2G_GetAreaList_Req message, Action <G2C_GetAreaList_Res> reply)
        {
            G2C_GetAreaList_Res response = new G2C_GetAreaList_Res();

            try
            {
                if (!GateHelper.SingSession(session))
                {
                    response.Error   = ErrorCode.ERR_SessionError;
                    response.Message = " 当前的session已经断开  !!!";
                    reply(response);
                    return;
                }

                foreach (var Area in Game.Scene.GetComponent <LobbyManagerCpt>().GetComponent <AreaManagerCpt>().areaList)
                {
                    if (Area.GameId != message.GameId)
                    {
                        continue;
                    }

                    AreaInfo areaInfo = new AreaInfo()
                    {
                        GameId   = Area.GameId,
                        AreaId   = Area.AreaId,
                        Score    = Area.Score,
                        AreaType = Area.AreaType
                    };

                    response.AreaInfo.Add(areaInfo);
                }

                if (response.AreaInfo.count == 0)
                {
                    response.Error   = ErrorCode.ERR_GetAreaError;
                    response.Message = "获取场信息失败 !!!";
                    reply(response);
                }

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
コード例 #8
0
        protected async override void Run(Session session, C2G_JionRoom_Req message, Action <G2C_JionRoom_Res> reply)
        {
            G2C_JionRoom_Res response = new G2C_JionRoom_Res();

            try
            {
                if (!GateHelper.SingSession(session))
                {
                    response.Error   = ErrorCode.ERR_SessionError;
                    response.Message = " 当前的session已经断开  !!!";
                    reply(response);
                    return;
                }

                int RoomId = RoomHelper.JionRoom(message.GameId, message.AreaId, message.UserId, session.Id, message.RoomId, out string errMsg);

                if (RoomId == -1)
                {
                    response.Error   = ErrorCode.ERR_JionRoomError;
                    response.Message = errMsg;
                    reply(response);
                    return;
                }

                var myLastRoomInfo = Game.Scene.GetComponent <PlayerManagerComponent>().Get(message.UserId).GetComponent <MyLastJionRoom>().MyLastJionRoomList;

                myLastRoomInfo.Clear();

                MyLastJionRoomData myLast = new MyLastJionRoomData()
                {
                    GameId = message.GameId,
                    AreaId = message.AreaId,
                    RoomId = RoomId
                };

                myLastRoomInfo.Add(myLast);

                response.RoomId = RoomId;

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
コード例 #9
0
        protected override async void Run(Session session, C2G_ResetPassword_Req message, Action <G2C_ResetPassword_Res> reply)
        {
            G2C_ResetPassword_Res response = new G2C_ResetPassword_Res();

            try
            {
                if (!GateHelper.SingSession(session))
                {
                    response.Error   = ErrorCode.ERR_SessionError;
                    response.Message = " 非法的 siesson 链接请求";
                    reply(response);
                    return;
                }

                DBProxyComponent dbProxy = Game.Scene.GetComponent <DBProxyComponent>();

                List <ComponentWithId> result = await dbProxy.Query <AccountInfo>(_account => _account.Id == message.UserId);

                AccountInfo account = result[0] as AccountInfo;

                if (account.Password != message.OldPassword)
                {
                    response.Error   = ErrorCode.ERR_ResetPasswordPError;
                    response.Message = "您的原始密码有误,请重新输入 !!!";
                    reply(response);
                    return;
                }
                if (message.NewPassword == account.Password)
                {
                    response.Error   = ErrorCode.ERR_ResetPasswordPError;
                    response.Message = "不能与原始密码相同 !!!";
                    reply(response);
                    return;
                }

                account.Password = message.NewPassword;
                await dbProxy.Save(account);

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
コード例 #10
0
        protected override async void Run(Session session, C2G_GetUserInfo_Req message, Action <G2C_GetUserInfo_Res> reply)
        {
            G2C_GetUserInfo_Res response = new G2C_GetUserInfo_Res();

            try
            {
                if (!GateHelper.SingSession(session))
                {
                    response.Error   = ErrorCode.ERR_SessionError;
                    response.Message = " 非法的 siesson 链接请求";
                    return;
                }

                ETModel.UserInfo userInfo = Game.Scene.GetComponent <PlayerManagerComponent>().Get(message.UserId);

                if (userInfo == null)
                {
                    response.Error   = ErrorCode.ERR_GetUserInfoError;
                    response.Message = $"查询用户信息失败,用户名{message.UserId}";
                    reply(response);
                    return;
                }

                response.UserInfo = new UserInfo()
                {
                    Account   = userInfo.Account,
                    PlayerId  = userInfo.PlayerId,
                    Nickname  = userInfo.Nickname,
                    HeadId    = userInfo.HeadId,
                    Gold      = userInfo.Gold,
                    Gender    = userInfo.Gender,
                    IsTourist = userInfo.IsTourist,
                };

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
コード例 #11
0
        protected override void Run(Session session, C2G_MailAsk_Req message, Action <G2C_MailReturn_Res> reply)
        {
            G2C_MailReturn_Res response = new G2C_MailReturn_Res();

            try
            {
                if (!GateHelper.SingSession(session))
                {
                    response.Error   = ErrorCode.ERR_SessionError;
                    response.Message = " 当前的session已经断开  !!!";
                    reply(response);
                    return;
                }

                ETModel.UserInfo userInfo = Game.Scene.GetComponent <PlayerManagerComponent>().Get(message.UserId);

                if (userInfo == null)
                {
                    response.Error   = ErrorCode.ERR_BindBankCardAskError;
                    response.Message = "用户不在线。";
                    reply(response);
                    return;
                }

                response.Info = new Google.Protobuf.Collections.RepeatedField <MailInfo>();

                userInfo.GetComponent <MyMailboxInfo>().MyMail.ForEach(u => response.Info.Add(new MailInfo()
                {
                    Content = u.Content, Timestamp = u.SendTime.ToString("yy-MM-dd HH:mm"), Title = u.Title
                }));

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
コード例 #12
0
        protected override void Run(Session session, C2G_Announcement_Req message, Action <G2C_Announcement_Res> reply)
        {
            G2C_Announcement_Res response = new G2C_Announcement_Res();

            try
            {
                if (!GateHelper.SingSession(session))
                {
                    response.Error   = ErrorCode.ERR_SessionError;
                    response.Message = " 当前的session已经断开  !!!";
                    reply(response);
                    return;
                }

                response.Info = new Google.Protobuf.Collections.RepeatedField <AnnounceInfo>();

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }