static int DownloadAll(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 1) { libx.Downloader arg0 = null; bool o = libx.Assets.DownloadAll(out arg0); LuaDLL.lua_pushboolean(L, o); ToLua.PushObject(L, arg0); return(2); } else if (count == 2) { string[] arg0 = ToLua.CheckStringArray(L, 1); libx.Downloader arg1 = null; bool o = libx.Assets.DownloadAll(arg0, out arg1); LuaDLL.lua_pushboolean(L, o); ToLua.PushObject(L, arg1); return(2); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: libx.Assets.DownloadAll")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
private IEnumerator Checking() { if (!Directory.Exists(_savePath)) { Directory.CreateDirectory(_savePath); } if (_step == Step.Wait) { enableVFS = true; #if UNITY_IPHONE enableVFS = false; #endif _step = Step.Copy; } if (_step == Step.Copy) { yield return(RequestCopy()); } if (_step == Step.Coping) { var path = _savePath + Versions.Filename + ".tmp"; var versions = Versions.LoadVersions(path); var basePath = GetBasePath(); yield return(UpdateCopy(versions, basePath)); _step = Step.Versions; } if (_step == Step.Versions) { yield return(RequestVersions()); } if (_step == Step.Prepared) { OnMessage("正在检查版本信息..."); var totalSize = _downloader.size; if (totalSize > 0) { var tips = string.Format("发现内容更新,总计需要下载 {0} 内容", Downloader.GetDisplaySize(totalSize)); var mb = MessageBox.Show("提示", tips, "下载", "退出"); yield return(mb); if (mb.isOk) { _downloader.StartDownload(); _step = Step.Download; } else { Quit(); } } else { OnComplete(); } } }
private void Update() { switch (_step) { case Step.Wait: break; case Step.Version: _step = Step.Wait; OnMessage("正在获取版本信息..."); if (!Directory.Exists(_savePath)) { Directory.CreateDirectory(_savePath); } if (Application.internetReachability == NetworkReachability.NotReachable) { MessageBox.Show("提示", "请检查网络连接状态", "重试", "退出").onComplete = OnErrorAction; return; } var request = Download(Versions.Filename); var oper = request.SendWebRequest(); oper.completed += delegate { if (!string.IsNullOrEmpty(request.error)) { MessageBox.Show("提示", string.Format("获取服务器版本失败:{0}", request.error), "重试", "退出").onComplete = OnErrorAction; } else { try { Versions.serverVersion = Versions.LoadFullVersion(_savePath + Versions.Filename); var newFiles = Versions.GetNewFiles(PatchBy.Level0, _savePath); if (newFiles.Count > 0) { foreach (var item in newFiles) { _downloader.AddDownload(GetDownloadURL(item.name), item.name, _savePath + item.name, item.hash, item.len); } _step = Step.Prepared; } else { OnComplete(); } } catch (Exception e) { Debug.LogException(e); MessageBox.Show("提示", "版本文件加载失败", "重试", "退出").onComplete += OnErrorAction; } } }; break; case Step.Prepared: OnMessage("正在检查版本信息..."); _step = Step.Wait; var totalSize = _downloader.size; if (totalSize > 0) { var tips = string.Format("发现内容更新,总计需要下载 {0} 内容", Downloader.GetDisplaySize(totalSize)); MessageBox.Show("提示", tips, "下载", "退出").onComplete += delegate(MessageBox.EventId id) { if (id == MessageBox.EventId.Ok) { _downloader.StartDownload(); _step = Step.Download; } else { Quit(); } }; } else { OnComplete(); } break; } }