Example #1
0
        static IEnumerator UF_ICrossRenderAlpha(GameObject target, float vfrom, float vto, float duration, bool ingoreTimeScale)
        {
            List <CanvasRenderer> array = ListCache <CanvasRenderer> .Acquire();

            target.GetComponentsInChildren <CanvasRenderer>(true, array);
            CanvasRenderer coloreffect = null;

            if (array != null && array.Count > 0)
            {
                float progress = 0;
                float tickBuff = 0;
                while (progress < 1)
                {
                    float delta = ingoreTimeScale ? GTime.DeltaTime : GTime.UnscaleDeltaTime;
                    tickBuff += delta;
                    progress  = Mathf.Clamp01(tickBuff / duration);
                    float current = progress * vto + (1 - progress) * vfrom;
                    for (int k = 0; k < array.Count; k++)
                    {
                        coloreffect = array[k];
                        if (coloreffect != null)
                        {
                            coloreffect.SetAlpha(current);
                        }
                    }
                    yield return(null);
                }
            }
            ListCache <CanvasRenderer> .Release(array);
        }
Example #2
0
        protected override void UF_OnRun(float progress)
        {
            if (m_MapTriggerCache.Count > 0 && interval > 0)
            {
                float             t        = time;
                List <GameObject> tempList = ListCache <GameObject> .Acquire();

                foreach (var key in m_MapTriggerCache.Keys)
                {
                    tempList.Add(key);
                }
                for (int k = 0; k < tempList.Count; k++)
                {
                    var key = tempList[k];
                    if (key == null)
                    {
                        continue;
                    }
                    //if (key.activeSelf == false) {
                    //    m_MapTriggerCache.Remove(key);
                    //    continue;
                    //}
                    float dt = time - m_MapTriggerCache[key];
                    if (dt >= interval)
                    {
                        m_MapTriggerCache[key] = time;
                        TriggerGameObject(key);
                    }
                }
                ListCache <GameObject> .Release(tempList);
            }
        }
Example #3
0
        protected override void UF_OnRun(float dtime)
        {
            m_ExistTime += dtime;

            if (m_MapTriggerCache.Count > 0 && interval > 0)
            {
                float             time     = m_ExistTime;
                List <GameObject> tempList = ListCache <GameObject> .Acquire();

                foreach (var key in m_MapTriggerCache.Keys)
                {
                    tempList.Add(key);
                }
                for (int k = 0; k < tempList.Count; k++)
                {
                    var   key = tempList[k];
                    float dt  = time - m_MapTriggerCache[key];
                    if (dt >= interval)
                    {
                        m_MapTriggerCache[key] = time;
                        var tarHitPoint = key.transform.position;
                        tarHitPoint.y = this.transform.position.y;
                        this.UF_OnColliderEnter(key, tarHitPoint);
                    }
                }
                ListCache <GameObject> .Release(tempList);
            }

            UF_UpdateAttach();
        }
Example #4
0
//
//		private bool checkIsDragCollsion(Rect a,Rect b){
//			//			Rect rect = Rect.zero;
//			//			Rect pice = Rect.zero;
//			//			//比较面积
//			//			if (a.width * a.height > b.width * b.height) {
//			//				rect = a;
//			//				pice = b;
//			//			} else {
//			//				rect = b;
//			//				pice = a;
//			//			}
//			//
//			//			mPoints [0] = new Vector2 (pice.x, pice.y);
//			//			mPoints [1] = new Vector2 (pice.x + pice.width, pice.y);
//			//			mPoints [2] = new Vector2 (pice.x + pice.width, pice.y + pice.height);
//			//			mPoints [3] = new Vector2 (pice.x, pice.y + pice.height);
//			//
//			//			for(int k = 0;k < mPoints.Length;k++){
//			//				if (rect.Contains (mPoints [k])) {
//			//					return true;
//			//				}
//			//			}
//
//			Vector2 point = new Vector2 (a.x + a.width / 2.0f, a.y + a.height / 2);
//			return b.Contains (point);
//
//		}
//
//
//		private bool CheckCollsion(Rect box,Vector2 pos){
//			return box.Contains (pos);
//		}
//
//
//
//		public void UpdateCollision(UIDrag target,Vector2 pos){
//			if (m_Drags != null && m_Drags.Count > 0) {
//				UIDrag drag = null;
//				for (int k = 0; k < m_Drags.Count; k++) {
//					drag = m_Drags [k];
//					if (drag != null && drag!= target && drag.gameObject.activeInHierarchy && drag.enabled) {
////						if (checkIsDragCollsion (getRect (target.rectTransform.rect, pos),getRect (drag.rectTransform.rect, drag.rectTransform.anchoredPosition))) {
//						if(CheckCollsion(getRect (drag.rectTransform.rect, drag.rectTransform.anchoredPosition),pos)){
//							SendEventMessage (target, m_Drags [k]);
//							break;
//						}
//					}
//				}
//			}
//		}
//

        //EventSystem 射线方式检测,适配各种对其
        internal void UF_UpdateCollision(UIDrag target, PointerEventData eventData)
        {
            if (m_Drags != null && m_Drags.Count > 0)
            {
                List <UnityEngine.EventSystems.RaycastResult> listRaycastResult = ListCache <UnityEngine.EventSystems.RaycastResult> .Acquire();

                UnityEngine.EventSystems.EventSystem.current.RaycastAll(eventData, listRaycastResult);
                if (listRaycastResult.Count > 0)
                {
                    for (int i = 0; i < listRaycastResult.Count; i++)
                    {
                        var go = listRaycastResult [i].gameObject;
                        for (int k = 0; k < m_Drags.Count; k++)
                        {
                            if (m_Drags [k] != null && target.gameObject != go && m_Drags [k].gameObject == go)
                            {
                                UF_SendEventMessage(target, m_Drags [k]);
                                if (!allowMultiCollision)
                                {
                                    ListCache <UnityEngine.EventSystems.RaycastResult> .Release(listRaycastResult);

                                    return;
                                }
                            }
                        }
                    }
                }
                ListCache <UnityEngine.EventSystems.RaycastResult> .Release(listRaycastResult);
            }
        }
