public void OnLog(string log, string stackTrace, LogType type) { // 暂时屏蔽崩溃堆栈消息的发送 if (type == LogType.Exception) { string text = string.Format("{0}\r\n------Call Stack:------\r\n{1}------------\r\n", log, stackTrace); #if UNITY_EDITOR UINotice.GetInstance().ShowMessage("Program abnormal"); #endif if (LogPosted == false)//&& !Application.isEditor)// 在编辑器中不发送错误日志 { DBOSManager.writeCSDmpToFile(text); LogPosted = true; #if UNITY_EDITOR // 游戏报错的时候要关闭数据库,不然退出游戏的时候退出不了 DBManager.Instance.CloseAllSqliteDB(); #endif } } var debugUI = MainGame.DebugUI; if (debugUI != null) { debugUI.OnLog(log, stackTrace, type); } }
public bool CheckSysHasOpened(uint sys_id, bool need_tips) { var db_sys_config = DBSysConfig.Instance;// DBManager.GetInstance().GetDB<DBSysConfig>(); var config = db_sys_config.GetConfigById(sys_id); if (config == null) { return(false); } bool is_open = false; DBSysConfig.SysConfig openConfig; if (mOpenSysDic.TryGetValue(sys_id, out openConfig) && openConfig != null) { is_open = true; } // 再从等待的系统列表中寻找 if (!is_open) { var waitSysCount = mWaitingSysList.Count; for (int i = 0; i < waitSysCount; ++i) { var wait_sys_config = mWaitingSysList[i]; if (wait_sys_config == null) { continue; } if (wait_sys_config.Id == sys_id) { is_open = true; break; } } } // 如果后端下发的系统为开启状态,且需要前端加条件,才进入此判断 if (is_open && config.CustomCondition == true) { return(GetCustomSysHasOpened(sys_id)); } if (!is_open && need_tips) { if (!string.IsNullOrEmpty(config.NotOpenTips))//策划配置的提示 { UINotice.GetInstance().ShowMessage(config.NotOpenTips); } else { UINotice.GetInstance().ShowMessage(xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_95")); } } return(is_open); }
public void OnGetPackFinished(string url, string error, string reply, System.Object userData) { if (string.IsNullOrEmpty(error) == false) { GameDebug.LogError("OnGetPackFinished error: " + error); UINotice.GetInstance().ShowMessage(DBConstText.GetText("GIFT_BAG_FAIL")); mPostGetPackFinishedCallback?.Invoke(false); return; } bool ret = false; Hashtable hashtable = MiniJSON.JsonDecode(reply) as Hashtable; if (hashtable != null) { int result = DBTextResource.ParseI(hashtable["result"].ToString()); if (result == 1) { UINotice.GetInstance().ShowMessage(DBConstText.GetText("GIFT_BAG_EXCHANGE_SUCCESS")); ret = true; } else { Hashtable argsHashtable = hashtable["args"] as Hashtable; if (argsHashtable != null) { string msg = argsHashtable["error_msg"].ToString(); string translatedMsg = xc.TextHelper.GetTranslateText(msg); UINotice.GetInstance().ShowMessage(translatedMsg); } else { UINotice.GetInstance().ShowMessage(DBConstText.GetText("GIFT_BAG_FAIL")); } } } else { GameDebug.LogError("OnGetPackFinished error: " + reply); } mPostGetPackFinishedCallback?.Invoke(ret); }
/// <summary> /// 触发技能 /// </summary> /// <param name="item"></param> /// <returns></returns> bool TrggerSkill(uint skill_id) { LocalPlayer localPlayer = Game.GetInstance().GetLocalPlayer() as LocalPlayer; if (localPlayer == null) { return(false); } if (!localPlayer.IsResLoaded) { return(false); } Skill skill = localPlayer.GetSelfSkill(skill_id); if (skill == null) { return(false); } if (localPlayer.AttackCtrl.IsSkillCanCast_showTipsWhenFalse(skill, 0, ref m_tips_type) == false) { if (m_tips_type != ClickRockButtonTipsType.None) { Dictionary <ClickRockButtonTipsType, float> m_tipsData; if (m_clickRockButtonTips.TryGetValue(skill_id, out m_tipsData) == false) { m_clickRockButtonTips[skill_id] = new Dictionary <ClickRockButtonTipsType, float>(); m_tipsData = m_clickRockButtonTips[skill_id]; } if (m_tipsData.ContainsKey(m_tips_type) == false) { m_tipsData[m_tips_type] = 0; } if (Time.realtimeSinceStartup >= m_tipsData[m_tips_type] + m_rockButtonTipsInterval) { m_tipsData[m_tips_type] = Time.realtimeSinceStartup; if (m_tips_type == ClickRockButtonTipsType.IsInCD) { UINotice.GetInstance().ShowMessage(DBConstText.GetText("SKILL_IN_CD")); } else if (m_tips_type == ClickRockButtonTipsType.NotEnoughMp) { UINotice.GetInstance().ShowMessage(DBConstText.GetText("MP_NOT_ENOUGH")); } } } return(false); } bool needAi = false; if (skill.GetAction(0).ActionData.SkillInfo.Target == "rival") { needAi = true; //InstanceManager.Instance.IsInAutoFireOneSkillModel = true; } bool attack_succ = false; if (localPlayer.IsGrounded()) { attack_succ = localPlayer.AttackCtrl.Attack(skill.SkillData.SkillID); localPlayer.MoveCtrl.Interrupt(); } return(attack_succ); }
/// <summary> /// 游戏数据重置,在断线重连时ignore_reconnect设置为true /// </summary> /// <param name="ignore_reconnect"></param> public void Reset(bool ignore_reconnect = false) { mAllSystemInited = false; // 初始化单件对象,在计时器、表格和网络数据初始化之后 if (ignore_reconnect == false) { TimerManager.GetInstance().Reset(); } DecimalTimerManager.GetInstance().Reset(); UIManager.GetInstance().Reset(); NpcManager.GetInstance().Reset(); ItemManager.GetInstance().Reset(ignore_reconnect); DialogManager.GetInstance().Reset(); InstanceManager.GetInstance().Reset(ignore_reconnect); InstanceDropManager.GetInstance().Reset(); LocalPlayerManager.Instance.Reset(ignore_reconnect); RedPointDataMgr.Instance.Reset(); LockIconDataMgr.Instance.Reset(); NewMarkerDataMgr.Instance.Reset(); if (ignore_reconnect == false) { RockCommandSystem.Instance.Reset(); } CooldownManager.Instance.Reset(); ShadowManager.Instance.Reset(); GuideManager.GetInstance().Reset(); SysConfigManager.GetInstance().Reset(); SysPreviewManager.GetInstance().Reset(); CullManager.GetInstance().Reset(); MailManager2.Instance.Reset(); LockTargetManager.Instance.Reset(); InterObjectManager.Instance.Reset(); FriendsManager.Instance.Reset(ignore_reconnect); TeamManager.Instance.Reset(ignore_reconnect); SkillHoleManager.Instance.Reset(); SkillManager.Instance.Reset(); TimelineManager.Instance.Reset(); TaskManager.Instance.Reset(); HookSettingManager.Instance.Reset(); ShieldManager.Instance.Reset(); GuildLeagueManager.Instance.Reset(); MarryManager.Instance.Reset(); SpanServerManager.Instance.Reset(); if (ignore_reconnect == false) { UINotice.GetInstance().Reset(); NetReconnect.Instance.Reset(); } DBGuide db_guide = DBManager.GetInstance().GetDB <DBGuide>(); db_guide.Reset(); DBGuideStep db_guide_step = DBManager.GetInstance().GetDB <DBGuideStep>(); db_guide_step.Reset(); LuaScriptMgr.Instance.Reset(ignore_reconnect); CustomDataMgr.Instance.Reset(); ChargeManager.Instance.Reset(); AudioManager.Instance.Reset(); }
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); } }