Beispiel #1
0
        private static void OnGetLoginNoticeInfo(string url, string error, string reply, object userData)
        {
            bool fromServerList = (bool)userData;

            if (string.IsNullOrEmpty(error) == false)
            {
                UIManager.Instance.ShowWaitScreen(false);

                GameDebug.LogError("获取游戏公告失败: " + error);
                string err = DBConstText.GetText("GET_LOGIN_NOTICE_INFO_FAIL");
#if UNITY_EDITOR
                err += error;
#endif
                UIWidgetHelp.GetInstance().ShowNoticeDlg(err);

                return;
            }

            LoginNoticeData data;
            if (!CheckData(reply, out data))
            {
                UIManager.Instance.ShowWaitScreen(false);

                GameDebug.LogError("获取游戏公告失败: " + error);
                string err = DBConstText.GetText("GET_LOGIN_NOTICE_INFO_FAIL");

                UIWidgetHelp.GetInstance().ShowNoticeDlg(err);

                return;
            }

            if (AuditManager.Instance.AuditAndIOS() && SDKHelper.GetSwitchModel())
            {
                return;
            }

            //获取成功解析成功

            UIManager.Instance.ShowWindow("UILoginNoticeWindow", data, false);

            //if (string.IsNullOrEmpty(data.content) == false)
            //{
            //}
        }
            // 点击选择角色按钮
            public void OnClickActor(int btnIdx)
            {
                if (btnIdx < Game.GetInstance().CharactorMaxCount)
                {
                    OnClickActorImpl(btnIdx);
                }
                else
                {
                    SetReomveBtnActive(false);

                    string text = DBConstText.GetText("CREATE_ACTOR_SLOT_EMPTY");
                    if (string.IsNullOrEmpty(text))
                    {
                        text = xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_92");
                    }

                    UIWidgetHelp.GetInstance().ShowNoticeDlg(UINoticeWindow.EWindowType.WT_OK, text, null, null);
                }
            }
