liuzhiwei
2020-11-04 78e14d93c46238881339f33a56c81275c55d5089
Assets/Scripts/TowerDefense/Level/EndlessDropManager.cs
@@ -54,6 +54,7 @@
        {
            AllDropList = new List<EndlessDrop>();
            DropObjDic = new Dictionary<int, GameObject>();
            allIconLis = new List<FlyImage>();
        }
        // Update is called once per frame
@@ -67,9 +68,12 @@
                if (AllDropList[i].ElapsedTime >= AllDropList[i].AutoPickupTime)
                {
                    AllDropList[i].IsPickupCompleted = true;
                    SafelyCallObtainDrop(AllDropList[i]);
                    RemoveDrop(AllDropList[i].Id);
                    EndlessDropReward dropReward = DropObjDic[AllDropList[i].Id].GetComponent<EndlessDropReward>();
                    dropReward?.OnClick();
                    //AllDropList[i].IsPickupCompleted = true;
                    //SafelyCallObtainDrop(AllDropList[i]);
                    //RemoveDrop(AllDropList[i].Id);
                }
            }
        }
@@ -139,7 +143,7 @@
            dropReward.DropData = drop;
            dropReward.SetIcon();
            GameObject mainUI = GameObject.Find("MainUI");
            GameObject mainUI = GameObject.Find("BottomUI");
            Transform mainUITransform = mainUI.transform;
            obj.transform.SetParent(mainUITransform, false);
@@ -169,6 +173,55 @@
            DropObjDic.Add(drop.Id, obj);
        }
        List<FlyImage> allIconLis;
        public GameObject drapIcon;
        public FlyImage CreateIcon(Transform ts)
        {
            for (int i = 0; i < allIconLis.Count; i++)
            {
                if (!allIconLis[i].gameObject.activeSelf)
                {
                    allIconLis[i].gameObject.SetActive(true);
                    return allIconLis[i];
                }
            }
            GameObject obj = Instantiate(drapIcon, ts);
            FlyImage fly = obj.GetComponent<FlyImage>();
            allIconLis.Add(fly);
            return fly;
        }
        public void FlyIcon(Transform ts, Sprite sp, Vector3 startP, Vector3 endP, bool useBezier)
        {
            StartCoroutine(CreateIcon(ts, sp, startP, endP, useBezier));
        }
        IEnumerator CreateIcon(Transform ts, Sprite sp, Vector3 startP, Vector3 endP, bool useBezier)
        {
            FlyImage fly;
            // for (int i = 0; i < 5; i++)
            // {
            //     fly = CreateIcon(ts);
            //     fly.SetDestination(sp, startP, endP, useBezier);
            // }
            // yield return new WaitForSeconds(0.2f);
            for (int i = 0; i < 15; i++)
            {
                fly = CreateIcon(ts);
                fly.SetDestination(sp, startP, endP, useBezier);
                yield return new WaitForSeconds(0.01f);
            }
            yield break;
        }
        /// <summary>
        /// 调用掉落获得事件
        /// </summary>