//------------------------------------------- void Update() { float realTime = Time.realtimeSinceStartup; for (int i = 0; i < mDropFlyItemList.Count; i++) { DropFlyItem item = mDropFlyItemList[i]; if (null != item) { item.UpdateItem(realTime); if (realTime > item.GetStayTime()) { RecycleDropFlyItem(item, true); } } } for (int i = 0; i < mDropGoldFlyItemList.Count; i++) { DropGoldFlyItem item = mDropGoldFlyItemList[i]; if (null != item) { item.UpdateItem(realTime); if (realTime > item.GetAnimationTime() + item.mAniStart) { RecycleDropGoldFlyItem(item); } } } for (int i = 0; i < mDropFlyTipItemList.Count; i++) { DropFlyTipItem item = mDropFlyTipItemList[i]; if (null != item) { item.UpdateItem(realTime); if (realTime > item.GetAnimationTime() + item.mAniStart) { RecycleDropFlyTipItem(item); } } } if (Time.realtimeSinceStartup - mLastTime > mIntervalTime) { if (mProcessFlyTips.Count > 0) { FlyTipInfo info = mProcessFlyTips.Dequeue(); ShowDropFlyTipItem(info.name, info.quality); mLastTime = Time.realtimeSinceStartup; } } }
/// <summary> /// 回收拾取 /// </summary> /// <param name="item"></param> private void RecycleDropFlyItem(DropFlyItem item, bool isDone = false) { //item.gameObject.SetActive(false); item.gameObject.transform.SetRenderActive(false); mDropFlyItemList.Remove(item); mCachedFlyItemList.Add(item); if (isDone) { DoBagTween(); EventToUI.SetArg(UIEventArg.Arg1, item.mItemName); EventToUI.SetArg(UIEventArg.Arg2, item.mItemQuality); EventToUI.SendEvent("EU_SHOW_DROPFLYTIP"); } }
/// <summary> /// 显示拾取 /// </summary> /// <param name="icon"></param> private void ShowDropFlyItem(float startTime, string icon, Vector3 startPos, Vector3 endPos, string itemName, int quality) { DropFlyItem item = null; int cnt = mCachedFlyItemList.Count; if (cnt > 0) { item = mCachedFlyItemList[cnt - 1]; mCachedFlyItemList.RemoveAt(cnt - 1); //item.gameObject.SetActive(true); item.gameObject.transform.SetRenderActive(true); } else { GameObject prefab = (GameObject)CoreEntry.gResLoader.Load(mDropFlyItemPath, typeof(GameObject)); if (null == prefab) { return; } GameObject obj = Instantiate(prefab) as GameObject; if (null == obj) { return; } obj.transform.SetParent(DropFlyRoot); obj.transform.localScale = Vector3.one; obj.SetActive(true); item = obj.GetComponent <DropFlyItem>(); } if (null != item) { mDropFlyItemList.Add(item); item.Init(startTime, icon, startPos, endPos, itemName, quality); } }