Example #5
0
        //设置粒子状态
        protected void UF_SetParticlesState(int state)
        {
            List <ParticleSystem> list = ListCache <ParticleSystem> .Acquire();

            this.GetComponentsInChildren <ParticleSystem>(false, list);
            foreach (var item in list)
            {
                switch (state)
                {
                case 1:
                    if (item.isPlaying)
                    {
                        item.Stop(false);
                    }
                    item.Play(false);
                    if (sortingOrder != 0)
                    {
                        ParticleSystemRenderer renderer = item.GetComponent <ParticleSystemRenderer>();
                        if (renderer != null)
                        {
                            renderer.sortingOrder = sortingOrder;
                        }
                    }
                    ; break;

                case 2: item.Stop(false); break;

                case 3: item.Pause(false); break;

                case 4: item.Play(false); break;
                }
            }
            ListCache <ParticleSystem> .Release(list);
        }
Example #6
0
        public void UF_OnUpdate()
        {
            float currentTime = GTime.Time;

            if ((currentTime - m_TimeStamp) >= m_TickDuration)
            {
                m_TimeStamp = currentTime;
                List <string> listTemp = ListCache <string> .Acquire();

                foreach (AssetBundleData item in m_DicBundleBuffer.Values)
                {
                    if (item.assetbundle == null)
                    {
                        listTemp.Add(item.name);
                        continue;
                    }
                    if ((item.flag == LoadAssetBundleOptions.UNLOAD_IN_NO_REF) && item.refCount <= 0)
                    {
                        item.UF_Tick();
                        if (item.tick > m_MaxTickCount)
                        {
                            listTemp.Add(item.name);
                        }
                    }
                }
                for (int k = 0; k < listTemp.Count; k++)
                {
                    m_DicBundleBuffer[listTemp[k]].UF_Dispose();
                    m_DicBundleBuffer.Remove(listTemp[k]);
                }
                ListCache <string> .Release(listTemp);
            }
        }
Example #7
0
        private void UF_OnIngoreMask(PointerEventData eventData)
        {
            List <UnityEngine.EventSystems.RaycastResult> listRaycastResult = ListCache <UnityEngine.EventSystems.RaycastResult> .Acquire();

            UnityEngine.EventSystems.EventSystem.current.RaycastAll(eventData, listRaycastResult);
            if (listRaycastResult.Count > 0)
            {
                int idx = 0;
                for (idx = 0; idx < listRaycastResult.Count; idx++)
                {
                    if (listRaycastResult [idx].gameObject == this.gameObject)
                    {
                        //往下没有button
                        if (++idx < listRaycastResult.Count)
                        {
                            //穿透下一个,触发下一个事件
                            PointerClick(UF_GetPointerClickHandler(listRaycastResult [idx].gameObject), eventData);
                        }
                        return;
                    }
                }
                //没有目标对象,则第一个索引为下一个clicker
                PointerClick(UF_GetPointerClickHandler(listRaycastResult [0].gameObject), eventData);
            }
            ListCache <UnityEngine.EventSystems.RaycastResult> .Release(listRaycastResult);
        }
