Beispiel #1
0
 public void doSetPrefab(string path, string name, object finishCallback, object args, object progressCB)
 {
     if (name == null)
     {
         return;
     }
     if (MapEx.getBool(isSettingPrefabMap, name))
     {
         return;
     }
     if (_havePrefab(name))
     {
         if (finishCallback != null)
         {
             Utl.doCallback(finishCallback, prefabMap [name], args);
         }
     }
     else
     {
         isSettingPrefabMap [name] = true;
         Callback cb = onGetAssetsBundle;
         CLVerManager.self.getNewestRes(path,
                                        CLAssetType.assetBundle,
                                        cb, isAutoReleaseAssetBundle, finishCallback, name, args, progressCB);
     }
 }
Beispiel #2
0
 public NewMap put(params object[] args)
 {
     lock (this) {
         MapEx.putKvs(this, args);
         return(this);
     }
 }
Beispiel #3
0
        public int getCoroutineIndex(object callbakFunc)
        {
            object key = getKey4InvokeMap(callbakFunc, coroutineIndex);
            int    ret = MapEx.getInt(coroutineIndex, key);

            coroutineIndex [key] = ret + 1;
            return(ret);
        }
Beispiel #4
0
        public Hashtable getCoroutines(object callbakFunc)
        {
            object    key = getKey4InvokeMap(callbakFunc, coroutineMap);
            Hashtable ret = MapEx.getMap(coroutineMap, key);

            ret = ret == null ? new Hashtable() : ret;
            coroutineMap[key] = ret;
            return(ret);
        }
Beispiel #5
0
 public static Vector2 mapToVector2(Hashtable map)
 {
     if (map == null)
     {
         return(Vector2.zero);
     }
     return(new Vector2(
                (float)(MapEx.getDouble(map, "x")),
                (float)(MapEx.getDouble(map, "y"))));
 }
Beispiel #6
0
        public static Color mapToColor(Hashtable map)
        {
            Color c = new Color(
                (float)(MapEx.getDouble(map, "r")),
                (float)(MapEx.getDouble(map, "g")),
                (float)(MapEx.getDouble(map, "b")),
                (float)(MapEx.getDouble(map, "a"))
                );

            return(c);
        }
Beispiel #7
0
        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);
            }
        }
Beispiel #8
0
        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();
            }
        }
Beispiel #9
0
        public void prepareOneSprite4BorrowMode(UIAtlas atlas, string spriteName, object callback, object orgs)
        {
            UISpriteData sd = atlas.getSpriteBorrowMode(spriteName);

            if (sd != null && MapEx.get(UIAtlas.assetBundleMap, sd.path) != null)
            {
                Utl.doCallback(callback, null, spriteName, orgs);
            }
            else
            {
                atlas.borrowSpriteByname(spriteName, null, callback, orgs);
            }
        }
Beispiel #10
0
 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);
 }
Beispiel #11
0
        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);
        }
Beispiel #12
0
        public void add(string key, object callback, object orgs)
        {
            ArrayList list = MapEx.getList(delegateInfro, key);

            if (list == null)
            {
                list = ObjPool.listPool.borrowObject();
            }
            NewList infor = ObjPool.listPool.borrowObject();

            infor.Add(callback);
            infor.Add(orgs);
            list.Add(infor);
            delegateInfro [key] = list;
        }
Beispiel #13
0
        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);
            }
        }
