static void onGetVerinfor(params object[] param) { byte[] content = param[0] as byte[]; object orgs = param[1]; if (content != null) { string fPath = orgs as string; progress = progress + 1; MapEx.set(localverVer, fPath, MapEx.getString(serververVer, fPath)); string fName = PStr.b().a(CLPathCfg.persistentDataPath).a("/").a(newestVerPath).a("/").a(fPath).e(); if (Path.GetFileName(fName) == "priority.ver") { //-- 优先更新需要把所有资源更新完后才记录 isNeedUpgradePriority = true; serverPriorityVer = CLVerManager.self.toMap(content); CLVerManager.self.localPriorityVer = serverPriorityVer; } else { otherResVerNew = CLVerManager.self.toMap(content); CLVerManager.self.otherResVerNew = otherResVerNew; } MapEx.set(needUpgradeVerver, fPath, true); if (progressCallback != null) { Utl.doCallback(progressCallback, needUpgradeVerver.Count, progress); } //-- if (isFinishAllGet()) then if (needUpgradeVerver.Count == progress) { if (!isNeedUpgradePriority) { //-- 说明没有优先资源需要更新,可以不做其它处理了 //--同步到本地 loadPriorityVer(); loadOtherResVer(true); } else { checkPriority(); //--处理优先资源更新 } } } else { initFailed(); } }
static void checkVervers() { progress = 0; needUpgradeVerver.Clear(); isNeedUpgradePriority = false; string ver = null; ArrayList keysList = MapEx.keys2List(serververVer); int count = keysList.Count; string basePath = CLPathCfg.self.basePath; string key = ""; for (int i = 0; i < count; i++) { key = keysList[i] as string; ver = MapEx.getString(localverVer, key); //实际上这个时间localverVer是空的 if (ver == null || ver != MapEx.getString(serververVer, key)) { if (!key.Contains(PStr.b().a(basePath).a("/ui/panel").e()) && !key.Contains(PStr.b().a(basePath).a("/ui/cell").e()) && !key.Contains(PStr.b().a(basePath).a("/ui/other").e())) { MapEx.set(needUpgradeVerver, key, false); } } } keysList.Clear(); keysList = null; if (needUpgradeVerver.Count > 0) { if (progressCallback != null) { Utl.doCallback(progressCallback, needUpgradeVerver.Count, 0); } keysList = MapEx.keys2List(needUpgradeVerver); count = keysList.Count; key = ""; for (int i = 0; i < count; i++) { key = keysList[i] as string; getVerinfor(key, MapEx.getString(serververVer, key)); } keysList.Clear(); keysList = null; } else { loadPriorityVer(); loadOtherResVer(true); } }
public static string getTextFromCache(string path) { if (string.IsNullOrEmpty(path)) { return(null); } string ret = MapEx.getString(FileTextMap, path); if (string.IsNullOrEmpty(ret)) { ret = FileEx.ReadAllText(path); FileTextMap [path] = ret; } return(ret); }
static void checkPriority() { localPriorityVer = new Hashtable(); progress = 0; needUpgradeVerver.Clear(); needUpgradePrioritis.Clear(); string ver = null; ArrayList keysList = MapEx.keys2List(serverPriorityVer); string key = null; int count = keysList.Count; for (int i = 0; i < count; i++) { key = keysList[i] as string; ver = MapEx.getString(localPriorityVer, key); //实际上这个时间localverVer是空的,因此其实就是取得所有优先资源,但是因为了加了版本号,所以可以使用cdn,或者本地缓存什么的 if (ver == null || ver != MapEx.getString(serverPriorityVer, key)) { MapEx.set(needUpgradeVerver, key, false); needUpgradePrioritis.Enqueue(key); } } keysList.Clear(); keysList = null; if (needUpgradePrioritis.Count > 0) { haveUpgrade = true; CLVerManager.self.haveUpgrade = true; if (progressCallback != null) { Utl.doCallback(progressCallback, needUpgradeVerver.Count, 0); } getPriorityFiles(needUpgradePrioritis.Dequeue() as string); } else { //--同步总的版本管理文件到本地 //MemoryStream ms = new MemoryStream(); //B2OutputStream.writeMap(ms, localverVer); //string vpath = PStr.b().a(CLPathCfg.persistentDataPath).a("/").a(mVerverPath).e(); //FileEx.CreateDirectory(Path.GetDirectoryName(vpath)); //File.WriteAllBytes(vpath, ms.ToArray()); loadOtherResVer(true); } }
//-- 取得优先更新的资源 static void getPriorityFiles(string fPath) { string Url = ""; string verVal = MapEx.getString(serverPriorityVer, fPath); //--把版本号拼在后面 Url = PStr.begin().a(baseUrl).a("/").a(fPath).a(".").a(verVal).e(); //-- print("Url=="..Url); WWWEx.get(Url, CLAssetType.bytes, (Callback)onGetPriorityFiles, (Callback)initFailed, fPath, true); if (progressCallback != null) { Utl.doCallback(progressCallback, needUpgradeVerver.Count, progress, WWWEx.getWwwByUrl(Url)); } }
public static CLBulletBase fire(CLUnit attacker, CLUnit target, Vector3 orgPos, Vector3 dir, object attr, object data, object callbak) { if (attr == null || attacker == null) { Debug.LogError("bullet attr is null"); return(null); } string bulletName = MapEx.getString(attr, "PrefabName"); if (!CLBulletPool.havePrefab(bulletName)) { ArrayList list = new ArrayList(); list.Add(attacker); list.Add(target); list.Add(orgPos); list.Add(dir); list.Add(attr); list.Add(data); list.Add(callbak); CLBulletPool.borrowObjAsyn(bulletName, (Callback)onFinishBorrowBullet, list, null); return(null); } CLBulletBase bullet = CLBulletPool.borrowObj(bulletName); if (bullet == null) { return(null); } bullet.doFire(attacker, target, orgPos, dir, attr, data, callbak); NGUITools.SetActive(bullet.gameObject, true); // bullet.FixedUpdate(); return(bullet); }
public void getNewestRes(string path, CLAssetType type, object onGetAsset, bool autoRealseAB, params object[] originals) { if (string.IsNullOrEmpty(path)) { return; } string verVal = ""; if (!MapEx.getBool(wwwMap, path)) { bool needSave = false; wwwMap[path] = true; if (localPriorityVer[path] != null) { //在优先资源里有 needSave = false; } else { //则可能在others里 object obj1 = otherResVerOld[path]; object obj2 = otherResVerNew[path]; if (obj1 == null && obj2 != null) { //本地没有,最新有 verVal = MapEx.getString(otherResVerNew, path); needSave = true; } else if (obj1 != null && obj2 != null) { if (obj1.ToString().Equals(obj2.ToString())) {//本地是最新的 needSave = false; } else { //本地不是最新的 verVal = MapEx.getString(otherResVerNew, path); needSave = true; } } else if (obj1 != null && obj2 == null) {//本地有,最新没有 needSave = false; } else { //都没有找到 needSave = false; #if UNITY_EDITOR // Debug.LogWarning ("Not found.path==" + path); #endif } } string url = ""; if (needSave) { if (!string.IsNullOrEmpty(verVal)) { url = PStr.begin().a(baseUrl).a("/").a(path).a(".").a(verVal).end(); } else { url = PStr.begin().a(baseUrl).a("/").a(path).end(); } if (isPrintDownload) { Debug.LogWarning(url); } } else { url = PStr.begin().a(CLPathCfg.persistentDataPath).a("/").a(path).end(); if (!File.Exists(url)) { url = System.IO.Path.Combine(Application.streamingAssetsPath, path); #if !UNITY_ANDROID || UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX url = PStr.begin().a("file://").a(url).end(); #endif } else { url = PStr.begin().a("file://").a(url).end(); } } doGetContent(path, url, needSave, type, onGetAsset, autoRealseAB, originals); } }