Beispiel #3
0
        public void BuyGood(uint id, uint whiteGold, uint diamond)
        {
            Actor local = Game.GetInstance().GetLocalPlayer();

            if (LocalPlayerManager.Instance.LocalActorAttribute.Sin <= 0)
            {
                UINotice.Instance.ShowMessage(DBConstText.GetText("EVIL_TOO_LOW_TO_BUY"));
                return;
            }
            //deicide
            lastBuyGoodId = id;
            if (LocalPlayerManager.Instance.GetMoneyByConst(GameConst.MONEY_COIN) < whiteGold)
            {
                UIWidgetHelp.GetInstance().ShowNoticeDlg(xc.ui.ugui.UINoticeWindow.EWindowType.WT_OK_Cancel, string.Format(DBConstText.GetText("BUY_WITH_GOLD_ASK"), diamond), BuyWithDiamond, diamond);
            }
            else
            {
                BuyGood(id);
            }
        }
            void OnClickCreateNewRoleButton()
            {
                string char_name = mNameInputField.text;

                // 判断是否输入了角色名
                if (char_name.Length <= 0)
                {
                    ui.UIWidgetHelp.GetInstance().ShowNoticeDlg(DBConstText.GetText("CREATE_ROLE_FAIL1")); //请输入角色名
                    return;
                }

                // 韩国版的角色名字和聊天敏感字库读取不同的表,其他
                if (Const.Region == RegionType.KOREA)
                {
                    // 判断角色名字是否合法
                    if (SensitiveWordsFilterPlayerName.Instance.IsInputUserNameLegal(char_name) == false)
                    {
                        ui.UIWidgetHelp.GetInstance().ShowNoticeDlg(DBConstText.GetText("CREATE_ROLE_FAIL2")); //角色名请使用汉字,英文或者数字
                        return;
                    }

                    // 判断角色名中的敏感字符
                    if (SensitiveWordsFilterPlayerName.GetInstance().IsHaveSensitiveWords(char_name))
                    {
                        ui.UIWidgetHelp.GetInstance().ShowNoticeDlg(DBConstText.GetText("CREATE_ROLE_FAIL3"));//角色名中包含敏感字符
                        return;
                    }
                }
                else
                {
                    // 判断角色名字是否合法
                    if (SensitiveWordsFilter.Instance.IsInputUserNameLegal(char_name, Const.Region) == false)
                    {
                        ui.UIWidgetHelp.GetInstance().ShowNoticeDlg(DBConstText.GetText("CREATE_ROLE_FAIL2")); //角色名请使用汉字,英文或者数字
                        return;
                    }

                    // 判断角色名中的敏感字符
                    if (SensitiveWordsFilter.GetInstance().IsHaveSensitiveWords(char_name))
                    {
                        ui.UIWidgetHelp.GetInstance().ShowNoticeDlg(DBConstText.GetText("CREATE_ROLE_FAIL3"));//角色名中包含敏感字符
                        return;
                    }
                }

                // 判断角色名字是否超长
                var   utf8_parse    = new Utf8Parse(char_name);
                float role_name_len = utf8_parse.GetWordLenByRule();

                if (role_name_len > (float)GameConstHelper.GetFloat("GAME_NAME_MAX_COUNT"))
                {
                    UIWidgetHelp.GetInstance().ShowNoticeDlg(DBConstText.GetText("NAME_COUNT_EXCEED"));
                    GameDebug.Log("role_name_len:" + role_name_len);
                    return;
                }

                if (GlobalConfig.GetInstance().LoginInfo == null || GlobalConfig.GetInstance().LoginInfo.ServerInfo == null)
                {
                    return;
                }

                mVocationId = 4;

                // 发送创建角色的协议
                var create_role = new C2SCreateRole();

                create_role.name      = System.Text.Encoding.UTF8.GetBytes(char_name);;
                create_role.rid       = mVocationId; // actor type, 从1开始
                create_role.server_id = (uint)GlobalConfig.GetInstance().LoginInfo.ServerInfo.SId;
                if (string.IsNullOrEmpty(GlobalConfig.GetInstance().LoginInfo.ProviderPassport))
                {
                    create_role.chn_passport = System.Text.Encoding.UTF8.GetBytes("provider_passport");
                }
                else
                {
                    create_role.chn_passport = System.Text.Encoding.UTF8.GetBytes(GlobalConfig.GetInstance().LoginInfo.ProviderPassport);
                }


                if (AuditManager.Instance.AuditAndIOS())
                {
                    SDKConfig sdkConfig = SDKHelper.GetSDKConfig();
                    if (sdkConfig != null)
                    {
                        create_role.majia_id   = sdkConfig.copy_bag_id;
                        create_role.majia_pack = sdkConfig.copy_bag_id;
                    }
                }
                else
                {
                    SDKConfig sdkConfig = SDKHelper.GetSDKConfig();
                    if (sdkConfig != null)
                    {
                        create_role.majia_id   = 0;
                        create_role.majia_pack = sdkConfig.copy_bag_id;
                    }
                }
                ControlServerLogHelper.CreatePkgAccPhoneInfos(create_role.phone_info);

                NetClient.GetBaseClient().SendData <C2SCreateRole>(NetMsg.MSG_CREATE_ROLE, create_role);

                // 保存创建角色的名字
                GlobalConfig.GetInstance().LoginInfo.Name = char_name;

                // 记录上一次选中的职业
                GlobalSettings.GetInstance().LastActorIndex = Game.GetInstance().CharacterList.Count;
                GlobalSettings.GetInstance().Save();

                Game.Instance.IsCreateRoleEnter = true;


                UIManager.Instance.ShowWaitScreen(true);

                // 点击创角按钮
                ControlServerLogHelper.Instance.PostPlayerFollowRecord(PlayerFollowRecordSceneId.ClickCreateActorButton);
                ControlServerLogHelper.Instance.PostCloudLadderEventAction(CloudLadderMarkEnum.create_role);

                // 点击选角按钮
                ControlServerLogHelper.Instance.PostPlayerFollowRecord(PlayerFollowRecordSceneId.ClickSelectActorButton);
                ControlServerLogHelper.Instance.PostCloudLadderEventAction(CloudLadderMarkEnum.select_role);
            }
