public static byte[] getBytesFromCache(string path) { if (string.IsNullOrEmpty(path)) { return(null); } byte[] ret = MapEx.getBytes(FileBytesMap, path); if (ret == null) { ret = FileEx.ReadAllBytes(path); FileBytesMap [path] = ret; } return(ret); }
public static byte[] myLuaLoader(ref string filepath) { byte[] bytes = null; string luaPath = ""; string strs = ""; try { if (!filepath.StartsWith(CLPathCfg.self.basePath)) { //说明是通过require进来的 filepath = filepath.Replace(".", "/"); filepath = PStr.b().a(CLPathCfg.self.basePath).a("/upgradeRes/priority/lua/").a(filepath).a(".lua").e(); } #if UNITY_EDITOR if (CLCfgBase.self.isEditMode) { filepath = filepath.Replace("/upgradeRes/", "/upgradeRes4Dev/"); luaPath = PStr.b().a(Application.dataPath).a("/").a(filepath).e(); bytes = MapEx.getBytes(FileBytesCacheMap, luaPath); if (bytes != null) { filepath = luaPath; return(bytes); } if (File.Exists(luaPath)) { strs = FileEx.getTextFromCache(luaPath); bytes = System.Text.Encoding.UTF8.GetBytes(strs); filepath = luaPath; return(bytes); } } #endif //======================================================= //1.first load from CLPathCfg.persistentDataPath; luaPath = PStr.b().a(CLPathCfg.persistentDataPath).a("/").a(filepath).e(); bytes = MapEx.getBytes(FileBytesCacheMap, luaPath); if (bytes != null) { filepath = luaPath; return(bytes); } if (File.Exists(luaPath)) { bytes = FileEx.getBytesFromCache(luaPath); if (bytes != null) { // bytes = System.Text.Encoding.UTF8.GetBytes(strs); bytes = deCodeLua(bytes); FileBytesCacheMap [luaPath] = bytes; filepath = luaPath; return(bytes); } } //======================================================= //2.second load from Application.streamingAssetsPath; luaPath = PStr.b().a(Application.streamingAssetsPath).a("/").a(filepath).e(); bytes = MapEx.getBytes(FileBytesCacheMap, luaPath); if (bytes != null) { filepath = luaPath; return(bytes); } bytes = FileEx.getBytesFromCache(luaPath); if (bytes != null) { // bytes = System.Text.Encoding.UTF8.GetBytes(strs); bytes = deCodeLua(bytes); FileBytesCacheMap [luaPath] = bytes; filepath = luaPath; return(bytes); } //======================================================= //3.third load from Resources.Load (); luaPath = filepath; bytes = MapEx.getBytes(FileBytesCacheMap, luaPath); if (bytes != null) { filepath = luaPath; return(bytes); } TextAsset text = Resources.Load <TextAsset> (filepath); if (text != null) { bytes = text.bytes; // System.Text.Encoding.UTF8.GetBytes(text.text); if (bytes != null) { bytes = deCodeLua(bytes); FileBytesCacheMap [luaPath] = bytes; filepath = luaPath; return(bytes); } } //========================== return(bytes); } catch (System.Exception e) { Debug.LogError(luaPath + ":" + e); return(null); } }
public static byte[] getContent(string fileName) { return(MapEx.getBytes(resCache4Webgl, fileName)); }
public void fire(int firePointIndex, int numPoints, int numEach, float angle, float offsetTime, CLUnit attacker, CLUnit target, object attr, object data, object callbak) { if (attacker == null || attr == null) { return; } //#if UNITY_EDITOR // CLTest cltest = GetComponent<CLTest>(); // if(cltest == null) { // cltest = gameObject.AddComponent<CLTest>(); // } // cltest.fire ( numPoints, numEach, angle, attacker); //#endif Transform firePoint = null; if (firePointIndex < 0 || firePoints == null || firePoints.Length <= firePointIndex) { firePoint = transform; } else { firePoint = firePoints[firePointIndex]; } int h = NumEx.bio2Int(MapEx.getBytes(attr, "High")); bool isZeroY = h > 0 ? true : false; if (numPoints > 0) { // get fire point bool needFireMid = false; //是否需要在中间发射(是奇数时需要) int half = numPoints / 2; if (numPoints % 2 == 0) { needFireMid = false; } else { needFireMid = true; } Vector3 pos2 = Vector3.zero; Vector3 dir = Vector3.zero; for (int i = 0; i < numEach; i++) { if (needFireMid) { dir = attacker.mbody.forward; if (isZeroY) { dir.y = 0; } // StartCoroutine (createBullet (attacker, target, firePoint.position, dir, attr, data, callbak, i * 0.1f)); object[] list = { attacker, target, firePoint.position, dir, attr, data, callbak }; InvokeEx.invokeByFixedUpdate((Callback)createBullet2, list, i * offsetTime); } for (int j = 1; j <= half; j++) { pos2 = AngleEx.getCirclePointStartWithYV3(firePoint.position, 2, attacker.mbody.eulerAngles.y - j * angle); if (isZeroY) { pos2.y = 0; } dir = pos2 - firePoint.position; // StartCoroutine (createBullet (attacker, target, firePoint.position, dir, attr, data, callbak, i * 0.1f)); object[] list = { attacker, target, firePoint.position, dir, attr, data, callbak }; InvokeEx.invokeByFixedUpdate((Callback)createBullet2, list, i * offsetTime); pos2 = AngleEx.getCirclePointStartWithYV3(firePoint.position, 2, attacker.mbody.eulerAngles.y + j * angle); if (isZeroY) { pos2.y = 0; } dir = pos2 - firePoint.position; // StartCoroutine (createBullet (attacker, target, firePoint.position, dir, attr, data, callbak, i * 0.1f)); object[] list2 = { attacker, target, firePoint.position, dir, attr, data, callbak }; InvokeEx.invokeByFixedUpdate((Callback)createBullet2, list2, i * offsetTime); } } } }