コード例 #1
0
ファイル: PandoraImpl.cs プロジェクト: TonyDongGuaPi/joework
 private void TryDoLua(string newReadyAssetBundle)
 {
     try
     {
         Logger.DEBUG(newReadyAssetBundle);
         string text = Utils.GetPlatformDesc() + "_ulua_lua.assetbundle";
         if (this.resMgr.IsLuaAssetBundleLoaded(text) && !this.luaMgrInited)
         {
             LuaStatic.Load     = new ReadLuaFile(this.resMgr.GetLuaBytes);
             this.luaMgr.DoFile = new LuaScriptMgr.FileExecutor(this.DoLoadedLua);
             this.luaMgr.Start();
             this.luaMgrInited = true;
         }
         if (this.luaMgrInited)
         {
             using (Dictionary <string, List <PandoraImpl.FileState> > .Enumerator enumerator = this.dependencyInfos.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     KeyValuePair <string, List <PandoraImpl.FileState> > current = enumerator.get_Current();
                     bool flag = true;
                     using (List <PandoraImpl.FileState> .Enumerator enumerator2 = current.get_Value().GetEnumerator())
                     {
                         while (enumerator2.MoveNext())
                         {
                             PandoraImpl.FileState current2 = enumerator2.get_Current();
                             if (!current2.isReady)
                             {
                                 flag = false;
                             }
                         }
                     }
                     if (flag)
                     {
                         using (List <PandoraImpl.FileState> .Enumerator enumerator3 = current.get_Value().GetEnumerator())
                         {
                             while (enumerator3.MoveNext())
                             {
                                 PandoraImpl.FileState current3 = enumerator3.get_Current();
                                 if (Utils.IsLuaAssetBundle(current3.name) && !current3.name.Equals(text) && !this.executedLuaAssetBundles.Contains(current3.name))
                                 {
                                     Logger.DEBUG(current3.name);
                                     string name = Utils.ExtractLuaName(current3.name);
                                     this.luaMgr.DoFile(name);
                                     this.executedLuaAssetBundles.Add(current3.name);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Logger.ERROR(ex.get_Message() + "\n" + ex.get_StackTrace());
     }
 }
コード例 #2
0
ファイル: PandoraImpl.cs プロジェクト: TonyDongGuaPi/joework
 private void HotUpdate()
 {
     if (this.bootupStatus == PandoraImpl.BootupStatus.kReadConfigDone)
     {
         Logger.DEBUG(string.Empty);
         this.resMgr.Init();
         this.resMgr.DeleteRedundantFiles(this.dependencyAll);
         List <PandoraImpl.DownloadASTask> list = new List <PandoraImpl.DownloadASTask>();
         using (List <PandoraImpl.DownloadASTask> .Enumerator enumerator = this.pendingDownloadASTasks.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 PandoraImpl.DownloadASTask current = enumerator.get_Current();
                 if (!this.dependencyAll.Contains(current.name))
                 {
                     list.Add(current);
                 }
             }
         }
         using (List <PandoraImpl.DownloadASTask> .Enumerator enumerator2 = list.GetEnumerator())
         {
             while (enumerator2.MoveNext())
             {
                 PandoraImpl.DownloadASTask current2 = enumerator2.get_Current();
                 this.pendingDownloadASTasks.Remove(current2);
             }
         }
         list.Clear();
         this.bootupStatus = PandoraImpl.BootupStatus.kLocalLoading;
     }
     if (this.bootupStatus == PandoraImpl.BootupStatus.kLocalLoading)
     {
         Logger.DEBUG(string.Empty);
         while (this.dependencyAll.get_Count() > 0)
         {
             if (this.isDependencyLoading)
             {
                 Logger.DEBUG("waiting local loading!");
                 return;
             }
             string first = this.dependencyAll.get_Item(0);
             string text  = string.Empty;
             PandoraImpl.DownloadASTask taskOfDependency = null;
             using (List <PandoraImpl.DownloadASTask> .Enumerator enumerator3 = this.pendingDownloadASTasks.GetEnumerator())
             {
                 while (enumerator3.MoveNext())
                 {
                     PandoraImpl.DownloadASTask current3 = enumerator3.get_Current();
                     if (first == current3.name)
                     {
                         taskOfDependency = current3;
                         text             = current3.md5;
                         break;
                     }
                 }
             }
             Logger.DEBUG("first=" + first + " md5=" + text);
             if (this.resMgr.IsFileExistsInCache(first, text) || (!this.resMgr.IsFileExistsInCache(first, text) && taskOfDependency == null))
             {
                 Logger.DEBUG("first=" + first + " md5=" + text);
                 Action <bool> action = delegate(bool status)
                 {
                     this.isDependencyLoading = false;
                     if (status)
                     {
                         Logger.DEBUG(first + " loaded");
                         using (Dictionary <string, List <PandoraImpl.FileState> > .Enumerator enumerator6 = this.dependencyInfos.GetEnumerator())
                         {
                             while (enumerator6.MoveNext())
                             {
                                 KeyValuePair <string, List <PandoraImpl.FileState> > current6 = enumerator6.get_Current();
                                 using (List <PandoraImpl.FileState> .Enumerator enumerator7 = current6.get_Value().GetEnumerator())
                                 {
                                     while (enumerator7.MoveNext())
                                     {
                                         PandoraImpl.FileState current7 = enumerator7.get_Current();
                                         if (current7.name == first)
                                         {
                                             current7.isReady = true;
                                         }
                                     }
                                 }
                             }
                         }
                         this.TryDoLua(first);
                         this.dependencyAll.RemoveAt(0);
                         if (taskOfDependency != null)
                         {
                             this.pendingDownloadASTasks.Remove(taskOfDependency);
                         }
                     }
                     else
                     {
                         Logger.ERROR(string.Empty);
                         this.dependencyAll.RemoveAt(0);
                         this.resMgr.DeleteFile(first);
                     }
                 };
                 if (Utils.IsLuaAssetBundle(first))
                 {
                     Logger.DEBUG(string.Empty);
                     this.isDependencyLoading = true;
                     base.StartCoroutine(this.resMgr.LoadLuaAssetBundle(first, action));
                 }
                 else
                 {
                     Logger.DEBUG(string.Empty);
                     action.Invoke(true);
                 }
             }
             else
             {
                 this.resMgr.DeleteFile(first);
                 this.dependencyAll.RemoveAt(0);
             }
         }
         if (this.dependencyAll.get_Count() == 0)
         {
             Logger.DEBUG(string.Empty);
             this.bootupStatus = PandoraImpl.BootupStatus.kLocalLoadDone;
         }
     }
     if (this.bootupStatus == PandoraImpl.BootupStatus.kLocalLoadDone || this.bootupStatus == PandoraImpl.BootupStatus.kDownloading)
     {
         this.bootupStatus = PandoraImpl.BootupStatus.kDownloading;
         int num = 0;
         List <PandoraImpl.DownloadASTask> list2 = new List <PandoraImpl.DownloadASTask>(this.pendingDownloadASTasks);
         using (List <PandoraImpl.DownloadASTask> .Enumerator enumerator4 = list2.GetEnumerator())
         {
             while (enumerator4.MoveNext())
             {
                 PandoraImpl.DownloadASTask current4 = enumerator4.get_Current();
                 if (current4.isDownloading)
                 {
                     num++;
                 }
             }
         }
         using (List <PandoraImpl.DownloadASTask> .Enumerator enumerator5 = list2.GetEnumerator())
         {
             while (enumerator5.MoveNext())
             {
                 PandoraImpl.DownloadASTask current5 = enumerator5.get_Current();
                 PandoraImpl.DownloadASTask task     = current5;
                 int num2 = Utils.NowSeconds() - task.lastDownloadTime;
                 if (!task.isDownloading && num2 > this.retryDownloadASInterval)
                 {
                     Logger.DEBUG(string.Concat(new object[]
                     {
                         "task.url=",
                         task.url,
                         " task.size=",
                         task.size,
                         " task.md5=",
                         task.md5
                     }));
                     Action <int, Dictionary <string, object> > action2 = delegate(int downloadRet, Dictionary <string, object> result)
                     {
                         Logger.DEBUG(string.Concat(new object[]
                         {
                             "task.url=",
                             task.url,
                             " task.size=",
                             task.size,
                             " task.md5=",
                             task.md5
                         }));
                         if (downloadRet == 0)
                         {
                             Logger.DEBUG(string.Empty);
                             this.resMgr.AddCacheFileMeta(task.name, task.size, task.md5);
                             Action <bool> action3 = delegate(bool status)
                             {
                                 task.isDownloading = false;
                                 this.pendingDownloadASTasks.Remove(task);
                                 if (status)
                                 {
                                     Logger.DEBUG(string.Empty);
                                     using (Dictionary <string, List <PandoraImpl.FileState> > .Enumerator enumerator6 = this.dependencyInfos.GetEnumerator())
                                     {
                                         while (enumerator6.MoveNext())
                                         {
                                             KeyValuePair <string, List <PandoraImpl.FileState> > current6 = enumerator6.get_Current();
                                             using (List <PandoraImpl.FileState> .Enumerator enumerator7 = current6.get_Value().GetEnumerator())
                                             {
                                                 while (enumerator7.MoveNext())
                                                 {
                                                     PandoraImpl.FileState current7 = enumerator7.get_Current();
                                                     if (current7.name == task.name)
                                                     {
                                                         current7.isReady = true;
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                     this.TryDoLua(task.name);
                                     this.pendingDownloadASTasks.Remove(task);
                                 }
                                 else
                                 {
                                     Logger.ERROR(task.name + " load to mem failed!");
                                     this.resMgr.DeleteFile(task.name);
                                 }
                             };
                             if (Utils.IsLuaAssetBundle(task.name))
                             {
                                 this.StartCoroutine(this.resMgr.LoadLuaAssetBundle(task.name, action3));
                             }
                             else
                             {
                                 action3.Invoke(true);
                             }
                         }
                         else
                         {
                             Logger.ERROR(string.Empty);
                             task.isDownloading = false;
                         }
                     };
                     task.isDownloading = true;
                     num++;
                     task.lastDownloadTime = Utils.NowSeconds();
                     string destFile = Pandora.Instance.GetCachePath() + "/" + Path.GetFileName(task.url);
                     this.netLogic.AddDownload(task.url, task.size, task.md5, destFile, 0, action2);
                     if (num >= this.maxDownloadingTaskNum)
                     {
                         break;
                     }
                 }
             }
         }
         if (this.pendingDownloadASTasks.get_Count() == 0)
         {
             Logger.DEBUG(string.Empty);
             this.bootupStatus = PandoraImpl.BootupStatus.kDownloadDone;
         }
     }
 }