Beispiel #14
0
        public void switchByName(string cellName, Animator animator, object callback)
        {
            if (!isInited)
            {
                init();
            }
            int index = MapEx.getInt(mapIndex, cellName);

            if (needSwitchController)
            {
                if (animator != null)
                {
                    animator.runtimeAnimatorController = animatorControllers [index];
                }
                else
                {
                    Debug.LogError("animator is null");
                }
            }

            if (switchType == CLSwitchType.showOrHide)
            {
                for (int i = 0; i < partObjs.Count; i++)
                {
                    if (i == index)
                    {
                        NGUITools.SetActive(partObjs [i], true);
                    }
                    else
                    {
                        NGUITools.SetActive(partObjs [i], false);
                    }
                }
                Utl.doCallback(callback);
            }
            else if (switchType == CLSwitchType.switchShader)
            {
                if (render.sharedMaterial != null)
                {
                    string mName = render.sharedMaterial.name;
//					mName = mName.Replace(" (Instance)", "");
                    CLMaterialPool.returnObj(mName);
                    render.sharedMaterial = null;
                }
                setMat(render, materialNames [index], callback);
            }
        }
Beispiel #15
0
        public void onGetNewstRes(UnityWebRequest www, string url, string path, CLAssetType type, object content, bool needSave, object onGetAsset, bool autoRealseAB, params object[] originals)
        {
            try
            {
                if (needSave)
                {
                    //说明是需要下载的资源
                    if (www != null && content == null && (MapEx.getInt(wwwTimesMap, path) + 1) < downLoadTimes4Failed)
                    {
                        //需要下载资源时,如查下载失败,且少于失败次数,则再次下载
                        wwwTimesMap[path] = MapEx.getInt(wwwTimesMap, path) + 1;
                        doGetContent(path, url, needSave, type, onGetAsset, autoRealseAB, originals);
                        return;
                    }
                    rmWWW(url);
                }
                if (content == null)
                {
                    Debug.LogError("get newstRes is null. url==" + url);
                }
                Utl.doCallback(onGetAsset, path, content, originals);
            }
            catch (System.Exception e)
            {
                Debug.LogError(e);
            }

            if (autoRealseAB && content != null && type == CLAssetType.assetBundle)
            {
                AssetBundle ab = content as AssetBundle;
                if (ab != null)
                {
                    ab.Unload(false);
                }
            }

            if (www != null)
            {
                www.Dispose();
                www = null;
            }

            wwwMap[path]      = false;
            wwwTimesMap[path] = 0;
        }
Beispiel #16
0
        /// <summary>
        /// Gets the material cfg.取得material引用图片的配置
        /// </summary>
        /// <returns><c>true</c>, if material cfg was gotten, <c>false</c> otherwise.</returns>
        /// <param name="matName">Mat name.</param>
        /// <param name="propNames">Property names.</param>
        /// <param name="texNames">Tex names.</param>
        /// <param name="texPaths">Tex paths.</param>
        public static bool getMaterialTexCfg(string matName, ref ArrayList propNames, ref ArrayList texNames, ref ArrayList texPaths)
        {
            Hashtable cfg = MapEx.getMap(materialTexRefCfg, matName);
            bool      ret = true;

            if (cfg == null)
            {
                Debug.LogError("Get MaterialTexCfg is null!" + matName);
                ret = false;
            }
            else
            {
                propNames = cfg["pp"] as ArrayList;
                texNames  = cfg["tn"] as ArrayList;
                texPaths  = cfg["tp"] as ArrayList;
            }
            return(ret);
        }
Beispiel #17
0
        //-- 取得优先更新的资源
        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));
            }
        }
Beispiel #18
0
 public void switch2xx(string partName, string cellName, object callback)
 {
     if (!isInited)
     {
         isInited = true;
         setMapindex();
     }
     try {
         int        index = MapEx.getInt(mapIndex, partName);
         CLBodyPart part  = bodyParts [index];
         if (part == null)
         {
             return;
         }
         part.switchByName(cellName, animator, callback);
     } catch (System.Exception e) {
         Debug.LogError(e);
     }
 }
        void onTopPanelChange(CLPanelBase p)
        {
            //			CLPanelBase[] ps = panelRetainLayer.ToArray ();
            //			if (ps != null) {
            //				for (int i = 0; i < ps.Length; i++) {
            //					ps [i].onTopPanelChange (p);
            //				}
            //			}
            ArrayList list = MapEx.vals2List(showingPanels);

            if (list != null)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    ((CLPanelBase)(list[i])).onTopPanelChange(p);
                }
                list.Clear();
                list = null;
            }
        }