Beispiel #5
0
        private void OnGetLoginNoticeInfo(string url, string error, string reply, object userData)
        {
            if (string.IsNullOrEmpty(error) == false)
            {
                UIManager.Instance.ShowWaitScreen(false);

                GameDebug.LogError("获取游戏公告失败: " + error);
                string err = DBConstText.GetText("GET_LOGIN_NOTICE_INFO_FAIL");
#if UNITY_EDITOR
                err += error;
#endif

                UIWidgetHelp.GetInstance().ShowNoticeDlg(err, (object obj) => {
                    //获取公告信息失败,获取服务器信息
                    UpdateServerLogic();
                });
                return;
            }
            GameDebug.Log("游戏公告获取成功");

            //判断是否需要弹出通告界面
            LoginNoticeData data;

            if (!LoginNoticeUtil.CheckData(reply, out data))
            {
                UIManager.Instance.ShowWaitScreen(false);

                GameDebug.LogError("获取游戏公告失败: " + reply);
                string err = DBConstText.GetText("GET_LOGIN_NOTICE_INFO_FAIL");
#if UNITY_EDITOR
                err += reply;
#endif
                UIWidgetHelp.GetInstance().ShowNoticeDlg(err, (object obj) => {
                    //获取公告信息失败,获取服务器信息
                    UpdateServerLogic();
                });
                return;
            }

            int lastId = PlayerPrefs.GetInt(LoginNoticeData.LOGIN_ID_KEY, LoginNoticeData.DEFAULT_LOGIN_ID);

            //判断自动弹出
            if (lastId == LoginNoticeData.DEFAULT_LOGIN_ID)
            {
                //第一次都弹出
                ShowNoticePanel(data, true);
            }
            else
            {
                //第二次判断是否为强制,或者通告信息发生了改变
                if (data.type == 1)
                {
                    ShowNoticePanel(data, true);
                }
                else
                {
                    //通告没有变化而且不是强制弹出,开始获取服务器信息
                    //设置当前弹出ID
                    //UpdateServerLogic();
                }

                ////第二次判断是否为强制,或者通告信息发生了改变
                //if (data.id != lastId || data.type == 1)
                //{
                //    ShowNoticePanel(data, true);
                //}
                //else
                //{
                //    //通告没有变化而且不是强制弹出,开始获取服务器信息
                //    //设置当前弹出ID
                //    //UpdateServerLogic();
                //}
            }

            // 总是获取服务器信息
            UpdateServerLogic();

            //PlayerPrefs.SetInt(LoginNoticeData.LOGIN_ID_KEY, data.id);
            UIManager.Instance.ShowWaitScreen(false);
        }
