private void UpdateFixedText(FixedFlyItem item, float realTime) { if (null == item) { return; } float curTime = realTime - item.AniStart; float x = 0, y = 0; item.GetAnimationPos(curTime, ref x, ref y); item.ShowText.transform.localPosition = new Vector3(x, y, 0f); Color c = item.ShowText.color; c.a = item.GetAnimationAlpha(curTime); item.ShowText.color = c; x = item.GetAnimationScale(curTime); item.ShowText.transform.localScale = new Vector3(x, x, x); x = item.GetAnimationTime(); if (curTime > x) { Recycle(item); } }
private void Recycle(FixedFlyItem item) { List <FixedFlyItem> activeList = m_FixedTextDict[item.mType]; List <FixedFlyItem> cacheList = m_CachedDict[item.mType]; item.Recycle(); activeList.Remove(item); cacheList.Add(item); //item.gameObject.SetActive(false); item.gameObject.transform.SetRenderActive(false); }
private void ShowFixedFly(FixedFlyType type, string text) { Transform parent = null; switch (type) { case FixedFlyType.Exp: parent = ExpRoot; break; case FixedFlyType.Huanling: case FixedFlyType.Mochong: parent = SkillRoot; break; default: break; } if (null == parent) { return; } List <FixedFlyItem> activeList = m_FixedTextDict[type]; List <FixedFlyItem> cacheList = m_CachedDict[type]; string path = m_FlyTextPath[type]; FixedFlyItem item = null; int cnt = cacheList.Count; if (cnt > 0) { item = cacheList[cnt - 1]; cacheList.RemoveAt(cnt - 1); item.transform.localPosition = Vector3.zero; //item.gameObject.SetActive(true); item.gameObject.transform.SetRenderActive(true); } 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); item = obj.GetComponent <FixedFlyItem>(); } if (null != item) { activeList.Add(item); item.Init(Time.realtimeSinceStartup, text, type); } }