Example #8
0
        public void UF_GenNeibourhood(int width, int height)
        {
            var tmplist = ListCache <int> .Acquire();

            for (int i = -1; i <= 1; i++)
            {
                for (int j = -1; j <= 1; j++)
                {
                    // 如果是自己,则跳过
                    if (i == 0 && j == 0)
                    {
                        continue;
                    }
                    int x = X + i;
                    int y = Y + j;
                    // 判断是否越界,如果没有,加到列表中
                    if (!(x >= 0 && x < width && y >= 0 && y < height))
                    {
                        continue;
                    }

                    tmplist.Add((int)(y * width + x));
                }
            }
            Neibourhood = tmplist.ToArray();
            ListCache <int> .Release(tmplist);
        }
Example #9
0
        public static void UF_OnPopulateMesh(UILabel label, List <TextToken> tokens, List <UIVertex> uivertexs, int startIndex = 0)
        {
            List <ColorData> listColors = ListCache <ColorData> .Acquire();

            UF_HandleToken(tokens, listColors);
            UF_HandleMesh(uivertexs, listColors, startIndex);
            ListCache <ColorData> .Release(listColors);
        }
Example #10
0
        public static void UF_OnPopulateMesh(UILabel label, List <TextToken> tokens, List <UIVertex> uivertexs, int startIndex = 0)
        {
            List <SpriteData> listSpriteDatas = ListCache <SpriteData> .Acquire();

            RTSpriteBoard spriteBoard = UF_GetSpriteBoard(label);

            UF_HandleToken(tokens, listSpriteDatas, label.fontSize);
            UF_HandleMesh(uivertexs, listSpriteDatas, spriteBoard, startIndex);
            ListCache <SpriteData> .Release(listSpriteDatas);
        }
Example #11
0
        //停止全部
        public void UF_AllStop()
        {
            List <FXController> list = ListCache <FXController> .Acquire();

            UF_GetAllActiveFXController(list);
            foreach (FXController val in list)
            {
                val.UF_Stop();
            }
            ListCache <FXController> .Release(list);
        }
Example #12
0
        public static void UF_ResetTailRender(UnityEngine.GameObject go)
        {
            List <TrailRenderer> tempList = ListCache <TrailRenderer> .Acquire();

            go.GetComponentsInChildren <TrailRenderer>(false, tempList);
            foreach (var tr in tempList)
            {
                tr.Clear();
            }
            ListCache <TrailRenderer> .Release(tempList);
        }
Example #13
0
        public void Stop()
        {
            List <ParticleSystem> list = ListCache <ParticleSystem> .Acquire();

            this.GetComponentsInChildren <ParticleSystem>(false, list);
            foreach (var item in list)
            {
                item.Stop(false);
            }
            ListCache <ParticleSystem> .Release(list);
        }
Example #14
0
        //强制清除动态实体
        public void Clear()
        {
            List <FXController> list = ListCache <FXController> .Acquire();

            this.GetComponentsInChildren <FXController>(false, list);
            foreach (var item in list)
            {
                item.Release();
            }
            ListCache <FXController> .Release(list);
        }
Example #15
0
        public static void UF_OnPopulateMesh(UILabel label, List <TextToken> tokens, List <UIVertex> uivertexs, int startIndex = 0)
        {
            List <ULineData> listULineDatas = ListCache <ULineData> .Acquire();

            //基于fontsize ,计算size
            float SizeScale = label.fontSize * 0.1f;

            UF_CheckInfoBlock(label);
            UF_HandleToken(tokens, listULineDatas, SizeScale);
            UF_HandleMesh(uivertexs, listULineDatas, startIndex);
            ListCache <ULineData> .Release(listULineDatas);
        }
Example #16
0
        protected override void OnApplySortingOrder()
        {
            //获取正确的渲染序号
            int             absOrder = rootSortingOrder + sortingOrder;
            List <Renderer> list     = ListCache <Renderer> .Acquire();

            this.gameObject.GetComponentsInChildren <Renderer>(false, list);
            foreach (var render in list)
            {
                render.sortingOrder = absOrder;
            }
            ListCache <Renderer> .Release(list);
        }
Example #17
0
        public RaycastHit[] UF_GetRayHitReflex(Vector3 point, Vector3 forward, float distance, int tarLayerMask, int reflexTimes)
        {
            var listTemp = ListCache <RaycastHit> .Acquire();

            Vector3 sPoint   = point;
            Vector3 sForward = forward;

            this.UF_GetRayHitReflex(point, forward, distance, tarLayerMask, reflexTimes, listTemp);
            var ret = listTemp.ToArray();

            ListCache <RaycastHit> .Release(listTemp);

            return(ret);
        }
