public void Init(float startTime, string text, FixedFlyType type) { AniStart = startTime; ShowText.text = text; mType = type; if (null != EffectGo) { EffectGo.SetActive(false); } if (type == FixedFlyType.Huanling || type == FixedFlyType.Mochong) { EffectGo.SetActive(true); } }
public override void InitializeSrv() { //CoreEntry.gEventMgr.AddListener(GameEvent.GE_PLAYER_EXP, OnPlayerExp); CoreEntry.gEventMgr.AddListener(GameEvent.GE_PALYER_JINGJIE_EXP, OnPlayerJingJieExp); CoreEntry.gEventMgr.AddListener(GameEvent.GE_FLY_SKILL, OnSkillFlyText); CoreEntry.gEventMgr.AddListener(GameEvent.GE_AddExpInfo, OnAddExpInfo); m_FixedTextDict.Clear(); m_CachedDict.Clear(); for (int i = 0; i < (int)FixedFlyType.Max; i++) { FixedFlyType type = (FixedFlyType)i; m_FixedTextDict[type] = new List <FixedFlyItem>(); m_CachedDict[type] = new List <FixedFlyItem>(); } }
//------------------------------------------- void Update() { DoProcessText(); float realTime = Time.realtimeSinceStartup; for (int i = 0; i < (int)FixedFlyType.Max; i++) { FixedFlyType type = (FixedFlyType)i; if (m_FixedTextDict.ContainsKey(type)) { List <FixedFlyItem> showList = m_FixedTextDict[type]; for (int j = 0; j < showList.Count; j++) { UpdateFixedText(showList[j], realTime); } } } }
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); } }