From 00d47de2f5c810542c1668c153f47f38122a47c6 Mon Sep 17 00:00:00 2001
From: weixudong <weixudong4700@ktgame.com>
Date: Thu, 12 Nov 2020 20:23:10 +0800
Subject: [PATCH] Merge branch 'master' of ssh://172.16.1.52:8091/GemBattle into master

---
 Assets/Scripts/TowerDefense/UI/EndlessDropReward.cs |   73 +++++++++++++++++++++++++++++++-----
 1 files changed, 62 insertions(+), 11 deletions(-)

diff --git a/Assets/Scripts/TowerDefense/UI/EndlessDropReward.cs b/Assets/Scripts/TowerDefense/UI/EndlessDropReward.cs
index 91a3148..1b41082 100644
--- a/Assets/Scripts/TowerDefense/UI/EndlessDropReward.cs
+++ b/Assets/Scripts/TowerDefense/UI/EndlessDropReward.cs
@@ -1,9 +1,13 @@
+using UnityEngine.UI;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using Core.Utilities;
 using TowerDefense.Level;
 using System;
+using Protobuf;
+using DG.Tweening;
+
 
 /**
  * 无尽模式道具掉落管理器
@@ -43,40 +47,87 @@
     public class EndlessDropReward : MonoBehaviour
     {
         /// <summary>
-        /// 道具类型
-        /// 1- money 2-gold 3-rmb 4-gem 5-box (Table.cs请看)
+        /// 发光粒子特效
         /// </summary>
-        public int Type;
+        public ParticleSystem LightParticle;
 
         /// <summary>
-        /// 道具id,例如宝箱 1-初级宝箱 2-中级宝箱 3-高级宝箱
+        /// item图标
         /// </summary>
-        public int Id;
-
-        /// <summary>
-        /// 奖励数量
-        /// </summary>
-        public int Count { get; set; }
+        public Image Icon;
 
         /// <summary>
         /// 自动拾取时间
         /// </summary>
-        public float AutoPickupTime = 5f;
+        public float AutoPickupTime { get; set; } = 5f;
 
         public EndlessDrop DropData;
 
+        private string path = "UI/Props/";
+
         public event Action<EndlessDrop> ClickDropEvent;
+
+        private bool isBox;//是否是宝箱
+        private GameObject propBtn;
 
         // Start is called before the first frame update
         private void Start()
         {
             ClickDropEvent += EndlessDropManager.instance.OnClickDrop;
+            propBtn = GameObject.Find("BottomUI/PropsObtained/PropButton");
         }
 
+        public GameObject drapIcon;
         public void OnClick()
         {
+            if (isBox)
+            {
+                EndlessDropManager.instance.FlyIcon(transform.parent, Icon.sprite, transform.position, (propBtn.transform as RectTransform).position, true);
+            }
+            else
+            {
+                FlyImage fly = EndlessDropManager.instance.CreateIcon(transform.parent);
+                fly.SetDestination(Icon.sprite, transform.position, (propBtn.transform as RectTransform).position, false);
+            }
             if (ClickDropEvent != null)
                 ClickDropEvent(DropData);
+
         }
+
+        public void SetIcon()
+        {
+            string resId = "";
+            Vector3 scale = Icon.rectTransform.localScale;
+
+            if (DropData.Reward.id == 0)
+            {
+                resId = $"{path}{(int)DropData.Reward.type}";
+                isBox = true;
+            }
+            else
+            {
+                resId = $"{path}{(int)DropData.Reward.type}_{DropData.Reward.id}";
+                scale *= 1.5f;
+                isBox = false;
+
+            }
+            Icon.sprite = Resources.Load<Sprite>(resId);
+            Icon.SetNativeSize();
+
+            //Debug.Log("开始缩放");
+            Icon.rectTransform.localScale = scale * 0.5f;
+            Icon.rectTransform.DOScale(scale, 0.5f);
+
+        }
+
+        /// <summary>
+        /// 播放发光的粒子特效
+        /// </summary>
+        public void PlayParticle()
+        {
+            LightParticle.Play();
+        }
+
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1