From 17c6e8b6f2aee4ed9a15c886f54a73f0cb61b125 Mon Sep 17 00:00:00 2001 From: weixudong <weixudong4700@ktgame.com> Date: Wed, 09 Dec 2020 17:14:59 +0800 Subject: [PATCH] Merge branch 'master' of ssh://172.16.1.52:8091/GemBattle into master --- Assets/Scripts/TowerDefense/Level/EndlessDropManager.cs | 93 ++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 80 insertions(+), 13 deletions(-) diff --git a/Assets/Scripts/TowerDefense/Level/EndlessDropManager.cs b/Assets/Scripts/TowerDefense/Level/EndlessDropManager.cs index 5715502..7ea8bf3 100644 --- a/Assets/Scripts/TowerDefense/Level/EndlessDropManager.cs +++ b/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); } } } @@ -100,15 +104,15 @@ /// <param name="pos">小怪的世界坐标</param> public void AddDrop(List<reward> list, Vector3 pos) { - for (int i = 0; i < list.Count; ++i) - { - EndlessDrop drop = new EndlessDrop(); - drop.Reward = list[i]; - drop.Id = GetDropId(); - drop.AutoPickupTime = AutoPickupTime; - CreateDrop(drop, pos, list.Count > 0); - AllDropList.Add(drop); - } + // for (int i = 0; i < list.Count; ++i) + // { + // EndlessDrop drop = new EndlessDrop(); + // drop.Reward = list[i]; + // drop.Id = GetDropId(); + // drop.AutoPickupTime = AutoPickupTime; + // CreateDrop(drop, pos, list.Count > 0); + // AllDropList.Add(drop); + // } } /// <summary> @@ -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); @@ -152,6 +156,10 @@ obj.GetComponent<Transform>().SetParent(mainUITransform, true); obj.transform.position = worldPos; + + Vector3 offect = obj.GetComponent<RectTransform>().anchoredPosition3D; + offect.z = 0; + obj.GetComponent<RectTransform>().anchoredPosition3D = offect; // obj.transform.localRotation = Quaternion.identity; // obj.transform.localScale = Vector3.one; @@ -169,6 +177,65 @@ 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, int count) + { + StartCoroutine(CreateIcon(ts, sp, startP, endP, useBezier, count)); + } + + IEnumerator CreateIcon(Transform ts, Sprite sp, Vector3 startP, Vector3 endP, bool useBezier, int count) + { + 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); + if (i == 0) + { + fly.Init(true, count); + } + else + { + fly.Init(false, 0); + } + + fly.SetDestination(sp, startP, endP, useBezier); + yield return new WaitForSeconds(0.01f); + + } + + yield break; + } + /// <summary> /// 调用掉落获得事件 /// </summary> -- Gitblit v1.9.1