/// <summary> /// 读取配置初始化 包列表信息 /// </summary> /// <param name="data"></param> /// <param name="offset"></param> public void Read(byte[] data, ref int offset, bool procDependency = false) { int count = MemoryOperator.ReadShort(data, ref offset); int resCount = 0; for (int i = 0; i < count; i++) { ResPackInfo packInfo = CreatePackInfo(data, ref offset); if (packInfo != null) { packInfo.Read(data, ref offset); if (procDependency) { packInfo.ProcessDependency(PackInfo); } PackInfo.Add(packInfo); resCount += packInfo.Resources.Count; } } if (_resourceMap == null) { _resourceMap = new JWObjDictionary <string, ResPackInfo>(resCount, StringComparer.OrdinalIgnoreCase); } for (int i = 0; i < PackInfo.Count; ++i) { AddToMap(PackInfo[i]); } }
public void UnInit() { StopAllCoroutines(); // _curSession = null; _localFileList = null; _netFileList = null; _diffFileList = null; //移动解压终止 if (_cachedDownloader != null) { _cachedDownloader.Dispose(); _cachedDownloader = null; } //终止文件列表下载 if (_diffDownloadInfo != null) { foreach (KeyValuePair <uint, string> kvp in _diffDownloadInfo) { HttpService.GetInstance().UnRegisteFileHttpDownload(kvp.Key); } _diffDownloadInfo.Clear(); _diffDownloadInfo = null; } _errorCnt = 0; IsDone = false; }
public override void Uninitialize() { _curState = null; if (_registedState != null) { _registedState.Clear(); _registedState = null; } }
public void StopSession() { StopCoroutine("StartSession"); //回收 if (_netFileList != null) { _netFileList = null; } if (_localFileList != null) { _localFileList = null; } if (_diffFileList != null) { _diffFileList = null; } //移动解压终止 if (_cachedDownloader != null) { _cachedDownloader.Dispose(); _cachedDownloader = null; } //终止文件列表下载 if (_diffDownloadInfo != null) { foreach (KeyValuePair <uint, string> kvp in _diffDownloadInfo) { HttpService.GetInstance().UnRegisteFileHttpDownload(kvp.Key); } _diffDownloadInfo.Clear(); _diffDownloadInfo = null; } if (_curSession == null) { JW.Common.Log.LogE("IFS Service Stop No Run"); return; } else { _curSession.SessionHandler = null; //删除标记文件 string ifsDir = JW.Res.FileUtil.GetIFSExtractPath(); string localPath = JW.Res.FileUtil.CombinePath(ifsDir, _curSession.FileListFileName); JW.Res.FileUtil.DeleteFile(localPath); _curSession = null; } // IsDone = true; }
/// <summary> /// 注册游戏状态 /// </summary> /// <param name="name"></param> /// <param name="state"></param> public void RegisteState(string name, IState state) { if (_registedState == null) { _registedState = new JWObjDictionary <string, IState>(); } if (_registedState.ContainsKey(name)) { JW.Common.Log.LogE("StateService:Already Registed:" + name); return; } if (state != null) { state.InitializeState(); } _registedState.Add(name, state); }
/// <summary> /// 添加包信息 /// </summary> /// <param name="packInfo"></param> public void AddPackInfo(ResPackInfo packInfo) { if (packInfo == null) { return; } if (_resourceMap == null) { _resourceMap = new JWObjDictionary <string, ResPackInfo>(StringComparer.OrdinalIgnoreCase); } packInfo.ProcessDependency(PackInfo); PackInfo.Add(packInfo); AddToMap(packInfo); }
/// 下载更新文件 ToDO优化 IEnumerator DoDownloadDiffFileList() { if ((_diffFileList != null) && (_diffFileList.FileList.Count > 0)) { _diffTotalCnt = _diffFileList.FileList.Count; _diffDownloadedCnt = 0; string ifsDir = JW.Res.FileUtil.GetIFSExtractPath(); for (int i = 0; i < _diffFileList.FileList.Count; i++) { string url = _curSession.NetFileRootUrl + _diffFileList.FileList[i].FileName; string localPath = JW.Res.FileUtil.CombinePath(ifsDir, _diffFileList.FileList[i].FileName); uint sid = HttpService.GetInstance().RegisteFileHttpDownload(url, localPath, OnDiffFileDownloaded); if (_diffDownloadInfo == null) { _diffDownloadInfo = new JWObjDictionary <uint, string>(_diffFileList.FileList.Count); } else { _diffDownloadInfo.Clear(); } _diffDownloadInfo.Add(sid, _diffFileList.FileList[i].FileName); } // while (_diffDownloadInfo.Count > 0) { CallSessionHandler(IFSState.DownloadingDiff, (float)_diffDownloadedCnt / _diffTotalCnt); yield return(null); } // CallSessionHandler(IFSState.DownloadDiffSuccess, 1.0f); } else { CallSessionHandler(IFSState.DownloadDiffSuccess, 1.0f); } // _diffDownloadInfo = null; yield return(null); }
public ResCache() { _resources = new JWObjDictionary <string, ResObj>(StringComparer.OrdinalIgnoreCase); }
void OnGUI() { if (!BundleService.IsValidate()) { return; } JWObjDictionary <string, BundleRef> bundleDict = BundleService.GetInstance().BundleDict; GUILayout.Space(3f); GUILayout.BeginVertical(); // list title GUILayout.BeginHorizontal("Table Title", GUILayout.MinHeight(20f)); GUILayout.Label("Index", _labelStyle, GUILayout.Width(60f)); GUILayout.Label("RefCnt", _labelStyle, GUILayout.Width(60f)); GUILayout.Label("Tag", _labelStyle, GUILayout.Width(120f)); GUILayout.Label("Name", _labelStyle, GUILayout.Width(60f)); GUILayout.EndHorizontal(); ResPackConfig config = ResService.GetInstance().PackConfig; if (config == null) { return; } // list mScroll = GUILayout.BeginScrollView(mScroll); int index = 0; foreach (var kv in bundleDict) { BundleRef bundle = kv.Value; BundlePackInfo pi = config.GetPackInfo(bundle.Path) as BundlePackInfo; if (pi == null) { continue; } index++; GUILayout.BeginHorizontal("Table Row", GUILayout.MinHeight(20f)); // index GUILayout.Label(index.ToString(), _labelStyle, GUILayout.Width(60f)); // ref count GUILayout.Label(bundle.RefCnt.ToString(), _labelStyle, GUILayout.Width(60f)); // tag //GUILayout.Label(pi.Tag, _labelStyle, GUILayout.Width(120f)); // path GUILayout.Label(pi.Path, _labelStyle); GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.Space(3f); }