Esempio n. 1
0
        private float getFileDownloadPercent(string path)
        {
            if (ResourceManager.Instance.GetPhyRes(path) != null)
            {
                return(1.0f);
            }
            LoadImplement impl = ResourceManager.Instance.getLoadImplement(path);

            if (impl == null)
            {
                return(0.0f);
            }
            return(impl.www.progress);
        }
Esempio n. 2
0
        //
        public void LoadImpl(string path, PhyResouce.EPhyResType type, OnResLoaded onLoaded = null, OnResLoadError onError = null)
        {
            //GameDefine.GameMethod.DebugError("load " + path);
            if (phyResDic.ContainsKey(path) == true)
            {
                return;
            }
            if (loadImplDic.ContainsKey(path) == true)
            {
                return;
            }
            LoadImplement l = new LoadImplement();

            l.phyResType     = type;
            l.onResLoaded    = onLoaded;
            l.onResLoadError = onError;
            l.resPath        = path;
            l.start();
            loadImplDic.Add(path, l);
        }
Esempio n. 3
0
        //
        public void Update()
        {
            if (loadProcess != null)
            {
                if (loadProcess.isLoading == true)
                {
                    loadProcess.Update();
                }
            }

            List <string> removeLoadList = new List <string>();

            //遍历loadimplement
            foreach (LoadImplement l in loadImplDic.Values)
            {
                if (l.www.isDone == true)
                {
                    if (l.www.error == null)
                    {
                        if (l.createReq == null)
                        {
                            l.createReq = AssetBundle.CreateFromMemory(l.www.bytes);
                        }
                        if (l.createReq.isDone == true)
                        {
                            // GameDefine.GameMethod.DebugError("Load Res Success:" + l.resPath);
                            PhyResouce phyRes = new PhyResouce();
                            phyRes.resPath     = l.resPath;
                            phyRes.phyResType  = l.phyResType;
                            phyRes.assetBundle = l.createReq.assetBundle;
                            //if(phyResDic.ContainsKey(phyRes.resPath) == true)
                            //{
                            //    Debug.LogError("already have:"+phyRes.resPath);
                            //}
                            //else
                            // Debug.LogError("phy res :" + phyRes.resPath);
                            phyResDic.Add(phyRes.resPath, phyRes);
                            // }
                            removeLoadList.Add(l.resPath);
                        }
                    }
                    else
                    {
                        GameDefine.GameMethod.DebugError("Load Res Failed:" + l.www.url + "======" + l.resPath + " error is:" + l.www.error.ToString());
                        removeLoadList.Add(l.resPath);
                    }
                }
            }
            foreach (string s in removeLoadList)
            {
                LoadImplement l = getLoadImplement(s);
                if (l.onResLoaded != null)
                {
                    l.onResLoaded(l.resPath);
                }
                loadImplDic.Remove(s);
            }

            List <string> removeBuilderList = new List <string>();

            foreach (LogicResourceBuilder builder in logicResBuilder.Values)
            {
                bool allLoaded = true;
                foreach (string s in builder.resLists)
                {
                    if (GetPhyRes(s) == null)
                    {
                        allLoaded = false;
                        break;
                    }
                }
                if (allLoaded == true)
                {
                    removeBuilderList.Add(builder.resPath);
                    if (builder.onLogicResourceBuilded != null)
                    {
                        builder.onLogicResourceBuilded(builder.resPath);
                    }
                    LogicResouce logicRes = new LogicResouce();
                    logicRes.resPath      = builder.resPath;
                    logicRes.logicResType = builder.logicResType;
                    logicRes.phyResList   = builder.resLists;
                    if (logicResDic.ContainsKey(logicRes.resPath) == true)
                    {
                        logicResDic[logicRes.resPath] = logicRes;
                    }
                    else
                    {
                        logicResDic.Add(logicRes.resPath, logicRes);
                    }


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                }
            }
            foreach (string s in removeBuilderList)
            {
                logicResBuilder.Remove(s);
            }
            //
        }