From 0e8a4a629f0db7d9dc7b8c3b9795a195c279f7b9 Mon Sep 17 00:00:00 2001 From: wangguan <wangguan@kt007.com> Date: Mon, 26 Oct 2020 14:25:48 +0800 Subject: [PATCH] Merge branch 'master' of ssh://172.16.1.52:8091/GemBattle --- Assets/Scripts/TowerDefense/UI/EndlessDropReward.cs | 40 +++++++++++++++++++++++++++++----------- 1 files changed, 29 insertions(+), 11 deletions(-) diff --git a/Assets/Scripts/TowerDefense/UI/EndlessDropReward.cs b/Assets/Scripts/TowerDefense/UI/EndlessDropReward.cs index 91a3148..a6a93e4 100644 --- a/Assets/Scripts/TowerDefense/UI/EndlessDropReward.cs +++ b/Assets/Scripts/TowerDefense/UI/EndlessDropReward.cs @@ -1,9 +1,11 @@ +using UnityEngine.UI; using System.Collections; using System.Collections.Generic; using UnityEngine; using Core.Utilities; using TowerDefense.Level; using System; +using Protobuf; /** * 无尽模式道具掉落管理器 @@ -43,27 +45,23 @@ 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; @@ -78,5 +76,25 @@ if (ClickDropEvent != null) ClickDropEvent(DropData); } + + public void SetIcon() + { + string resId = ""; + + if (DropData.Reward.id == 0) + resId = $"{path}{(int)DropData.Reward.type}"; + else + resId = $"{path}{(int)DropData.Reward.type}_${DropData.Reward.id}"; + Icon.sprite = Resources.Load<Sprite>(resId); + Icon.SetNativeSize(); + } + + /// <summary> + /// 播放发光的粒子特效 + /// </summary> + public void PlayParticle() + { + LightParticle.Play(); + } } } \ No newline at end of file -- Gitblit v1.9.1