From b1f72b6a7f2c3846eacf26721e114e05ffe3a3db Mon Sep 17 00:00:00 2001
From: wangguan <wangguan@kt007.com>
Date: Sat, 26 Dec 2020 17:13:57 +0800
Subject: [PATCH] 修改拖拽,有些脚本随安卓工程上传了

---
 Assets/Scripts/TowerDefense/UI/HUD/SelectBuffIcon.cs |  134 +++++++++++++++++++++++++++++++++++---------
 1 files changed, 107 insertions(+), 27 deletions(-)

diff --git a/Assets/Scripts/TowerDefense/UI/HUD/SelectBuffIcon.cs b/Assets/Scripts/TowerDefense/UI/HUD/SelectBuffIcon.cs
index 7ef97db..7677345 100644
--- a/Assets/Scripts/TowerDefense/UI/HUD/SelectBuffIcon.cs
+++ b/Assets/Scripts/TowerDefense/UI/HUD/SelectBuffIcon.cs
@@ -3,6 +3,7 @@
 using UnityEngine;
 using UnityEngine.UI;
 using System;
+using DG.Tweening;
 
 /**
  * 无尽模式选择buff
@@ -15,12 +16,24 @@
     {
         public Image Icon;
 
-        public Image BgMask;
+        /// <summary>
+        /// 边框
+        /// </summary>
+        public Image BorderImage;
 
-        public Image Check;
+        /// <summary>
+        /// 品质底图
+        /// </summary>
+        public Image QualityImage;
 
+        /// <summary>
+        /// buff名称
+        /// </summary>
         public Text Name;
 
+        /// <summary>
+        /// 效果描述
+        /// </summary>
         public Text Effect;
 
         public event Action<int> OnSelectBuffCompleted;
@@ -30,44 +43,68 @@
         /// </summary>
         public int Index;
 
+        /// <summary>
+        /// 是否被选中
+        /// </summary>
+        public bool IsSelected { get; set; }
+
+        private string iconPath = "UI/Endless/BuffIcon/";
+
+        private string qualityPath = "UI/Endless/BuffQuality/";
+        public ParticleSystem myPS;//播放粒子特效
+        GameObject psParent;
+
+        public BuffFly buffFly;//确定后的飞动脚本
         private void Start()
         {
-            SetState(EndlessBuffSelectState.Normal);
-        }
-
-        /// <summary>
-        /// 设置选中状态
-        /// </summary>
-        /// <param name="state"></param>
-        public void SetState(EndlessBuffSelectState state)
-        {
-            switch (state)
+            if (psParent == null && myPS != null)
             {
-                case EndlessBuffSelectState.Normal:
-                    Check.gameObject.SetActive(false);
-                    BgMask.gameObject.SetActive(false);
-
-                    break;
-                case EndlessBuffSelectState.Unselected:
-                    Check.gameObject.SetActive(false);
-                    BgMask.gameObject.SetActive(true);
-                    break;
-                case EndlessBuffSelectState.Selected:
-                    Check.gameObject.SetActive(true);
-                    BgMask.gameObject.SetActive(false);
-                    break;
+                psParent = myPS.transform.parent.gameObject;
             }
         }
 
         public void OnClick()
         {
+            //判断是否是金钱
+            if (isGold)
+            {
+                AudioSourceManager.Ins.Play(AudioEnum.Gold);
+            }
+            else
+            {
+                AudioSourceManager.Ins.Play(AudioEnum.UI);
+            }
+
             if (OnSelectBuffCompleted != null)
                 OnSelectBuffCompleted(Index);
         }
 
-        public void SetIcon(Sprite param)
+        public void Fly()
         {
-            Icon.sprite = param;
+            if (buffFly != null)
+            {
+                buffFly.SetIcon(Icon.sprite);
+                buffFly.SetQuality(QualityImage.sprite);
+                buffFly.SetName(Name.text);
+                buffFly.SetEffect(Effect.text);
+                buffFly.SetRare(Name.color);
+                buffFly.Fly();
+            }
+
+        }
+
+        public void SetIcon(int resId)
+        {
+            Icon.sprite = Resources.Load($"{iconPath}{resId}", typeof(Sprite)) as Sprite;
+        }
+
+        /// <summary>
+        /// 设置buff品质
+        /// </summary>
+        /// <param name="quality"></param>
+        public void SetQuality(int quality)
+        {
+            QualityImage.sprite = Resources.Load($"{qualityPath}{quality}", typeof(Sprite)) as Sprite;
         }
 
         public void SetName(string buffName)
@@ -92,5 +129,48 @@
         {
             Name.color = EndlessBuffData.GetColorByRare(rare);
         }
+
+        bool isGold;//是否是金币BUFF
+        public void SetIsGold(bool isGold)
+        {
+            this.isGold = isGold;
+        }
+
+
+        /// <summary>
+        /// 设置选中状态,做个缓动播放粒子特效
+        /// </summary>
+        /// <param name="isSelected"></param>
+        public void SetState(bool selected)
+        {
+            if (selected == IsSelected) return;
+
+            IsSelected = selected;
+            BorderImage.gameObject.SetActive(selected);
+
+            if (selected)
+            {
+                DOTween.To(() => transform.localScale, (v) => transform.localScale = v, new Vector3(1f, 1f, 1f), 0.15f);
+                if (!psParent.activeSelf) psParent.SetActive(true);
+                myPS?.Play();
+            }
+            else
+            {
+                DOTween.To(() => transform.localScale, (v) => transform.localScale = v, new Vector3(0.87f, 0.87f, 0.87f), 0.15f);
+                myPS?.Stop();
+                if (psParent.activeSelf) psParent.SetActive(false);
+
+            }
+        }
+
+        /// <summary>
+        /// 重置
+        /// </summary>
+        public void Reset()
+        {
+            IsSelected = false;
+            BorderImage.gameObject.SetActive(false);
+            transform.localScale = new Vector3(0.87f, 0.87f, 0.87f);
+        }
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1