Beispiel #20
0
        public void remove(string key, object callback)
        {
            ArrayList list = MapEx.getList(delegateInfro, key);

            if (list == null)
            {
                return;
            }

            NewList cell = null;

            while (list.Count > 0)
            {
                cell = (list[list.Count - 1]) as NewList;
                if (cell[0] == null || cell[0].Equals(callback))
                {
                    ObjPool.listPool.returnObject(cell);
                    list.RemoveAt(list.Count - 1);
                }
            }
        }
Beispiel #21
0
        void OnEnable()
        {
            try {
                if (!string.IsNullOrEmpty(spriteName))
                {
                    setMainTexture(spriteName);
                    MarkAsChanged();
                }

                Texture   tt      = null;
                string    _spName = "";
                ArrayList list    = MapEx.keys2List(subTextureNameMap);
                for (int i = 0; i < list.Count; i++)
                {
                    _spName = subTextureNameMap [list [i]] as string;
                    setTexture(list [i].ToString(), _spName);
                }
                list.Clear();
                list = null;
            } catch (System.Exception e) {
                Debug.LogError(e);
            }
        }
Beispiel #22
0
        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);
        }
Beispiel #23
0
        /// <summary>
        /// Gets the animation curve.创建动画曲线
        /// </summary>
        /// <returns>
        /// The animation curve.
        /// </returns>
        /// <param name='list'>
        /// List.
        /// </param>
        /// <param name='postWrapMode'>
        /// Post wrap mode.
        /// </param>
        /// <param name='preWrapMode'>
        /// Pre wrap mode.
        /// </param>
        public static AnimationCurve getAnimationCurve(ArrayList list, WrapMode postWrapMode, WrapMode preWrapMode)
        {
            if (list == null || list.Count <= 0)
            {
                return(null);
            }
            int len = list.Count;

            Keyframe[] ks = new Keyframe[len];
            for (int i = 0; i < len; i++)
            {
                Hashtable m          = (Hashtable)list[i];
                float     inTangent  = (float)MapEx.getDouble(m, "inTangent");
                float     outTangent = (float)MapEx.getDouble(m, "outTangent");
                float     time       = (float)MapEx.getDouble(m, "time");
                float     value      = (float)MapEx.getDouble(m, "value");
                ks[i] = new Keyframe(time, value, inTangent, outTangent);
            }
            AnimationCurve curve = new AnimationCurve(ks);

            curve.preWrapMode  = preWrapMode;
            curve.postWrapMode = postWrapMode;
            return(curve);
        }
