public IEnumerator PreLoadingCo() { SetProgress(0); float fPercent = 0; if (m_isFirstLoad) { m_isFirstLoad = false; int nLoadedCount = 0; fPercent = 0.95f; TableResMgr.Instance.PreLoading(); //foreach (KeyValuePair<int, TableResMgr.TableRecordBase> kv in TableResMgr.Instance.m_tablePathDict) //{ // int nIndex = kv.Key; // TableResMgr.Instance.LoadBinary(nIndex); // nLoadedCount++; // SetProgress((float)nLoadedCount / (float)TableResMgr.Instance.m_tablePathDict.Count * fPercent); // if (nLoadedCount % 15 == 0) // { // yield return null; // } //} } fPercent = 1.0f; SetProgress(fPercent); CGameRoot.SwitchToState(m_nextStateType); yield return(null); }
public void Awake() { mInstance = this; DontDestroyOnLoad(gameObject); DontDestroyOnLoad(UINodesManager.UIRoot); CGameRootCfg.mCfgs[0] = null; CGameRootCfg.mCfgs[(int)EGameRootCfgType.Game] = CGameRootCfg.mGame; CGameRootCfg.mCfgs[(int)EGameRootCfgType.EditorBase] = CGameRootCfg.mEditorBase; mConfig = CGameRootCfg.mCfgs[(int)mConfigType]; }
public override IEnumerator SysEnterCo() { while (!SceneLoadSys.instance.isDone) { yield return(null); } ActorManager.Cache(EActorType.Hero, 1002, 5); ActorManager.Cache(EActorType.Monster, 2001, 10); yield return(null); CGameRoot.SwitchToState(EStateType.Gaming); }
public IEnumerator PreLoadData() { //对资源的minifest文件进行初始化 ResourceManager.Instance.InitManifest(); //预加载文件的读取与解析后,进行AB文件的预加载 yield return(StartCoroutine(doABPreLoad())); //预加载lua文件 yield return(StartCoroutine(SLuaSys.Instance.preLoadLua())); //预加载状态PreLoad切换至Login状态 CGameRoot.SwitchToState(EStateType.Login); }
public void OnDestroy() { if (mSystems != null) { for (int i = mSystems.Length - 1; i >= 0; --i) { mSystems[i].SysFinalize(); DestroyImmediate(mSystems[i]); } } UnLoad(); StopAllCoroutines(); _GameRoot = null; mSystems = null; mConfig = null; mLeaveSystems.Clear(); mEnterSystems.Clear(); mSystemMap.Clear(); }
public static void Log(ELogLevel level, ELogTag tag, string content, string stack) { CLogSys logSys = CGameRoot.GetGameSystem <CLogSys>(); if (logSys == null) { return; } if ((int)level < (int)logSys.mSelfLogLevel) { return; } //if (FightScene.mInstance != null && FightScene.mInstance.isBattleStart) //{ // return; //} #region 重复内容保护 string sameStr = content.Substring(0, Mathf.Min(20, content.Length)); if (string.IsNullOrEmpty(mSameLogStr) || mSameLogStr != sameStr) { mSameLogStr = sameStr; mSameLogCnt = 0; } else { mSameLogCnt++; } if (mSameLogCnt > 20) { return; } #endregion #if !UNITY_EDITOR if (string.IsNullOrEmpty(stack)) { System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(true); System.Diagnostics.StackFrame[] stackFrames = stackTrace.GetFrames(); System.Text.StringBuilder sb = new System.Text.StringBuilder(); for (int i = 0; i < stackFrames.Length; ++i) { System.Reflection.MethodBase method = stackFrames[i].GetMethod(); string typeName = method.DeclaringType.FullName; string methodName = method.Name; if (typeName == "CLogSys" || typeName == "UnityEngine.Debug" || methodName == "CallLogCallback") { continue; } sb.AppendFormat("{0}:{1}\n", typeName, methodName); } stack = sb.ToString(); } char[] contentInLine; int contentIdx; TransInLine(content, out contentInLine, out contentIdx); char[] stackInLine; int stackIdx; TransInLine(stack, out stackInLine, out stackIdx); System.DateTime now = System.DateTime.Now; string curTime = string.Format("{0:00}{1:00}{2:00}{3:00}{4:00}", now.Month, now.Day, now.Hour, now.Minute, now.Second); string logStr = string.Format("{0}|{1}|{2}|{3}|{4}|{5}", cLogPrefix, curTime, level.ToString()[0], tag, new string(contentInLine, 0, contentIdx), new string(stackInLine, 0, stackIdx)); //ELogLevel logLevel = (ResourceSys != null && ResourceSys.RootCfg != null) ? ResourceSys.RootCfg.mLogLevel : ELogLevel.Debug; if (mLogPlatform != null) { mLogPlatform.Log(logStr); } if (level >= ELogLevel.Error) { //DCProxy.ReportError(content, logStr); } #else if (level == ELogLevel.Warning) { Debug.LogWarning(content); } else if (level == ELogLevel.Error) { Debug.LogError(content); } else if (level == ELogLevel.Fatal) { Debug.LogError(content); } else if (level == ELogLevel.Debug) { Debug.LogWarning(content); } else if (level == ELogLevel.Verbose) { Debug.Log(content); } #endif }
public override IEnumerator SysEnterCo() { SetProgress(0); #if !UNITY_EDITOR || BUNDLE_MODE #if UNITY_IPHONE string strMd5ConfigURL = GetURLRoot() + "/IOSAssetsMD5Config.xml"; #elif UNITY_EDITOR string strMd5ConfigURL = GetURLRoot() + "/StreamingAssets/AndroidAssetsMD5Config.xml"; #else string strMd5ConfigURL = GetURLRoot() + "/AndroidAssetsMD5Config.xml"; #endif WWW www = new WWW(strMd5ConfigURL); yield return(www); if (!string.IsNullOrEmpty(www.error)) { Debug.LogError("下载资源配置出错!"); yield break; } List <MD5Info> lstFileMD5 = (List <MD5Info>)CUility.DeSerializerObjectFromBuff(www.bytes, typeof(List <MD5Info>)); www.Dispose(); for (int i = 0; i != lstFileMD5.Count; ++i) { MD5Info md5Info = lstFileMD5[i]; string strLocalPath = Application.persistentDataPath + md5Info.strPath.Substring(md5Info.strPath.IndexOf('/')); bool bNeedUpdate = true; if (File.Exists(strLocalPath)) { string strFileMd5 = CUility.GetFileMD5(strLocalPath); if (strFileMd5 == md5Info.strMD5) { bNeedUpdate = false; } } if (bNeedUpdate) { string strURL = GetURL(md5Info.strPath); www = new WWW(strURL); yield return(www); if (!string.IsNullOrEmpty(www.error)) { Debug.LogError("下载资源出错!"); yield break; } byte[] arrData = GzipHelper.GzipDecompress(www.bytes); string strDirectory = strLocalPath.Substring(0, strLocalPath.LastIndexOf('/')); if (!Directory.Exists(strDirectory)) { Directory.CreateDirectory(strDirectory); } using (FileStream destFile = File.Open(strLocalPath, FileMode.Create, FileAccess.Write)) { destFile.Write(arrData, 0, arrData.Length); destFile.Close(); } www.Dispose(); } } CResourceSys.Instance.GenManifestBundle(); #endif SetProgress(1.0f); #if !UNITY_EDITOR #if UNITY_IPHONE string strCompressDir = Application.dataPath + "/StreamingAssets/IOSAssetsCompress"; #else string strCompressDir = Application.dataPath + "/StreamingAssets/AndroidAssetsCompress"; #endif if (Directory.Exists(strCompressDir)) { Directory.Delete(strCompressDir, true); } #endif CGameRoot.SwitchToState(EStateType.GamePreLoading); yield return(null); }