Example #18
0
        public static string[] UF_SplitStringWithCount(string param, int count, char split = ';')
        {
            if (string.IsNullOrEmpty(param) || count <= 0)
            {
                return(null);
            }
            List <string> list = ListCache <string> .Acquire();

            UF_SplitStringWithCount(param, count, list, split);
            string[] array = list.ToArray();
            ListCache <string> .Release(list);

            return(array);
        }
Example #19
0
        public static void UF_SetRenderColor(GameObject target, Color value)
        {
            List <CanvasRenderer> array = ListCache <CanvasRenderer> .Acquire();

            target.GetComponentsInChildren <CanvasRenderer>(true, array);
            if (array != null && array.Count > 0)
            {
                for (int k = 0; k < array.Count; k++)
                {
                    array[k].SetColor(value);
                }
            }
            ListCache <CanvasRenderer> .Release(array);
        }
Example #20
0
        public static void UF_SetGrey(GameObject target, bool opera)
        {
            List <IUIColorable> array = ListCache <IUIColorable> .Acquire();

            target.GetComponentsInChildren <IUIColorable>(true, array);
            if (array != null && array.Count > 0)
            {
                for (int k = 0; k < array.Count; k++)
                {
                    array[k].UF_SetGrey(opera);
                }
            }
            ListCache <IUIColorable> .Release(array);
        }
Example #21
0
        public static string[] UF_SplitString(string param, char split = ';')
        {
            if (string.IsNullOrEmpty(param))
            {
                return(null);
            }
            //string[] array = param.Split(new char[] { split }, System.StringSplitOptions.RemoveEmptyEntries);
            List <string> list = ListCache <string> .Acquire();

            UF_SplitString(param, list, split);
            string[] array = list.ToArray();
            ListCache <string> .Release(list);

            return(array);
        }
Example #22
0
        public static void UF_RebuildSiblingLayout(IUILayout layout)
        {
            List <IUILayout> list = ListCache <IUILayout> .Acquire();

            (layout as MonoBehaviour).gameObject.GetComponents <IUILayout>(list);
            foreach (var item in list)
            {
                //忽略标签布局
                if (item != layout)
                {
                    item.UF_RebuildLoyout();
                }
            }
            ListCache <IUILayout> .Release(list);
        }
Example #23
0
        private void UF_FindingPath(SceneMap map, List <Vector3> outList, int Ax, int Ay, int Bx, int By)
        {
            var listGridPoint = ListCache <Vector2> .Acquire();

            ASGridPathFinder.UF_FindingPath(map.asGrid, Ax, Ay, Bx, By, listGridPoint, true);
            if (listGridPoint.Count > 1)
            {
                //转化grid点为世界地图点
                foreach (var point in listGridPoint)
                {
                    outList.Add(map.UF_GetGridPosition((int)point.x, (int)point.y));
                }
            }
            ListCache <Vector2> .Release(listGridPoint);
        }
Example #24
0
        public static void UF_SetAlpha(GameObject target, float value)
        {
            List <IUIColorable> array = ListCache <IUIColorable> .Acquire();

            target.GetComponentsInChildren <IUIColorable>(true, array);
            value = Mathf.Clamp01(value);
            if (array != null && array.Count > 0)
            {
                for (int k = 0; k < array.Count; k++)
                {
                    array[k].UF_SetAlpha(value);
                }
            }
            ListCache <IUIColorable> .Release(array);
        }
Example #25
0
        //获取附近一个点
        public Vector2 UF_GetGridPointInLocal(int x, int y, int state, int range, int randIndex)
        {
            int            startX   = Mathf.Max(0, x - range);
            int            endX     = Mathf.Min(gridWidth, x + range);
            int            startY   = Mathf.Max(0, y - range);
            int            endY     = Mathf.Min(gridHeight, y + range);
            int            lenX     = Mathf.Abs(startX - endX);
            int            lenY     = Mathf.Abs(startY - endY);
            Vector2        ret      = new Vector2(x, y);
            List <Vector2> tempList = ListCache <Vector2> .Acquire();

            for (int i = 0; i <= lenX; i++)
            {
                for (int j = 0; j <= lenY; j++)
                {
                    int tx = Mathf.Min(startX + i, gridWidth - 1);
                    int ty = Mathf.Min(startY + j, gridHeight - 1);
                    if (UF_GetGridState(tx, ty) == state)
                    {
                        tempList.Add(new Vector2(tx, ty));
                    }
                }
            }
            if (tempList.Count == 0)
            {
                ListCache <Vector2> .Release(tempList);

                return(ret);
            }
            if (randIndex == 0)
            {
                ret = tempList[0];
            }
            else
            {
                //取出对应的索引
                int index = randIndex;
                if (randIndex > tempList.Count)
                {
                    index = randIndex % tempList.Count;
                }
                ret = tempList[Mathf.Max(0, index - 1)];
            }
            ListCache <Vector2> .Release(tempList);

            return(ret);
        }
