/// <summary> /// 显示属性改变。 /// </summary> /// <param name="type">属性类型。</param> /// <param name="oldvalue">改变前的值。</param> /// <param name="newvalue">改变值。</param> /// <param name="delay">显示延迟。</param> public void ShowAttrChange(BasicAttrEnum type, double oldvalue, double newvalue, float delay) { var change = newvalue - oldvalue; if (type == BasicAttrEnum.Power) { //同一时间只显示一个战斗变化 if (CurPowerFlyAttr != null) { RemoveFlyAttr(CurPowerFlyAttr); } CurPowerFlyAttr = GetFlyAttr(change > 0 ? 0 : 1); if (newvalue > oldvalue) { //CoreEntry.gAudioMgr.PlayUISound(900011); } CurPowerFlyAttr.Init(type, oldvalue, newvalue, 0, -150, delay); } else { ItemFlyAttr item = GetFlyAttr(change > 0 ? 2 : 3); item.Init(type, (float)oldvalue, (float)newvalue, 200, 50, delay); CurFlyAttr.Add(item); } }
public void ShowTextChange(string text, int oldvalue, int newvalue, float delay) { int change = newvalue - oldvalue; { ItemFlyAttr item = GetFlyAttr(change > 0 ? 2 : 3); item.Init(BasicAttrEnum.Exp, oldvalue, newvalue, 200, 50, delay); item.NameText.text = text; CurFlyAttr.Add(item); } }
public void RemoveFlyAttr(ItemFlyAttr item) { Stack <ItemFlyAttr> cache; if (!m_CacheFlyAttr.TryGetValue(item.ShowType, out cache)) { cache = new Stack <ItemFlyAttr>(); m_CacheFlyAttr.Add(item.ShowType, cache); } item.gameObject.SetActive(false); CurFlyAttr.Remove(item); cache.Push(item); //战斗力去除 if (item.ShowType == 0 || item.ShowType == 1) { CurPowerFlyAttr = null; } }
public ItemFlyAttr GetFlyAttr(int type) { Stack <ItemFlyAttr> cache; if (!m_CacheFlyAttr.TryGetValue(type, out cache)) { cache = new Stack <ItemFlyAttr>(); m_CacheFlyAttr.Add(type, cache); } if (cache.Count > 0) { ItemFlyAttr item = cache.Pop(); item.gameObject.SetActive(true); return(item); } GameObject prefab = (GameObject)CoreEntry.gResLoader.Load(Prefabs[type], typeof(GameObject)); if (prefab == null) { return(null); } GameObject obj = GameObject.Instantiate(prefab) as GameObject; RectTransform rt = obj.GetComponent <RectTransform>(); ItemFlyAttr ret = obj.GetComponent <ItemFlyAttr>(); obj.SetActive(true); rt.SetParent(FlyAttrRoot); rt.anchoredPosition3D = Vector3.zero; rt.localScale = Vector3.one; ret.ShowType = type; return(ret); }