Esempio n. 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);
     }
 }
Esempio n. 2
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);
            }
        }
Esempio n. 3
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);
            }
        }