Beispiel #6
0
        public void ProcessServerData(ushort protocol, byte[] data)
        {
#if UNITY_EDITOR
            if (GlobalConfig.Instance.IsDebugMode)
            {
                GameDebug.Log("S------>C: " + protocol);
            }
#endif
#if UNITY_STANDALONE_WIN
            PackRecorder.RecordRecvPack(protocol, data);
#elif TEST_HOST && UNITY_ANDROID
            var pack_recorder = xc.Game.Instance.PackRecorder;
            if (!pack_recorder.NotRecordDict.ContainsKey(protocol))
            {
                GameDebug.Log("S------>C: " + protocol);
            }
#endif
            //处理错误信息
            if (protocol == NetMsg.MSG_SYS_ERROR)
            {
                S2CSysError errReport = S2CPackBase.DeserializePack <S2CSysError>(data);

                xc.ui.ugui.UIManager.Instance.ShowWaitScreen(false);

                switch (errReport.err_code)
                {
                case ErrorCode.ERR_QUEUE_MAX:    // 服务器人数达到上限后,会马上断开网络
                {
                    mQueueMax = true;
                }
                break;

                case ErrorCode.ERR_ACCOUNT_LOGIN_AGAIN:    // 顶号之后,会马上断开网络
                {
                    mLoginConflict = true;
                    string notice = DBErrorCode.GetErrorString((uint)ErrorCode.ERR_ACCOUNT_LOGIN_AGAIN);
                    if (!string.IsNullOrEmpty(notice))
                    {
                        mLoginConflictNotice = notice;
                    }
                }
                break;

                case ErrorCode.ERR_SERVER_MANTAIN:    // 服务器维护
                {
                    mMaintainServer = true;
                    string notice = DBErrorCode.GetErrorString((uint)ErrorCode.ERR_SERVER_MANTAIN);
                    if (!string.IsNullOrEmpty(notice))
                    {
                        mMaintainServerNotice = notice;
                    }
                }
                break;

                default:
                {
                    string content = "";

                    // 错误码为0时,直接使用服务端发送过来的错误信息
                    if (errReport.err_code == 0)
                    {
                        if (errReport.err_msg == null)
                        {
                            content = xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_35") + errReport.err_code;
                        }
                        else
                        {
                            content = System.Text.Encoding.UTF8.GetString(errReport.err_msg);
                        }
                    }
                    else
                    {
                        DBErrorCode           db        = (DBErrorCode)DBManager.GetInstance().GetDB(typeof(DBErrorCode).Name);
                        DBErrorCode.ErrorInfo errorInfo = db.GetErrorInfo(errReport.err_code);
                        if (errorInfo == null)
                        {
                            content = xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_35") + errReport.err_code;
                        }
                        else
                        {
                            content = errorInfo.mDesc;
                        }
                    }

                    if (errReport.@params != null && [email protected] > 0)
                    {
                        int paramsCount = [email protected];
                        if (paramsCount == 1)
                        {
                            content = string.Format(content, System.Text.Encoding.UTF8.GetString(errReport.@params[0]));
                        }
                        else if (paramsCount == 2)
                        {
                            content = string.Format(content, System.Text.Encoding.UTF8.GetString(errReport.@params[0]), System.Text.Encoding.UTF8.GetString(errReport.@params[1]));
                        }
                        else if (paramsCount == 3)
                        {
                            content = string.Format(content, System.Text.Encoding.UTF8.GetString(errReport.@params[0]), System.Text.Encoding.UTF8.GetString(errReport.@params[1]), System.Text.Encoding.UTF8.GetString(errReport.@params[2]));
                        }
                        else
                        {
                            GameDebug.LogError("MSG_SYS_ERROR 参数过多!!!");
                        }
                    }

                    string log = string.Format(xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_36"), content);
                    UINotice.GetInstance().ShowMessage(content);
                    ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_SYS_ERROR, new CEventBaseArgs(errReport.err_code));
                    GameDebug.LogWarning(log);
                    break;
                }
                }
                return;
            }
            //处理Debug信息
            else if (protocol == NetMsg.MSG_SYS_DEBUG)
            {
                S2CSysDebug msg = S2CPackBase.DeserializePack <S2CSysDebug>(data);

                xc.ui.ugui.UIManager.Instance.ShowWaitScreen(false);

                string content = System.Text.Encoding.UTF8.GetString(msg.err);
                string log     = string.Format(xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_37"), content);
                //UINotice.GetInstance().ShowMessage(content);
                GameDebug.LogWarning(log);
            }
            // 登录验证失败
            else if (protocol == NetMsg.MSG_ACC_LOGIN_FAIL)
            {
                S2CAccLoginFail loginFail = S2CPackBase.DeserializePack <S2CAccLoginFail>(data);
                uint            reason    = loginFail.reason;
                if (reason != 1)
                {
                    UIWidgetHelp.GetInstance().ShowNoticeDlg(xc.ui.ugui.UINoticeWindow.EWindowType.WT_OK, xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_38"), OnClickSDKRelogin, null);
                }

                return;
            }

            bool process = false;
            List <DataReplyDelegate> funcs;
            if (mNetHandlers.TryGetValue(protocol, out funcs))
            {
                // Broacast the net notify.
                for (int i = 0; i < funcs.Count; ++i)
                {
                    DataReplyDelegate func = funcs [i];
                    func(protocol, data);

                    // 这里不再catch异常,不然有报错不好找
                    //try
                    //{
                    //    func(protocol, data);
                    //}
                    //catch (System.Exception e)
                    //{
                    //    GameDebug.LogError("Protocol " + protocol + " error: " + e.Message);
                    //}
                }
                process = true;
            }

            if (mLuaNetHandlers != null)
            {
                if (mLuaNetHandlers.TryGetValue(protocol, out funcs))
                {
                    // Broacast the net notify.
                    for (int i = 0; i < funcs.Count; ++i)
                    {
                        DataReplyDelegate func = funcs[i];
                        try
                        {
                            func(protocol, data);
                        }
                        catch (System.Exception e)
                        {
                            GameDebug.LogError("Protocol " + protocol + " error: " + e.Message);
                        }
                    }
                    process = true;
                }
            }

            if (process == false)
            {
                GameDebug.Log("未处理的协议:" + protocol);
            }
        }