/// <summary> /// 插入PK表无重复键数据 /// </summary> void InsertPKDifferentKeyTable() { Stopwatch watch = new Stopwatch(); watch.Start(); SQLiteTableMapAttribute tableAttribute = StrayFogConfigHelper.GetTableAttribute <XLS_Report_Table_Report>(); UnityEngine.Debug.LogFormat("【Insert PK Table 】【Different Key】 【{0}->{1}】", GetSrcData(tableAttribute), tableAttribute.sqliteTableName); List <XLS_Report_Table_Report> reports = StrayFogConfigHelper.Select <XLS_Report_Table_Report>(); watch.Stop(); UnityEngine.Debug.LogFormat("【Select PK Table 】【Different Key】SQLite Data =>{0} , Time=>{1} , Data=>【{2}】", reports.Count, watch.Elapsed, reports.JsonSerialize()); watch.Reset(); watch.Start(); XLS_Report_Table_Report insertReport = new XLS_Report_Table_Report(Guid.NewGuid().ToString().GetHashCode()); insertReport.Set_stringCol("Insert PK Table"); StrayFogConfigHelper.Insert(insertReport); watch.Stop(); UnityEngine.Debug.LogFormat("【Insert PK Table】【Different Key】SQLite Data 【Different PK】=>{0} , Time=>{1}, Data=>【{2}】", reports.Count, watch.Elapsed, reports.JsonSerialize()); watch.Reset(); watch.Start(); reports = StrayFogConfigHelper.Select <XLS_Report_Table_Report>(); watch.Stop(); UnityEngine.Debug.LogFormat("【Select PK Table】【Different Key】SQLite Data =>{0} , Time=>{1}", reports.Count, watch.Elapsed, reports.JsonSerialize()); }
/// <summary> /// 插入NoPK表数据 /// </summary> void InsertNoPKTable() { Stopwatch watch = new Stopwatch(); watch.Start(); SQLiteTableMapAttribute tableAttribute = StrayFogConfigHelper.GetTableAttribute <XLS_Report_Table_ReportColumnMaping>(); UnityEngine.Debug.LogFormat("Insert 【NoPk Table】 【{0}->{1}】", GetSrcData(tableAttribute), tableAttribute.sqliteTableName); watch.Reset(); watch.Start(); List <XLS_Report_Table_ReportColumnMaping> reportColumnMapings = StrayFogConfigHelper.Select <XLS_Report_Table_ReportColumnMaping>(); watch.Stop(); UnityEngine.Debug.LogFormat("Select【NoPk Table】SQLite Data =>{0} , Time=>{1}", reportColumnMapings.Count, watch.Elapsed); if (reportColumnMapings.Count > 0) { watch.Reset(); watch.Start(); reportColumnMapings[0].Set_stringCol("Insert NoPk Table"); StrayFogConfigHelper.Insert(reportColumnMapings[0]); watch.Stop(); UnityEngine.Debug.LogFormat("Insert【NoPk Table】SQLite Data =>{0} , Time=>{1}", reportColumnMapings.Count, watch.Elapsed); } watch.Reset(); watch.Start(); reportColumnMapings = StrayFogConfigHelper.Select <XLS_Report_Table_ReportColumnMaping>(); watch.Stop(); UnityEngine.Debug.LogFormat("Select【NoPk Table】SQLite Data =>{0} , Time=>{1}", reportColumnMapings.Count, watch.Elapsed); }
/// <summary> /// OnAfterConstructor /// </summary> protected override void OnAfterConstructor() { List <XLS_Config_Table_XLuaMap> src = StrayFogConfigHelper.Select <XLS_Config_Table_XLuaMap>(); foreach (XLS_Config_Table_XLuaMap r in src) { if (!mXLuaConfigMaping.ContainsKey(r.id)) { mXLuaConfigMaping.Add(r.id, r); } } xLuaEnv = new LuaEnv(); xLuaEnv.AddLoader((ref string filepath) => { int xLuaId = 0; string xLuaString = string.Empty; byte[] result = null; if (!int.TryParse(filepath, out xLuaId)) { xLuaId = filepath.UniqueHashCode(); } xLuaString = OnGetXLuaScript(xLuaId); if (!string.IsNullOrEmpty(xLuaString)) { result = System.Text.Encoding.UTF8.GetBytes(xLuaString); } return(result); }); base.OnAfterConstructor(); }
/// <summary> /// 插入PK表有重复键数据 /// </summary> void InsertPKSameKeyTable() { Stopwatch watch = new Stopwatch(); watch.Start(); SQLiteTableMapAttribute tableAttribute = StrayFogConfigHelper.GetTableAttribute <XLS_Report_Table_Report>(); UnityEngine.Debug.LogFormat("【Insert PK Table 】【Same Key】【{0}->{1}】", GetSrcData(tableAttribute), tableAttribute.sqliteTableName); List <XLS_Report_Table_Report> reports = StrayFogConfigHelper.Select <XLS_Report_Table_Report>(); watch.Stop(); UnityEngine.Debug.LogFormat("【Select PK Table 】【Same Key】SQLite Data =>{0} , Time=>{1} , Data=>【{2}】", reports.Count, watch.Elapsed, reports.JsonSerialize()); if (reports.Count > 0) { watch.Reset(); watch.Start(); StrayFogConfigHelper.Insert(reports[0]); watch.Stop(); UnityEngine.Debug.LogFormat("【Insert PK Table】【Same Key】SQLite Data 【Same PK】=>{0} , Time=>{1}, Data=>【{2}】", reports.Count, watch.Elapsed, reports.JsonSerialize()); } watch.Reset(); watch.Start(); reports = StrayFogConfigHelper.Select <XLS_Report_Table_Report>(); watch.Stop(); UnityEngine.Debug.LogFormat("【Select PK Table】【Same Key】SQLite Data =>{0} , Time=>{1}", reports.Count, watch.Elapsed, reports.JsonSerialize()); }
/// <summary> /// DeleteAllTable /// </summary> void DeleteAllTable() { Stopwatch watch = new Stopwatch(); watch.Start(); SQLiteTableMapAttribute tableAttribute = StrayFogConfigHelper.GetTableAttribute <XLS_Report_Table_Report>(); UnityEngine.Debug.LogFormat("Delete Table【{0}->{1}】", GetSrcData(tableAttribute), tableAttribute.sqliteTableName); List <XLS_Report_Table_Report> reports = StrayFogConfigHelper.Select <XLS_Report_Table_Report>(); watch.Stop(); UnityEngine.Debug.LogFormat("Select Table SQLite Data =>{0} , Time=>{1} , Data=>【{2}】", reports.Count, watch.Elapsed, reports.JsonSerialize()); watch.Reset(); watch.Start(); StrayFogConfigHelper.DeleteAll <XLS_Report_Table_Report>(); watch.Stop(); UnityEngine.Debug.LogFormat("DeleteAll Table SQLite Data =>{0} , Time=>{1}, Data=>【{2}】", reports.Count, watch.Elapsed, reports.JsonSerialize()); watch.Reset(); watch.Start(); reports = StrayFogConfigHelper.Select <XLS_Report_Table_Report>(); watch.Stop(); UnityEngine.Debug.LogFormat("Select Table SQLite Data =>{0} , Time=>{1}", reports.Count, watch.Elapsed, reports.JsonSerialize()); }
/// <summary> /// 更新行列式表 /// </summary> void UpdateDeterminantTable() { Stopwatch watch = new Stopwatch(); watch.Start(); SQLiteTableMapAttribute tableAttribute = StrayFogConfigHelper.GetTableAttribute <XLS_Report_Determinant_Table_ReportDeterminant>(); UnityEngine.Debug.LogFormat("Update【Determinant Table 】【{0}->{1}】", GetSrcData(tableAttribute), tableAttribute.sqliteTableName); List <XLS_Report_Determinant_Table_ReportDeterminant> reports = StrayFogConfigHelper.Select <XLS_Report_Determinant_Table_ReportDeterminant>(); watch.Stop(); UnityEngine.Debug.LogFormat("Select【Determinant Table 】SQLite Data =>{0} , Time=>{1} , Data=>【{2}】", reports.Count, watch.Elapsed, reports.JsonSerialize()); if (reports.Count > 0) { watch.Reset(); watch.Start(); reports[0].Set_ReportTip("Update Determinant Table"); reports[0].Set_DeterminantTip(Guid.NewGuid().ToString()); StrayFogConfigHelper.Update(reports[0]); watch.Stop(); UnityEngine.Debug.LogFormat("Update【Determinant Table】SQLite Data 【Same PK】=>{0} , Time=>{1}, Data=>【{2}】", reports.Count, watch.Elapsed, reports.JsonSerialize()); } watch.Reset(); watch.Start(); reports = StrayFogConfigHelper.Select <XLS_Report_Determinant_Table_ReportDeterminant>(); watch.Stop(); UnityEngine.Debug.LogFormat("Select【Determinant Table】SQLite Data =>{0} , Time=>{1}", reports.Count, watch.Elapsed, reports.JsonSerialize()); }
/// <summary> /// RefreshTable /// </summary> void RefreshTable() { Stopwatch watch = new Stopwatch(); watch.Start(); SQLiteTableMapAttribute tableAttribute = StrayFogConfigHelper.GetTableAttribute <XLS_Report_Table_Report>(); UnityEngine.Debug.LogFormat("Refresh Table【{0}->{1}】", GetSrcData(tableAttribute), tableAttribute.sqliteTableName); List <XLS_Report_Table_Report> reports = StrayFogConfigHelper.Select <XLS_Report_Table_Report>(); watch.Stop(); UnityEngine.Debug.LogFormat("Select Table SQLite Data =>{0} , Time=>{1} , Data=>【{2}】", reports.Count, watch.Elapsed, reports.JsonSerialize()); if (reports.Count > 0) { watch.Reset(); watch.Start(); reports[0].Set_stringCol("Refresh Table"); watch.Stop(); UnityEngine.Debug.LogFormat("Modify Table SQLite Data =>{0} , Time=>{1}, Data=>【{2}】", reports.Count, watch.Elapsed, reports.JsonSerialize()); } watch.Reset(); watch.Start(); StrayFogConfigHelper.Reload <XLS_Report_Table_Report>(); reports = StrayFogConfigHelper.Select <XLS_Report_Table_Report>(); watch.Stop(); UnityEngine.Debug.LogFormat("Select Table SQLite Data =>{0} , Time=>{1}", reports.JsonSerialize(), watch.Elapsed, reports.JsonSerialize()); }
/// <summary> /// SelectTable /// </summary> void SelectTable() { SQLiteTableMapAttribute tableAttribute = StrayFogConfigHelper.GetTableAttribute <XLS_Report_Table_Report>(); UnityEngine.Debug.LogFormat("【Select Table 】【{0}->{1}】", GetSrcData(tableAttribute), tableAttribute.sqliteTableName); Stopwatch watch = new Stopwatch(); watch.Start(); List <XLS_Report_Table_Report> maps = StrayFogConfigHelper.Select <XLS_Report_Table_Report>(); watch.Stop(); UnityEngine.Debug.LogFormat("Select Table【{0}->{1}】Count->{2} Time->{3}", GetSrcData(tableAttribute), tableAttribute.sqliteTableName, maps.Count, watch.Elapsed); }
/// <summary> /// OnRunAwake /// </summary> protected override void OnRunAwake() { StrayFogGamePools.gameManager.Initialization(() => { StrayFogGamePools.uiWindowManager.AfterToggleScene(() => { System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start(); List <XLS_Config_Table_AssetDiskMapingFile> tables = StrayFogConfigHelper.Select <XLS_Config_Table_AssetDiskMapingFile>(); watch.Stop(); Debug.Log(tables + " " + tables.Count + " " + watch.Elapsed); }); }); }
/// <summary> /// 从XLS表加载视图 /// </summary> /// <param name="_table">表格</param> /// <param name="_type">类型</param> /// <returns>数据集</returns> Dictionary <int, T> StrayFogSQLiteEntityHelper_OnEventHandlerLoadViewFromXLS <T> (SQLiteTableMapAttribute _tableAttribute) where T : AbsStrayFogSQLiteEntity { Dictionary <int, T> result = new Dictionary <int, T>(); Type type = typeof(T); if (_tableAttribute.tableClassType.Equals(typeof(XLS_Config_View_AssetDiskMaping))) { #region View_AssetDiskMaping 数据组装 List <XLS_Config_Table_AssetDiskMapingFile> files = StrayFogConfigHelper.Select <XLS_Config_Table_AssetDiskMapingFile>(); List <XLS_Config_Table_AssetDiskMapingFolder> folders = StrayFogConfigHelper.Select <XLS_Config_Table_AssetDiskMapingFolder>(); Dictionary <int, XLS_Config_Table_AssetDiskMapingFile> dicFile = new Dictionary <int, XLS_Config_Table_AssetDiskMapingFile>(); Dictionary <int, XLS_Config_Table_AssetDiskMapingFolder> dicFolder = new Dictionary <int, XLS_Config_Table_AssetDiskMapingFolder>(); foreach (XLS_Config_Table_AssetDiskMapingFolder t in folders) { dicFolder.Add(t.folderId, t); } int fileId = StrayFogConfigHelper.GetPropertyId("fileId"); int folderId = StrayFogConfigHelper.GetPropertyId("folderId"); int fileName = StrayFogConfigHelper.GetPropertyId("fileName"); int inAssetPath = StrayFogConfigHelper.GetPropertyId("inAssetPath"); int outAssetPath = StrayFogConfigHelper.GetPropertyId("outAssetPath"); int extEnumValue = StrayFogConfigHelper.GetPropertyId("extEnumValue"); T tempEntity = null; foreach (XLS_Config_Table_AssetDiskMapingFile t in files) { tempEntity = (T)Activator.CreateInstance(type, _tableAttribute.hasPkColumn && _tableAttribute.canModifyData); StrayFogConfigHelper.GetPropertyInfo(_tableAttribute, fileId).SetValue(tempEntity, t.fileId, null); StrayFogConfigHelper.GetPropertyInfo(_tableAttribute, folderId).SetValue(tempEntity, t.folderId, null); StrayFogConfigHelper.GetPropertyInfo(_tableAttribute, fileName).SetValue(tempEntity, t.inSide + t.ext, null); StrayFogConfigHelper.GetPropertyInfo(_tableAttribute, inAssetPath).SetValue(tempEntity, Path.Combine(dicFolder[t.folderId].inSide, t.inSide + t.ext).TransPathSeparatorCharToUnityChar(), null); StrayFogConfigHelper.GetPropertyInfo(_tableAttribute, outAssetPath).SetValue(tempEntity, t.outSide, null); StrayFogConfigHelper.GetPropertyInfo(_tableAttribute, extEnumValue).SetValue(tempEntity, t.extEnumValue, null); tempEntity.Resolve(); result.Add(tempEntity.pkSequenceId, tempEntity); } #endregion } else if (_tableAttribute.tableClassType.Equals(typeof(XLS_Config_View_DeterminantVT))) { #region View_DeterminantVT 数据组装 int vtNameKey = "vtName".UniqueHashCode(); #endregion } return(result); }
/// <summary> /// 初始化引导参考对象数据 /// </summary> void OnInitGuideReferObjectData() { List <XLS_Config_Table_UserGuideReferObject> referObjects = StrayFogConfigHelper.Select <XLS_Config_Table_UserGuideReferObject>(); if (referObjects != null && referObjects.Count > 0) { foreach (XLS_Config_Table_UserGuideReferObject t in referObjects) { if (!mGuideReferObjectMaping.ContainsKey(t.id)) { mGuideReferObjectMaping.Add(t.id, t); } } } }
/// <summary> /// 初始化引导数据 /// </summary> void OnInitGuideConfigData() { List <XLS_Config_Table_UserGuideConfig> configs = StrayFogConfigHelper.Select <XLS_Config_Table_UserGuideConfig>(); if (configs != null && configs.Count > 0) { foreach (XLS_Config_Table_UserGuideConfig t in configs) { if (!mGuideConfigMaping.ContainsKey(t.id)) { mGuideConfigMaping.Add(t.id, t); } } } }
/// <summary> /// 初始化引导样式数据 /// </summary> void OnInitGuideStyleData() { List <XLS_Config_Table_UserGuideStyle> styles = StrayFogConfigHelper.Select <XLS_Config_Table_UserGuideStyle>(); if (styles != null && styles.Count > 0) { foreach (XLS_Config_Table_UserGuideStyle s in styles) { if (!mGuideStyleMaping.ContainsKey(s.id)) { mGuideStyleMaping.Add(s.id, s); } } } }
/// <summary> /// 初始化SQLite数据 /// </summary> void OnInitializeSQLite() { List <XLS_Config_Table_UIWindowSetting> tables = StrayFogConfigHelper.Select <XLS_Config_Table_UIWindowSetting>(); foreach (XLS_Config_Table_UIWindowSetting t in tables) { mWindowSettingMaping.Add(t.id, t); if (!mFolderIdFileIdForWinIdMaping.ContainsKey(t.folderId)) { mFolderIdFileIdForWinIdMaping.Add(t.folderId, new Dictionary <int, int>()); } if (!mFolderIdFileIdForWinIdMaping[t.folderId].ContainsKey(t.fileId)) { mFolderIdFileIdForWinIdMaping[t.folderId].Add(t.fileId, t.id); } else { Debug.LogErrorFormat("UIWindowManager SQLite has the same fileId 【{0}】", t.fileId); } } }
/// <summary> /// Application_quitting /// </summary> void OnApplication_quitting() { Time.timeScale = 0; StrayFogGamePools.assetBundleManager.Dispose(); StrayFogConfigHelper.CloseSQLite(); StrayFogConfigHelper.SaveExcelPackage(); AssetBundle.UnloadAllAssetBundles(true); GameObject[] gos = SceneManager.GetActiveScene().GetRootGameObjects(); if (gos != null && gos.Length > 0) { foreach (GameObject g in gos) { if (g != null) { GameObject.Destroy(g); } } } mQuitAppAsyncOperation = Resources.UnloadUnusedAssets(); Time.timeScale = 1; coroutine.StartCoroutine(OnWaitQuitApp()); }
/// <summary> /// 初始化 /// </summary> /// <param name="_onCallback">结束回调</param> public void Initialization(Action _onCallback) { if (!m_isInitialized) { m_isInitialized = true; runningSetting = StrayFogConfigHelper.Select <XLS_Config_Determinant_Table_GameSetting>()[0]; StrayFogGamePools.uiWindowManager.OnOpenWindowEventHandler += UiWindowManager_OnOpenWindowEventHandler; StrayFogGamePools.uiWindowManager.OnCloseWindowEventHandler += UiWindowManager_OnCloseWindowEventHandler; StrayFogGamePools.guideManager.OnIsLevel += Current_OnIsLevel; StrayFogGamePools.guideManager.OnValidateFinished += Current_OnValidateFinished; OnPartialInitialization(); Application.wantsToQuit += OnApplication_wantsToQuit; Application.lowMemory += Application_lowMemory; #if UNITY_EDITOR || DEBUGLOG Application.logMessageReceivedThreaded += Application_logMessageReceivedThreaded; #endif } if (_onCallback != null) { _onCallback.Invoke(); } }
/// <summary> /// 收集磁盘映射 /// </summary> void OnCollectAssetDiskMaping() { #if UNITY_EDITOR string editorABPN = typeof(IAssetBundleFileParameter).Name; string editorManifestN = typeof(AssetBundleManifest).Name; string editorXLSN = typeof(XLS_Config_View_AssetDiskMaping).Name; System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start(); #endif if (mAssetBundleManifest != null) { string[] names = mAssetBundleManifest.GetAllAssetBundles(); if (names != null && names.Length > 0) { foreach (string n in names) { IAssetBundleFileParameter abmp = new AssetBundleFileParameter(n); if (!mAssetBundlePathParameterMaping.ContainsKey(abmp.assetBundleId)) { mAssetBundlePathParameterMaping.Add(abmp.assetBundleId, abmp); } } } #if UNITY_EDITOR watch.Stop(); Debug.LogFormat("Collection {0} from 【Manifest =>{1}】,Time:{2}", editorABPN, mAssetBundlePathParameterMaping.Count, watch.Elapsed); watch.Reset(); #endif } #if UNITY_EDITOR int beforeCollectXlsConfigABMPC = mAssetBundlePathParameterMaping.Count; watch.Start(); #endif IAssetBundleFileParameter tempAbp = null; mXLS_Config_View_AssetDiskMaping.Clear(); StrayFogConfigHelper.AddLoadViewFromXLS(StrayFogSQLiteEntityHelper_OnEventHandlerLoadViewFromXLS <XLS_Config_View_AssetDiskMaping>); List <XLS_Config_View_AssetDiskMaping> mapings = StrayFogConfigHelper.Select <XLS_Config_View_AssetDiskMaping>(); if (mapings.Count > 0) { foreach (XLS_Config_View_AssetDiskMaping v in mapings) { if (!mXLS_Config_View_AssetDiskMaping.ContainsKey(v.folderId)) { mXLS_Config_View_AssetDiskMaping.Add(v.folderId, new Dictionary <int, XLS_Config_View_AssetDiskMaping>()); } if (!mXLS_Config_View_AssetDiskMaping[v.folderId].ContainsKey(v.fileId)) { mXLS_Config_View_AssetDiskMaping[v.folderId].Add(v.fileId, v); } if (!mXLSToManifestMaping.ContainsKey(v.folderId)) { mXLSToManifestMaping.Add(v.folderId, new Dictionary <int, int>()); } if (!mXLSToManifestMaping[v.folderId].ContainsKey(v.fileId)) { mXLSToManifestMaping[v.folderId].Add(v.fileId, 0); } if (StrayFogGamePools.setting.isUseAssetBundle) { tempAbp = new AssetBundleFileParameter(v.outAssetPath); } else { tempAbp = new AssetBundleFileParameter(v.inAssetPath); } if (!mAssetBundlePathParameterMaping.ContainsKey(tempAbp.assetBundleId)) { mAssetBundlePathParameterMaping.Add(tempAbp.assetBundleId, tempAbp); } #if UNITY_EDITOR if (mXLSToManifestMaping[v.folderId][v.fileId] != 0 && mXLSToManifestMaping[v.folderId][v.fileId] != tempAbp.assetBundleId) { Debug.LogErrorFormat("Asset 【{0}】【{1}_{2}】has the two assetId 【{3}_{4}】【{5}_{6}】", v.inAssetPath, v.folderId, v.fileId, mAssetBundlePathParameterMaping[mXLSToManifestMaping[v.folderId][v.fileId]].assetBundleId, mAssetBundlePathParameterMaping[mXLSToManifestMaping[v.folderId][v.fileId]].assetBundlePath, tempAbp.assetBundleId, tempAbp.assetBundlePath ); } #endif mXLSToManifestMaping[v.folderId][v.fileId] = tempAbp.assetBundleId; } } StrayFogConfigHelper.RemoveLoadViewFromXLS(StrayFogSQLiteEntityHelper_OnEventHandlerLoadViewFromXLS <XLS_Config_View_AssetDiskMaping>); #if UNITY_EDITOR watch.Stop(); Debug.LogFormat("Collection {0} from 【{1}=> {2}】,Time: {3}", editorABPN, editorXLSN, mapings.Count, watch.Elapsed); Debug.LogFormat("Collection {0} between {1} and {2} different【{3}】,Time:{4}", editorABPN, editorManifestN, editorXLSN, mAssetBundlePathParameterMaping.Count - beforeCollectXlsConfigABMPC, watch.Elapsed); watch.Reset(); #endif }