/// <summary> /// 异步下载网页文本 /// </summary> /// <param name="url"></param> /// <param name="AsynResult"></param> /// <param name="onError"></param> public void AsynDownLoadHtml(string url, Action <string> AsynResult, Action onError) { Action action = () => { string text = DownLoadHtml(url); if (string.IsNullOrEmpty(text)) { if (onError != null) { LOLGameDriver.Invoke(onError); } } else { if (AsynResult != null) { LOLGameDriver.Invoke(() => { AsynResult(text); }); //AsynResult(text); } } }; //开始异步下载 action.BeginInvoke(null, null); }
public void OnFinished() { if (Finished != null) { LOLGameDriver.Invoke(Finished); } //Finished(); }
private void CheckVersion(Action finished) { //添加一个解压文件界面提示回调 Action <bool> fileDecompress = (finish) => { LOLGameDriver.Invoke(() => { EventCenter.Broadcast(EGameEvent.eGameEvent_HideMessage); if (finish) { CEvent evt = new CEvent(EGameEvent.eGameEvent_ShowMessage); evt.AddParam("content", StringConfigManager.GetString("EMessageType.EMT_UpdateTip.Content2")); EventCenter.SendEvent <EMessageType, Action <bool> >(evt, EMessageType.EMT_Tip, null); Debug.Log("正在更新本地文件"); } else { CEvent evt = new CEvent(EGameEvent.eGameEvent_ShowMessage); evt.AddParam("content", StringConfigManager.GetString("EMessageType.EMT_UpdateTip.Content3")); EventCenter.SendEvent <EMessageType, Action <bool> >(evt, EMessageType.EMT_Tip, null); Debug.Log("数据读取中"); } }); }; Action <int, int, string> taskProgress = (total, index, fileName) => { LOLGameDriver.Invoke(() => { //正在下载更新文件 Debug.Log(string.Format("正在下载更新文件({0}/{1}:{2})", index + 1, total, fileName)); CEvent evt = new CEvent(EGameEvent.eGameEvent_ShowMessage); evt.AddParam("index", index + 1); evt.AddParam("total", total); evt.AddParam("fileName", fileName); EventCenter.SendEvent <EMessageType, Action <bool> >(evt, EMessageType.EMT_UpdateDownload, (isOk) => { if (isOk) { Application.OpenURL("http://www.baidu.com"); } else { } }); }); }; Action <int, long, long> progress = (ProgressPercentage, TotalBytesToReceive, BytesReceive) => { //处理进度条 Debug.Log(string.Format("进度:{0}%", ProgressPercentage)); }; Action <Exception> error = (ex) => { Debug.Log(ex); }; //界面提示版本检查中 //EventCenter.Broadcast<EMessageType, Action<bool>>(EGameEvent.eGameEvent_ShowMessage, EMessageType.EMT_UpdateTip,null); CEvent cEvent = new CEvent(EGameEvent.eGameEvent_ShowMessage); cEvent.AddParam("content", StringConfigManager.GetString("EMessageType.EMT_UpdateTip.Content1")); EventCenter.SendEvent <EMessageType, Action <bool> >(cEvent, EMessageType.EMT_Tip, null); Debug.Log("版本检查中..."); VersionManager.singleton.CheckVersion(fileDecompress, taskProgress, progress, finished, error); }