Example #26
0
        public static bool UF_CheckStringMask(string strMask, string pattern, char split = ';')
        {
            bool          retVal = false;
            List <string> list   = ListCache <string> .Acquire();

            UF_SplitString(strMask, list, split);
            foreach (var v in list)
            {
                if (pattern.IndexOf(v, System.StringComparison.Ordinal) > -1)
                {
                    retVal = true;
                }
            }
            ListCache <string> .Release(list);

            return(retVal);
        }
Example #27
0
        public void UF_ExecuteTweenAlpha(string valchunk)
        {
            if (string.IsNullOrEmpty(valchunk))
            {
                return;
            }
            List <string> list = ListCache <string> .Acquire();

            GHelper.UF_SplitStringWithCount(valchunk, 4, list, ';');
            float vform      = GHelper.UF_ParseFloat(list[0]);
            float vto        = GHelper.UF_ParseFloat(list[1]);
            float vduration  = GHelper.UF_ParseFloat(list[2]);
            bool  vtimescale = GHelper.UF_ParseBool(list[3]);

            UF_CrossRenderAlpha(vform, vto, vduration, vtimescale);
            ListCache <string> .Release(list);
        }
Example #28
0
        public void UF_ClearAll(bool unloadAllLoadedObjects)
        {
            List <string> listTemp = ListCache <string> .Acquire();

            foreach (AssetBundleData item in m_DicBundleBuffer.Values)
            {
                listTemp.Add(item.name);
            }
            for (int k = 0; k < listTemp.Count; k++)
            {
                m_DicBundleBuffer[listTemp[k]].UF_Dispose(unloadAllLoadedObjects);
            }
            m_DicBundleBuffer.Clear();
            ListCache <string> .Release(listTemp);

            Resources.UnloadUnusedAssets();
            //AssetBundle.UnloadAllAssetBundles(unloadAllLoadedObjects);
        }
Example #29
0
        public override string ToString()
        {
            System.Text.StringBuilder sb   = StrBuilderCache.Acquire();
            List <FXController>       list = ListCache <FXController> .Acquire();

            UF_GetAllActiveFXController(list);
            sb.AppendLine(string.Format("FX  Count:{0} \n", list.Count));
            foreach (FXController val in list)
            {
                if (val != null)
                {
                    sb.AppendLine(string.Format("\t {0} | life: {1} | left: {2} ", val.name, val.life, val.leftLife));
                }
            }
            ListCache <FXController> .Release(list);

            return(StrBuilderCache.GetStringAndRelease(sb));
        }
Example #30
0
        /// <summary>
        /// 播放Action,并清空之前的播放列表,可用';'间隔多个Action的播放,所有Action播放完毕会触发完成事件
        /// </summary>
        public void UF_Play(string strName, bool triggerEvent, float fSpeed, string playParam = "", DelegateMethod eventFinish = null)
        {
            if (string.IsNullOrEmpty(strName))
            {
                return;
            }
            if (lockPlay)
            {
                Debugger.UF_Warn(string.Format("Animator Has been lock,play {0} failed", strName));
                return;
            }
            //避免重复播放
            if (m_isPlayingElemelt && m_CurrentPlayClip != null && m_CurrentPlayClip.name == strName)
            {
                return;
            }
            UF_ClearPlayQueue();
            m_CurrentPlayClip = null;
            m_IsOver          = false;
            m_IsPause         = false;
            this.ctrlSpeed    = 1;
            if (strName.IndexOf(';') > -1)
            {
                List <string> inlist = ListCache <string> .Acquire();

                GHelper.UF_SplitString(strName, inlist);
                for (int k = 0; k < inlist.Count; k++)
                {
                    if (!string.IsNullOrEmpty(inlist[k]))
                    {
                        UF_AddToPlayQueue(inlist[k], triggerEvent, fSpeed, string.Empty, eventFinish);
                    }
                }
                ListCache <string> .Release(inlist);
            }
            else
            {
                UF_AddToPlayQueue(strName, triggerEvent, fSpeed, playParam, eventFinish);
            }

            //立即执行更新一次,避免播放速度过快导致显示异常
            this.UF_OnUpdate();
        }