Beispiel #24
0
        public virtual void doFire(CLUnit attacker, CLUnit target, Vector3 orgPos, Vector3 dir, object attr, object data, object callbak)
        {
            this.attr        = attr;
            this.data        = data;
            this.attacker    = attacker;
            this.target      = target;
            onFinishCallback = callbak;

            int SpeedRandomFactor = MapEx.getBytes2Int(attr, "SpeedRandomFactor");

            //			int SpeedRandomFactor = NumEx.bio2Int (MapEx.getBytes (attr, "SpeedRandomFactor"));
            speed = MapEx.getBytes2Int(attr, "Speed") / 10.0f;
            //			speed = (NumEx.bio2Int (MapEx.getBytes (attr, "Speed"))) / 10.0f;
            if (SpeedRandomFactor > 0)
            {
                speed = speed + attacker.fakeRandom(-SpeedRandomFactor, SpeedRandomFactor) / 100.0f;
            }
            high = MapEx.getBytes2Int(attr, "High") / 10.0f;
            //			high = NumEx.bio2Int (MapEx.getBytes (attr, "High"));
            if (MapEx.getBool(attr, "IsHighOffset"))
            {
                high = high * (1.0f + attacker.fakeRandom(-200, 200) / 1000.0f);
            }
            bool isZeroY = high > 0 ? true : false;

            float dis = MapEx.getBytes2Int(attr, "Range") / 10.0f;

            //			float dis = NumEx.bio2Int (MapEx.getBytes (attr, "Range")) / 10.0f;
            isFollow            = MapEx.getBool(attr, "IsFollow");
            isMulHit            = MapEx.getBool(attr, "IsMulHit");
            needRotate          = MapEx.getBool(attr, "NeedRotate");
            RefreshTargetMSec   = MapEx.getBytes2Int(attr, "RefreshTargetMSec");
            lastResetTargetTime = DateEx.nowMS;
            lastResetToPosTime  = DateEx.nowMS;
            //dir.y = 0;
            Utl.RotateTowards(transform, dir);

            origin             = orgPos;
            transform.position = origin;
            Vector3 toPos = Vector3.zero;

            if (target != null && dis <= 0)
            {
                toPos = target.transform.position;
            }
            else
            {
                toPos = origin + dir.normalized * dis;
                //toPos.y = 0;
            }
            int PosRandomFactor = MapEx.getBytes2Int(attr, "PosRandomFactor");

            //			int PosRandomFactor = NumEx.bio2Int (MapEx.getBytes (attr, "PosRandomFactor"));
            if (PosRandomFactor > 0)
            {
                toPos.x += attacker.fakeRandom(-PosRandomFactor, PosRandomFactor) / 100.0f;
                toPos.y += attacker.fakeRandom(-PosRandomFactor, PosRandomFactor) / 100.0f;
            }

            //if (isZeroY) {
            //    toPos.y = 0;
            //}

            if (boxCollider != null)
            {
                if (MapEx.getBool(attr, "CheckTrigger"))
                {
                    boxCollider.enabled = true;
                }
                else
                {
                    boxCollider.enabled = false;
                }
            }
            haveCollider = (boxCollider != null && boxCollider.enabled);

            v3Diff = toPos - origin;

            if (angleOffset != 0)
            {
                Vector3 center = origin + v3Diff / 2.0f;
//				transform.position = center + new Vector3 (0, high, 0);
                Vector3 _v3 = Utl.RotateAround(center + new Vector3(0, high, 0), center, v3Diff, angleOffset * Mathf.Sin(Mathf.Deg2Rad * Utl.getAngle(v3Diff).y));
//				transform.RotateAround (center, v3Diff, angleOffset * Mathf.Sin (Mathf.Deg2Rad * Utl.getAngle (v3Diff).y));
                highV3 = _v3 - center;
            }
            else
            {
                highV3 = new Vector3(0, high, 0);
            }

            magnitude = v3Diff.magnitude <= 0.00001f ? 1 : 1.0f / v3Diff.magnitude;

            hitTarget  = null;
            curveTime  = 0;
            curveTime2 = 0;
            isStoped   = false;
            isFireNow  = true;
            RotateBullet();
            CancelInvoke("timeOut");
            int stayTime = MapEx.getBytes2Int(attr, "MaxStayTime");

//			int stayTime = NumEx.bio2Int (MapEx.getBytes (attr, "MaxStayTime"));
            if (stayTime > 0.00001)
            {
                Invoke("timeOut", stayTime / 10.0f);
            }
        }
Beispiel #25
0
 public ArrayList getDelegates(string key)
 {
     return(MapEx.getList(delegateInfro, key));
 }
Beispiel #26
0
        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);
            }
        }
Beispiel #27
0
        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);
                    }
                }
            }
        }
Beispiel #28
0
        public static NewMap create(params object[] args)
        {
            NewMap map = create();

            return(MapEx.putKvs(map, args));
        }
Beispiel #29
0
        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);
            }
        }
Beispiel #30
0
 public static byte[] getContent(string fileName)
 {
     return(MapEx.getBytes(resCache4Webgl, fileName));
 }