コード例 #1
0
    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);
    }
コード例 #2
0
    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);
    }
コード例 #3
0
ファイル: PreLoadSys.cs プロジェクト: luofengwei/Client-Frame
    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);
    }
コード例 #4
0
    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);
    }