예제 #1
0
        private void UpdateFlyText()
        {
            float realTime = Time.realtimeSinceStartup;

            for (int i = 0; i < (int)FlyTextType.Max; ++i)
            {
                List <FlyText> showList  = m_FlyTextList[i];
                List <FlyText> cacheList = m_CachedList[i];
                for (int j = 0; j < showList.Count;)
                {
                    FlyText ft = showList[j];
                    if (UpdateFlyText(ft, realTime))
                    {
                        showList.RemoveAt(j);
                        cacheList.Add(ft);
                        //ft.gameObject.SetActive(false);
                        ft.gameObject.transform.SetRenderActive(false);
                    }
                    else
                    {
                        ++j;
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 更新票字。
        /// </summary>
        /// <param name="ft">飘字对象。</param>
        /// <param name="realTime">当前时间。</param>
        /// <returns>是否结束。</returns>
        private bool UpdateFlyText(FlyText ft, float realTime)
        {
            float curTime = realTime - ft.AniStart;
            float x = 0, y = 0;

            ft.GetAnimationPos(curTime, ref x, ref y);
            ft.UpdateBindPosition();
            if (ft.Inverse)
            {
                ft.ShowText.transform.localPosition = new Vector3(ft.StartPosition.x - x, ft.StartPosition.y + y, 0f);
            }
            else
            {
                ft.ShowText.transform.localPosition = new Vector3(ft.StartPosition.x + x, ft.StartPosition.y + y, 0f);
            }
            Color c = ft.ShowText.color;

            c.a = ft.GetAnimationAlpha(curTime);
            ft.ShowText.color = c;
            x = ft.GetAnimationScale(curTime);
            ft.ShowText.transform.localScale = new Vector3(x, x, x);

            float maxt = ft.AniCurve.GetAnimationTime();

            return(curTime > maxt);
        }
예제 #3
0
        private void ShowText(GameObject owner, string text, FlyTextType type, int isGood = 0)
        {
            Transform parent = FlyTextRoot;

            if (null == parent)
            {
                return;
            }

            string         path       = m_FlyTextPath[type];
            List <FlyText> activeList = m_FlyTextList[(int)type];
            List <FlyText> cacheList  = m_CachedList[(int)type];

            int     cachedCnt = cacheList.Count;
            FlyText ft        = null;

            if (cachedCnt > 0)
            {
                ft = cacheList[cachedCnt - 1];
                cacheList.RemoveAt(cachedCnt - 1);
                if (ft != null)
                {
                    ft.AniStart = Time.realtimeSinceStartup;

                    ft.transform.localPosition = Vector3.zero;
                    //ft.gameObject.SetActive(true);
                    ft.gameObject.transform.SetRenderActive(true);
                    activeList.Add(ft);
                }
            }
            else
            {
                GameObject prefab = (GameObject)CoreEntry.gResLoader.Load(path, typeof(GameObject));
                if (null == prefab)
                {
                    return;
                }
                GameObject obj = Instantiate(prefab) as GameObject;
                if (null == obj)
                {
                    return;
                }

                obj.transform.SetParent(parent);
                obj.transform.localPosition = Vector3.zero;
                obj.transform.localScale    = Vector3.one;
                obj.SetActive(true);
                ft = obj.GetComponent <FlyText>();
                if (ft != null)
                {
                    ft.AniStart = Time.realtimeSinceStartup;

                    activeList.Add(ft);
                }
            }

            if (null != ft)
            {
                ft.Init(owner, text, type, isGood);
            }
        }