Exemplo n.º 1
0
        /// <summary>
        /// 请求准备
        /// </summary>
        public async void RequestPrepare(bool _IsPrepare = true)
        {
            var resp = (G2C_DDZPrepare_Res)await SessionComponent.Instance.Session.Call(
                new C2G_DDZPrepare_Req()
            {
                GameId    = DDZGameHelper.CurrentGameInfo.GameId,
                AreaId    = GameHelper.AreaList[DDZGameHelper.CurrentGameInfo.GameId][0].AreaId,
                UserId    = GamePrefs.GetUserId(),
                RoomId    = DDZGameHelper.RoomId,
                IsPrepare = _IsPrepare
            });

            if (resp.Error != 0)
            {
                Game.PopupComponent.ShowMessageBox(resp.Message);
                return;
            }

            //将准备面板销毁

            this.DDZReadyPlugin.Reset();

            //将准备标识显示出来

            this.DDZReadyPlugin.SetReadyByIndex(0, true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// token 登录-手机号
        /// </summary>
        /// <param name="account"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public static async Task <int> OnLoginAsyncToken(string account, string token)
        {
            int errcode = -1;

            try
            {
                ETModel.Session session = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(GlobalConfigComponent.Instance.GlobalProto.Address);

                Session realmSession = ComponentFactory.Create <Session, ETModel.Session>(session);

                G2C_TokenLogin_Res r2CLogin = (G2C_TokenLogin_Res)await realmSession.Call(new C2G_TokenLogin_Req()
                {
                    Account = account, Token = token
                });

                errcode = r2CLogin.Error;
                realmSession.Dispose();

                if (r2CLogin.Error != 0)
                {
                    Game.PopupComponent.ShowMessageBox(r2CLogin.Message);
                    return(r2CLogin.Error);
                }

                GamePrefs.SetUserId(r2CLogin.UserId);
                ETModel.Session gateSession = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(r2CLogin.Address);
                ETModel.Game.Scene.AddComponent <ETModel.SessionComponent>().Session = gateSession;

                Game.Scene.AddComponent <SessionComponent>().Session = ComponentFactory.Create <Session, ETModel.Session>(gateSession);

                Game.Scene.GetComponent <SessionComponent>().Session.AddComponent <SessionOfflineComponent>();

                G2C_LoginGate g2CLoginGate = (G2C_LoginGate)await SessionComponent.Instance.Session.Call(new C2G_LoginGate()
                {
                    Key = r2CLogin.Key, UserId = r2CLogin.UserId
                });

                errcode = g2CLoginGate.Error;
                if (g2CLoginGate.Error != 0)
                {
                    Game.PopupComponent.ShowMessageBox(g2CLoginGate.Message);

                    Game.Scene.GetComponent <SessionComponent>().Session.Dispose();
                    return(g2CLoginGate.Error);
                }

                if (Game.Scene.GetComponent <PingComponent>() == null)
                {
                    Game.Scene.AddComponent <PingComponent, long, Session, Action>(3000, Game.Scene.GetComponent <SessionComponent>().Session, null);
                }

                return(g2CLoginGate.Error);
            }
            catch (Exception e)
            {
                Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.NotConnectGateTip);
                Log.Error("无法连接到网关服务器: " + e.Message);
                return(errcode);
            }
        }
Exemplo n.º 3
0
        private async void OnDDZ_LevelButton()
        {
            try
            {
                Game.PopupComponent.ShowLoadingLockUI(DataCenterComponent.Instance.tipInfo.EnterSubGameTip);

                var response = (G2C_JionRoom_Res)await SessionComponent.Instance.Session.Call(
                    new C2G_JionRoom_Req()
                {
                    AreaId = GameHelper.AreaList[DDZGameHelper.CurrentGameInfo.GameId][0].AreaId,
                    GameId = DDZGameHelper.CurrentGameInfo.GameId,
                    UserId = GamePrefs.GetUserId(),
                });

                Game.PopupComponent.CloseLoadingLockUI();

                if (response.Error != 0)
                {
                    Game.PopupComponent.ShowMessageBox(response.Message);
                    return;
                }

                DDZGameHelper.RoomId = response.RoomId;

                GameLobbyFactory.Remove();

                DDZUIFactory.gameScene.Create();
            }
            catch (Exception e)
            {
                Game.PopupComponent.ShowMessageBox(e.Message);
                throw;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 点击获取邮件
        /// </summary>
        private async void GetMail()
        {
            Title01.SetActive(false);
            Title02.SetActive(true);
            RecyleRecordItem();
            //请求公告信息数据
            var resp = (G2C_MailReturn_Res)await SessionComponent.Instance.Session.Call(
                new C2G_MailAsk_Req()
            {
                UserId = GamePrefs.GetUserId()
            });

            if (resp.Error == 0)
            {
                NoMsgTips.SetActive(resp.Info.count == 0);
                for (int i = 0; i < resp.Info.Count; i++)
                {
                    CreateRecordListsItem(null, resp.Info[i], 2);
                }
            }
            else
            {
                Game.PopupComponent.ShowTips(resp.Message);
                return;
            }
        }
Exemplo n.º 5
0
        private void InitData()
        {
            //初始化自己的信息
            UserVO myVo = new UserVO()
            {
                userID = GamePrefs.GetUserId(),

                headId = UserDataHelper.UserInfo.HeadId,

                sex = UserDataHelper.UserInfo.Gender,

                gold = UserDataHelper.UserInfo.Gold,

                nickName = UserDataHelper.UserInfo.Nickname,

                seatID = 0
            };

            DataCenterComponent.Instance.userInfo.httpUserInfo = myVo;

            DataCenterComponent.Instance.userInfo.addUser(myVo);

            //播放背景音乐

            SoundComponent.Instance.Stop(DataCenterComponent.Instance.soundInfo.bg_hall);

            var _soundVolume = PlayerPrefs.GetFloat("SoundVolume", 1);

            this.CurrentSoundName = DataCenterComponent.Instance.soundInfo.ddzbg + UnityEngine.Random.Range(1, 3);

            SoundComponent.Instance.PlayMusic(this.CurrentSoundName, 0, _soundVolume, true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 请求出牌
        /// </summary>
        /// <param name="_PlayCardStatue">出牌状态 0-出牌 1-要不起</param>
        /// <param name="_PlayCard">要出的牌数组</param>
        public async void RequestPlayCard(int _PlayCardStatue, DDZCard _PlayCard)
        {
            var resp = (G2C_DDZPlayCard_Res)await SessionComponent.Instance.Session.Call(
                new C2G_DDZPlayCard_Req()
            {
                GameId         = DDZGameHelper.CurrentGameInfo.GameId,
                AreaId         = GameHelper.AreaList[DDZGameHelper.CurrentGameInfo.GameId][0].AreaId,
                UserId         = GamePrefs.GetUserId(),
                RoomId         = DDZGameHelper.RoomId,
                PlayCardStatue = _PlayCardStatue,
                PlayCard       = _PlayCard
            });

            //由于服务器修正了,这里还是走DDZOutCardError事件
            if (resp.Error != 0 && resp.Error != 200225)
            {
                Game.PopupComponent.ShowMessageBox(resp.Message);

                this.DDZHandCardPlugin.ReSelect();

                return;
            }

            if (resp.Error == 200225)
            {
                return;
            }

            //隐藏掉交互界面
            this.DDZInteractivePlugin.Hide();

            //刷新最新的手牌
            if (resp.Card != null)
            {
                DDZGameConfigComponent.Instance.myHandCard = resp.Card;

                //修改:用服务器返回的数据刷新
                //this.DDZHandCardPlugin.ShowHandCard(resp.Card);
            }

            //根据出的牌,将牌隐藏掉,如果是不出,则不移。
            if (_PlayCardStatue != 1)
            {
                this.DDZHandCardPlugin.RemoveCard2();//临时
            }
            else
            {
                this.DDZHandCardPlugin.ReSelect();
            }

            //刷新倍数

            DDZGameConfigComponent.Instance.Times = resp.Times;

            this.DDZTopPlugin.SetBeiSu();

            //播放语音
            this.PlayOutCardSound(resp.PlayCard);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 修改密码
        /// </summary>
        private async void OnChangePwd()
        {
            ETModel.Game.Scene.GetComponent <SoundComponent>().PlayClip(DataCenterComponent.Instance.soundInfo.click);
            if (_isRequest)
            {
                Game.PopupComponent.ShowTips(DataCenterComponent.Instance.tipInfo.ModifyPasswordNotRepeatTip);
                return;
            }

            OnEndEditOldPwdInputField(_oldPwdInput.text);
            OnEndEditNewPwdInputField(_newPwdInput.text);
            OnEndEditConfirmPwdInputField(_confirmPwdInput.text);

            if (!_oldPwdVertify || !_newPwdVertify || !_confirmPwdVertify)
            {
                return;
            }

            try
            {
                Game.PopupComponent.ShowLoadingLockUI();
                _isRequest = true;

                var response = (G2C_ResetPassword_Res)await SessionComponent.Instance.Session.Call(
                    new C2G_ResetPassword_Req()
                {
                    UserId      = GamePrefs.GetUserId(),
                    OldPassword = _oldPwdInput.text,
                    NewPassword = _newPwdInput.text
                });

                if (response.Error != 0)
                {
                    Game.PopupComponent.ShowMessageBox(response.Message);
                    _isRequest = false;
                    Game.PopupComponent.CloseLoadingLockUI();
                    return;
                }

                GamePrefs.SetUserPwd(_confirmPwdInput.text);

                Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.ModifyPasswordSuccTip);

                OnCloseMask();
                Game.PopupComponent.CloseLoadingLockUI();
            }
            catch (Exception e)
            {
                Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.ModifyPasswordFailTip);
                Debug.LogError("修改密码失败: " + e.Message);
                Game.PopupComponent.CloseLoadingLockUI();
                throw;
            }
            finally
            {
                _isRequest = false;
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 请求叫地主
        /// </summary>
        /// <param name="_Score">叫分 0-不抢</param>
        public async void RequestAskScore(int _Score = 0)
        {
            var resp = (G2C_DDZAskScore_Res)await SessionComponent.Instance.Session.Call(
                new C2G_DDZAskScore_Req()
            {
                GameId = DDZGameHelper.CurrentGameInfo.GameId,
                AreaId = GameHelper.AreaList[DDZGameHelper.CurrentGameInfo.GameId][0].AreaId,
                UserId = GamePrefs.GetUserId(),
                RoomId = DDZGameHelper.RoomId,
                Score  = _Score
            });

            if (resp.Error != 0)
            {
                Game.PopupComponent.ShowMessageBox(resp.Message);
                return;
            }

            //流局
            if (resp.NextChairId == -1)
            {
                Log.Debug("当前是流局啦!!!!");

                this.DDZCallScorePlugin.Hide();

                DDZGameConfigComponent.Instance.ActiveChairId = -1;

                this.DDZOpTipPlugin.Reset();

                return;
            }

            //显示叫了几分
            int realSeatID = DDZGameHelper.ChangeSeat(resp.ChairId);

            this.DDZOpTipPlugin.CallScoreById(realSeatID, _Score);

            //把叫分面板隐藏掉

            this.DDZCallScorePlugin.Hide();

            //如果下一个玩家的操作是出牌
            if (resp.DoType < 2)
            {
                //下一个玩家操作
                int nextSeatID = DDZGameHelper.ChangeSeat(resp.NextChairId);

                //高亮显示头像
                DDZGameConfigComponent.Instance.ActiveChairId = resp.NextChairId;

                Log.Debug("玩家" + nextSeatID + "操作!!");
            }

            //播放音效
            SoundComponent.Instance.PlayClip(soundInfo.DDZ_male_Call_prefix + _Score);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 试玩登录
        /// </summary>
        private async void OnVisitorLoginButton()
        {
            Game.PopupComponent.SetClickLock();
            ETModel.Game.Scene.GetComponent <SoundComponent>().PlayClip(DataCenterComponent.Instance.soundInfo.click);

            if (_isRequest)
            {
                Game.PopupComponent.ShowTips(DataCenterComponent.Instance.tipInfo.IsLoadingTip);
                return;
            }
            _isRequest = true;
            try
            {
                var account = GamePrefs.GetGuestAccount();
                var pwd     = GamePrefs.GetGuestPwd();
                if (!string.IsNullOrEmpty(account) && !string.IsNullOrEmpty(pwd))
                {
                    var errorCode = await LoginRequest(account, pwd, true);

                    return;
                }
                Game.PopupComponent.ShowLoadingLockUI();
                ETModel.Session session = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(GlobalConfigComponent.Instance.GlobalProto.Address);

                // 创建一个ETHotfix层的Session, ETHotfix的Session会通过ETModel层的Session发送消息
                Session realmSession = ComponentFactory.Create <Session, ETModel.Session>(session);

                var response = (G2C_TouristsLogin_Res)await realmSession.Call(new C2G_TouristsLogin_Req());

                if (response.Error != 0)
                {
                    Game.PopupComponent.ShowMessageBox(response.Message);
                    _isRequest = false;
                    Game.PopupComponent.CloseLoadingLockUI();
                    return;
                }
                _isRequest = false;
                GamePrefs.SetGuestAccount(response.Account);
                GamePrefs.SetGuestPwd(response.Password);
                await LoginRequest(response.Account, response.Password, true);

                Game.PopupComponent.CloseLoadingLockUI();
            }
            catch (Exception e)
            {
                _isRequest = false;
                Game.PopupComponent.CloseLoadingLockUI();
                Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.VisitorLoginFailTip);
                throw;
            }
            finally
            {
                _isRequest = false;
                Game.PopupComponent.CloseLoadingLockUI();
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 请求换桌
        /// </summary>
        public async void RequestChangeRoom()
        {
            G2C_ChangerRoom_Res response = (G2C_ChangerRoom_Res)await SessionComponent.Instance.Session.Call(new C2G_ChangerRoom_Req()
            {
                GameId = DDZGameHelper.CurrentGameInfo.GameId,

                AreaId = GameHelper.AreaList[DDZGameHelper.CurrentGameInfo.GameId][DDZGameHelper.CurrentFieldId].AreaId,

                RoomId = DDZGameHelper.RoomId,

                UserId = GamePrefs.GetUserId()
            });

            if (response.Error == 0)
            {
                Game.PopupComponent.ShowTips(DataCenterComponent.Instance.tipInfo.ChangeTableTip);

                //手动退出房间

                this._BackHall = false;

                this.QuitGame();

                try
                {
                    var respons = (G2C_JionRoom_Res)await SessionComponent.Instance.Session.Call(
                        new C2G_JionRoom_Req()
                    {
                        AreaId = GameHelper.AreaList[DDZGameHelper.CurrentGameInfo.GameId][DDZGameHelper.CurrentFieldId].AreaId,

                        GameId = DDZGameHelper.CurrentGameInfo.GameId,

                        UserId = GamePrefs.GetUserId(),

                        RoomId = response.RoomId
                    });

                    if (respons.Error != 0)
                    {
                        Game.PopupComponent.ShowMessageBox(respons.Message);
                        return;
                    }

                    DDZGameHelper.RoomId = respons.RoomId;

                    DDZUIFactory.gameScene.Create();
                }
                catch (Exception e)
                {
                    Game.PopupComponent.ShowMessageBox(e.Message);
                    throw;
                }
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// 确认切换头像
        /// </summary>
        private async void OnConfirmChangeHead()
        {
            ETModel.Game.Scene.GetComponent <SoundComponent>().PlayClip(DataCenterComponent.Instance.soundInfo.click);

            if (ChangeHeadIndex == UserDataHelper.UserInfo.HeadId)
            {
                ChangeHeadView.SetActive(false);
                NormalInfoView.SetActive(true);
                return;
            }

            if (_isRequest)
            {
                Game.PopupComponent.ShowTips(DataCenterComponent.Instance.tipInfo.NotRepeatModifyTip);
                return;
            }

            _isRequest = true;
            try
            {
                G2C_ChangerUserInfo_Res chagerHead = (G2C_ChangerUserInfo_Res)await SessionComponent.Instance.Session.
                                                     Call(new C2G_ChangerUserInfo_Req()
                {
                    UserId = GamePrefs.GetUserId(),
                    Type   = 0,
                    HeadId = ChangeHeadIndex
                });

                if (chagerHead.Error != 0)
                {
                    Debug.Log(chagerHead.Message);
                    //                    GameHelper.ShowMessageBox(chagerHead.Message);
                    Game.PopupComponent.ShowMessageBox(chagerHead.Message);
                    _isRequest = false;
                    return;
                }

                ChangeHeadView.SetActive(false);
                NormalInfoView.SetActive(true);
                _isRequest = false;
            }
            catch (Exception e)
            {
                Log.Debug("修改头像错误:" + e.Message);
                Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.ModifyHeadIdFailTip);
                _isRequest = false;
            }

            //            GameHelper.ShowMessageBox("修改头像成功!");
            Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.ModifyHeadIdSuccTip);

            // 刷新显示
            await UserDataHelper.GetUserInfo(true);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Resume 事件处理
        /// </summary>
        public async void OnApplicationResume()
        {
            Game.PopupComponent.ShowLoadingLockUI(DataCenterComponent.Instance.tipInfo.ResumeSceneTip);

            await Task.Delay(DataCenterComponent.Instance.gameInfo.ApplicationResumeWaitTime);

            GameHelper.ApplicationIsPause = false;

            var uiC = Game.Scene.GetComponent <UIComponent>();

            if (uiC.Get(UIType.UIMessageBoxPanel) != null)
            {
                Log.Info("存在断线重联界面,不走Resume逻辑!!");

                Game.PopupComponent.CloseLoadingLockUI();

                return;
            }

            //销毁当前界面,但不重新创建大厅,否则相关数据会被清掉

            this._BackHall = false;

            this.QuitGame();

            Game.PopupComponent.CloseLoadingLockUI();

            try
            {
                var response = (G2C_JionRoom_Res)await SessionComponent.Instance.Session.Call(
                    new C2G_JionRoom_Req()
                {
                    AreaId = GameHelper.AreaList[DDZGameHelper.CurrentGameInfo.GameId][0].AreaId,
                    GameId = DDZGameHelper.CurrentGameInfo.GameId,
                    UserId = GamePrefs.GetUserId(),
                });

                if (response.Error != 0)
                {
                    Game.PopupComponent.ShowMessageBox(response.Message);
                    return;
                }

                DDZGameHelper.RoomId = response.RoomId;

                DDZUIFactory.gameScene.Create();
            }
            catch (Exception e)
            {
                Game.PopupComponent.ShowMessageBox(e.Message);
                throw;
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// 通用加入房间方法
        /// </summary>
        /// <param name="areaIndex"></param>
        public async void RequestJoinRoom(int areaIndex)
        {
            ETModel.Game.Scene.GetComponent <SoundComponent>().PlayClip(DataCenterComponent.Instance.soundInfo.click);
            var index = GameHelper.AreaList[GameHelper.CurrentGameInfo.GameId].Count;

            if (index > areaIndex)
            {
                index = areaIndex;
            }
            else
            {
                index -= 1;
            }
            try
            {
                Game.PopupComponent.ShowLoadingLockUI(DataCenterComponent.Instance.tipInfo.EnterSubGameTip);

                var response = (G2C_JionRoom_Res)await SessionComponent.Instance.Session.Call(
                    new C2G_JionRoom_Req()
                {
                    AreaId = GameHelper.AreaList[GameHelper.CurrentGameInfo.GameId][index].AreaId,

                    GameId = GameHelper.CurrentGameInfo.GameId,

                    UserId = GamePrefs.GetUserId(),
                });

                Game.PopupComponent.CloseLoadingLockUI();

                if (response.Error != 0)
                {
                    Game.PopupComponent.ShowMessageBox(response.Message);

                    return;
                }

                GameHelper.CurrentAreaInfo = GameHelper.AreaList[GameHelper.CurrentGameInfo.GameId][index];

                GameHelper.CurrentRoomId = response.RoomId;

                GameHelper.CurrentFieldId = index;

                this.EnterSubGame();

                Game.EventSystem.Run(EventIdType.RemoveGameLobby);
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);

                Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.JoinRoomFailTip);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// 内部获取用户信息
        /// </summary>
        /// <returns></returns>
        private static async ETTask <bool> INTERNAL_GET_USERINFO()
        {
            Game.PopupComponent.ShowLoadingLockUI();
            try
            {
                var getUserInfoRes = (G2C_GetUserInfo_Res)await SessionComponent.Instance.Session.Call
                                         (new C2G_GetUserInfo_Req()
                {
                    UserId = GamePrefs.GetUserId()
                });

                if (getUserInfoRes.Error != 0)
                {
                    Debug.LogError(getUserInfoRes.Message);
                    //                    GameHelper.ShowMessageBox(getUserInfoRes.Message);
                    Game.PopupComponent.ShowMessageBox(getUserInfoRes.Message);
                    Game.PopupComponent.CloseLoadingLockUI();
                    return(false);
                }

                // 获取用户信息成功
                UserInfo = getUserInfoRes.UserInfo;

                // 设置我的数据
                SetMyDataCenter();

                // 通知所有引用
                for (var i = _dependViews.Count - 1; i >= 0; i--)
                {
                    if (_dependViews[i].HeadImg == null ||
                        _dependViews[i].NickNameText == null ||
                        _dependViews[i].GoldText == null)
                    {
                        _dependViews.RemoveAt(i);
                        continue;
                    }

                    INTERNAL_SET_USERINFOVIEW(_dependViews[i], UserInfo);
                }

                Game.PopupComponent.CloseLoadingLockUI();
                return(true);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.GetPlayerInfoFailTip);
                Game.PopupComponent.CloseLoadingLockUI();
                throw;
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// 战绩请求用例
        /// </summary>
        /// <returns></returns>
        private async Task StressTest_MyRecordReq()
        {
            var resp = (G2C_MyRecord_Res)await SessionComponent.Instance.Session.Call
                       (
                new C2G_MyRecord_Req()
            {
                UserId = GamePrefs.GetUserId(),
            });

            if (resp.Error == 0)
            {
                Log.Debug("获取战绩成功=>数量:" + resp.Recordlist.Count);
            }
            else
            {
                Log.Debug("获取战绩失败" + resp.Message);
            }
        }
Exemplo n.º 16
0
        public async void Start()
        {
            RecyleRecordItem();
            //请求战绩数据
            var resp = (G2C_MyRecord_Res)await SessionComponent.Instance.Session.Call
                       (
                new C2G_MyRecord_Req()
            {
                UserId = GamePrefs.GetUserId(),
            });

            if (resp.Error == 0)
            {
                _RecordViewTipsText.SetActive(resp.Recordlist.Count == 0);
                for (int i = 0; i < resp.Recordlist.Count; i++)
                {
                    CreateRecordListsItem(resp.Recordlist[i], i);
                }
            }
        }
Exemplo n.º 17
0
        public async void ShowMessageBox()
        {
            if (this.backData == null)
            {
                return;
            }

            //增加:先向服务器验证,如果通过再弹窗口

            var response = (G2C_IsBoltback_Res)await SessionComponent.Instance.Session.Call(
                new C2G_IsBoltback_Req()
            {
                AreaId = this.backData.AreaId,
                GameId = this.backData.GameId,
                UserId = GamePrefs.GetUserId(),
                RoomId = this.backData.RoomId
            });

            if (!response.IsBoltback)
            {
                Log.Debug("服务器验证失败,不弹重回窗口!!");

                return;
            }

            MessageData messData = new MessageData();

            messData.onlyOk = false;

            messData.ok = OkAction;

            messData.cancel = NoAction;

            messData.titleStr = DataCenterComponent.Instance.tipInfo.Tips;

            messData.mes = DataCenterComponent.Instance.tipInfo.HasGameRebackTip;

            messData.okStr = DataCenterComponent.Instance.tipInfo.OkStrTip;

            Game.PopupComponent.ShowMessageBox(messData.mes, messData);
        }
Exemplo n.º 18
0
        /// <summary>
        /// 离开游戏
        /// </summary>
        private async void QuitGame()
        {
            var resp = (G2C_QuitRoom_Res)await SessionComponent.Instance.Session.Call(
                new C2G_QuitRoom_Req()
            {
                GameId = DDZGameHelper.CurrentGameInfo.GameId,

                AreaId = GameHelper.AreaList[DDZGameHelper.CurrentGameInfo.GameId][DDZGameHelper.CurrentFieldId].AreaId,

                UserId = GamePrefs.GetUserId(),

                RoomId = DDZGameHelper.RoomId
            });

            if (resp.Error == 0)
            {
                this.FastQuitGame();
            }
            else
            {
                Game.PopupComponent.ShowTips(resp.Message);
            }
        }
Exemplo n.º 19
0
        public async void Init()
        {
            DDZGameHelper.IsGetRoomDetails = false;

            DDZGameHelper.IsJoinRoom = true;

            Game.PopupComponent.ShowNoticeUI(DataCenterComponent.Instance.MarqueeInfo.SubGameDefault);

            //进入存储重回数据
            this.SaveReBackData();

            //请求房间详情
            var resp = (G2C_GetRoomInfo_Res)await SessionComponent.Instance.Session.Call(
                new C2G_GetRoomInfo_Req()
            {
                GameId = DDZGameHelper.CurrentGameInfo.GameId,
                AreaId = GameHelper.AreaList[DDZGameHelper.CurrentGameInfo.GameId][DDZGameHelper.CurrentFieldId].AreaId,
                UserId = GamePrefs.GetUserId(),
                RoomId = DDZGameHelper.RoomId
            });

            On_G2C_GetRoomInfo_Res(resp);
        }
Exemplo n.º 20
0
        /// <summary>
        /// 重新加入房间
        /// </summary>
        /// <param name="GameId"></param>
        /// <param name="AreaId"></param>
        /// <param name="RoomId"></param>
        private async void RequestJoinRoom(int GameId, int AreaId, int RoomId = 0, int Index = 0)
        {
            try
            {
                var response = (G2C_JionRoom_Res)await SessionComponent.Instance.Session.Call(
                    new C2G_JionRoom_Req()
                {
                    AreaId = AreaId,
                    GameId = GameId,
                    UserId = GamePrefs.GetUserId(),
                    RoomId = RoomId
                });

                //去掉小菊花,并清掉缓存
                Game.PopupComponent.CloseLoadingLockUI();

                if (response.Error != 0)
                {
                    Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.GameRebackErrorTip);

                    this.ClearReBackData();

                    return;
                }

                //将子游戏重回处理,分发到各子游戏模块
                Game.EventSystem.Run(EventIdType.HandleSubGameReBack, GameId, response.RoomId, backData);
            }
            catch (Exception e)
            {
                Game.PopupComponent.CloseLoadingLockUI();

                Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.GameRebackErrorTip);

                throw;
            }
        }
Exemplo n.º 21
0
        public void Awake()
        {
            _rf = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>();

            Root = _rf.Get <GameObject>("Root");

            QRCode   = _rf.Get <GameObject>("QRCode").GetComponent <Image>();
            CodeText = _rf.Get <GameObject>("CodeText").Get <Text>();

            QRCode.sprite = ETModel.Game.Scene.GetComponent <QRCodeComponent>().GenerateQRImage(GameHelper.GetShareQRCodeURL() + GamePrefs.GetUserId(), 512, 512);
            CodeText.text = UserDataHelper.UserInfo.PlayerId.ToString();
            ButtonHelper.RegisterButtonEvent(_rf, "mask", OnClose);
        }
Exemplo n.º 22
0
        /// <summary>
        /// 确认修改用户名
        /// </summary>
        private async void OnConfirmChangeName()
        {
            ETModel.Game.Scene.GetComponent <SoundComponent>().PlayClip(DataCenterComponent.Instance.soundInfo.click);

            var changeName = NameInputField.text.Trim();

            if (string.IsNullOrEmpty(changeName) || changeName.Equals(PlayerName.text))
            {
                Game.PopupComponent.ShowMessageBox("昵称不可为空");
                OnCancelChangeName();
                return;
            }

            var isMatch = Regex.IsMatch(NameInputField.text, _nameRegexStr);

//            if (!isMatch)
//            {
//                var matchA = Regex.IsMatch(_changeNameInput.text, _nameRegexStrGroupA);
//                if (matchA)
//                {
//                    // 找到了汉字和字母数字的混合
//                    isMatch = Regex.IsMatch(_changeNameInput.text, _nameRegexStrGroupB);
//                }
//            }

            if (!isMatch)
            {
                Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.NickNameNotMatchTip);
                return;
            }

            if (_isRequest)
            {
                Game.PopupComponent.ShowTips(DataCenterComponent.Instance.tipInfo.NotRepeatModifyTip);
                return;
            }

            _isRequest = true;
            try
            {
                Game.PopupComponent.ShowLoadingLockUI();
                G2C_ChangerUserInfo_Res chagerHead = (G2C_ChangerUserInfo_Res)await SessionComponent.Instance.Session.
                                                     Call(new C2G_ChangerUserInfo_Req()
                {
                    UserId   = GamePrefs.GetUserId(),
                    Type     = 1,
                    NickName = changeName
                });

                if (chagerHead.Error != 0)
                {
                    Debug.Log(chagerHead.Message);
                    //                    GameHelper.ShowMessageBox(chagerHead.Message);
                    Game.PopupComponent.ShowMessageBox(chagerHead.Message);
                    _isRequest = false;
                    Game.PopupComponent.CloseLoadingLockUI();
                    return;
                }

                _isRequest = false;
                await UserDataHelper.GetUserInfo(true);

                Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.ModifyNickNameSuccTip);
                PlayerName.gameObject.SetActive(true);
                _changePlayerName.SetActive(true);
                _changeNameInput.text = "";
                _changeNameInput.gameObject.SetActive(false);
                _confirmChangeName.SetActive(false);
                _cancelChangeName.SetActive(false);
                ChangeNameView.SetActive(false);
                Game.PopupComponent.CloseLoadingLockUI();
            }
            catch (Exception e)
            {
                Log.Debug($"修改昵称错误:{e.Message}");
                Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.ModifyNickNameFailTip);
                _isRequest = false;
                Game.PopupComponent.CloseLoadingLockUI();
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// 普通账号游客登录
        /// </summary>
        /// <param name="account"></param>
        /// <param name="pwd"></param>
        /// <param name="isGuest"></param>
        /// <returns></returns>
        public static async Task <int> OnLoginAsync(string account, string pwd, bool isGuest = false)
        {
            int errcode = -1;

            try
            {
                // 创建一个ETModel层的Session
                ETModel.Session session = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(GlobalConfigComponent.Instance.GlobalProto.Address);

                // 创建一个ETHotfix层的Session, ETHotfix的Session会通过ETModel层的Session发送消息
                Session realmSession = ComponentFactory.Create <Session, ETModel.Session>(session);

                //向服务器申请了一个Key
                R2C_Login r2CLogin = (R2C_Login)await realmSession.Call(new C2R_Login()
                {
                    Account = account, Password = pwd
                });

                errcode = r2CLogin.Error;
                realmSession.Dispose();

                if (r2CLogin.Error != 0)
                {
                    if (isGuest && r2CLogin.Error == ErrorCode.ERR_AccountDoesnExist)
                    {
                        return(r2CLogin.Error);
                    }
                    Game.PopupComponent.ShowMessageBox(r2CLogin.Message);
                    return(r2CLogin.Error);
                }

                GamePrefs.SetUserId(r2CLogin.UserId);

                // 创建一个ETModel层的Session,并且保存到ETModel.SessionComponent中
                ETModel.Session gateSession = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(r2CLogin.Address);
                ETModel.Game.Scene.AddComponent <ETModel.SessionComponent>().Session = gateSession;

                // 创建一个ETHotfix层的Session, 并且保存到ETHotfix.SessionComponent中
                Game.Scene.AddComponent <SessionComponent>().Session = ComponentFactory.Create <Session, ETModel.Session>(gateSession);

                //增加客户端断线处理组件
                Game.Scene.GetComponent <SessionComponent>().Session.AddComponent <SessionOfflineComponent>();


                G2C_LoginGate g2CLoginGate = (G2C_LoginGate)await SessionComponent.Instance.Session.Call(new C2G_LoginGate()
                {
                    Key = r2CLogin.Key, UserId = r2CLogin.UserId
                });

                errcode = g2CLoginGate.Error;
                if (g2CLoginGate.Error != 0)
                {
                    Game.PopupComponent.ShowMessageBox(g2CLoginGate.Message);

                    Game.Scene.GetComponent <SessionComponent>().Session.Dispose();
                    return(g2CLoginGate.Error);
                }

                if (Game.Scene.GetComponent <PingComponent>() == null)
                {
                    Game.Scene.AddComponent <PingComponent, long, Session, Action>(3000, Game.Scene.GetComponent <SessionComponent>().Session, null);
                }

                return(g2CLoginGate.Error);
            }
            catch (Exception e)
            {
                //                if (e.Message.Equals("ERR_AccountDoesnExist")) throw;
                Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.NotConnectGateTip);
                Log.Error("无法连接到网关服务器: " + e.Message);
                return(errcode);
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// 点击注册按钮
        /// </summary>
        private async void OnRegisterButton()
        {
            ETModel.Game.Scene.GetComponent <SoundComponent>().PlayClip(DataCenterComponent.Instance.soundInfo.click);
            if (_isRequest)
            {
                Game.PopupComponent.ShowTips(DataCenterComponent.Instance.tipInfo.IsLoadingTip);
                return;
            }

            OnEndEditAccountInputField(accoutIF.text);
            OnEndEditPasswordInputField(passIF.text);
            OnEndEditCaptchaInputField(repeatIF.text);

            if (!_accountVertify || !_passwordVertify || !_captchaVertify)
            {
                return;
            }

            Game.PopupComponent.ShowLoadingLockUI();
            _isRequest = true;
            try
            {
                // 创建一个ETModel层的Session
                ETModel.Session session = ETModel.Game.Scene.GetComponent <NetOuterComponent>()
                                          .Create(GlobalConfigComponent.Instance.GlobalProto.Address);

                // 创建一个ETHotfix层的Session, ETHotfix的Session会通过ETModel层的Session发送消息
                Session realmSession = ComponentFactory.Create <Session, ETModel.Session>(session);

                // 发送注册请求
                R2C_Register_Res r2CRegisterRes = (R2C_Register_Res)await realmSession.Call(
                    new C2R_Register_Req()
                {
                    Account  = this.accoutIF.text,
                    Password = this.passIF.text
                });

                if (r2CRegisterRes.Error != 0)
                {
                    Game.PopupComponent.ShowMessageBox(r2CRegisterRes.Message);
                    //                    GameHelper.ShowMessageBox(r2CRegisterRes.Message);
                }
                else if (r2CRegisterRes.Error == 0)
                {
                    //注册上报
                    var openInstall = ETModel.Game.Scene.GetComponent <OpenInstallComponent>();
                    openInstall.reportRegister();

                    // 登录
                    GamePrefs.SetUserAccount(accoutIF.text);
                    GamePrefs.SetUserPwd(passIF.text);
                    //                    OnBackButton();
                    //this.GetParent<UILoginCpt>().RegisterLogin();
                }
                Game.PopupComponent.CloseLoadingLockUI();
            }
            catch (Exception e)
            {
                Game.PopupComponent.CloseLoadingLockUI();
                Debug.LogError("无法连接到服务器: " + e.Message);
                Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.ConnectServerFailTip);
            }
            finally
            {
                Game.PopupComponent.CloseLoadingLockUI();
                _isRequest = false;
            }
        }
Exemplo n.º 25
0
 /// <summary>
 /// 账号不存在
 /// </summary>
 private void AccountIsNotExist()
 {
     GamePrefs.ClearGuestInfo();
 }