public void Awake() { Instance = this; ETModel.Game.Hotfix.OnApplicationPauseTrue += OnApplicationPauseTrue; ETModel.Game.Hotfix.OnApplicationPauseFalse += OnApplicationPauseFalse; recordDeltaTime = 0; }
private void OnCheckUpdateSwithInfo(string info, bool isIM, bool isUserChoice) { NetLineSwitchComponent.NetLineSwitchData lineSwitchData = JsonHelper.FromJson <NetLineSwitchComponent.NetLineSwitchData>(info); int selectID; string userChoice = PlayerPrefsMgr.mInstance.GetString($"{PlayerPrefsKeys.CURRENT_SERVER_USER_CHOICEID}{serverType}", null); if (!string.IsNullOrEmpty(userChoice)) { //优先使用用户选择的线路 selectID = Convert.ToInt32(userChoice); } else { if (isIM) { //IM切换的,不要使用接口返回的默认线路,使用上次的线路即可,如无则用线路1 selectID = PlayerPrefsMgr.mInstance.GetInt($"{PlayerPrefsKeys.CURRENT_VIP_DNS_SERVERID}{serverType}", 1); } else { selectID = lineSwitchData.selector; PlayerPrefsMgr.mInstance.SetInt($"{PlayerPrefsKeys.CURRENT_VIP_DNS_SERVERID}{serverType}", selectID); } } PlayerPrefsMgr.mInstance.SetInt($"{PlayerPrefsKeys.CURRENT_USING_SERVERID}{serverType}", selectID); PlayerPrefs.Save(); foreach (NetLineSwitchComponent.LineInfo lineInfo in lineSwitchData.list) { if (lineInfo.id == selectID) { bool hadChange = false; if (!string.IsNullOrEmpty(lineInfo.http)) { if (lineInfo.http != HTTP) { hadChange = true; } PlayerPrefsMgr.mInstance.SetString($"{PlayerPrefsKeys.CURRENT_SERVER_HTTP_DOMAIN}{serverType}", lineInfo.http); PlayerPrefs.Save(); } if (!string.IsNullOrEmpty(lineInfo.sck)) { if (lineInfo.sck != LoginHost) { hadChange = true; } PlayerPrefsMgr.mInstance.SetString($"{PlayerPrefsKeys.CURRENT_SERVER_SCK_DOMAIN}{serverType}", lineInfo.sck); PlayerPrefs.Save(); } Refresh(); if (hadChange && GameCache.Instance.nUserId > 0 && !isUserChoice) { //重连 NetworkDetectionComponent mNetworkDetectionComponent = Game.Scene.GetComponent <NetworkDetectionComponent>(); if (null != mNetworkDetectionComponent) { Game.Scene.GetComponent <NetworkDetectionComponent>().Reconnect(); } // UIComponent.Instance.ShowNoAnimation(UIType.UIDialog, new UIDialogComponent.DialogData() // { // type = UIDialogComponent.DialogData.DialogType.Commit, // title = $"温馨提示", // content = $"当前线路不稳定,已为您切换线路重新连接。", // contentCommit = "好的", // actionCommit = null // }); UIComponent.Instance.ShowNoAnimation(UIType.UIDialog, new UIDialogComponent.DialogData() { type = UIDialogComponent.DialogData.DialogType.Commit, // title = $"温馨提示", title = CPErrorCode.LanguageDescription(10007), // content = $"当前线路不稳定,已为您切换线路重新连接", content = CPErrorCode.LanguageDescription(20072), // contentCommit = "知道了", contentCommit = CPErrorCode.LanguageDescription(10024), contentCancel = "", actionCommit = null, actionCancel = null }); } } } }