From 452c75675679c44cc39b04bdb7d330d7c5c14d5c Mon Sep 17 00:00:00 2001 From: wangguan <wangguan@kt007.com> Date: Tue, 29 Dec 2020 10:48:06 +0800 Subject: [PATCH] 增加多SDK支持。常规使用SDKChannel.KTGM 偶哈游的是空SDK --- Assets/Scripts/TowerDefense/UI/EndlessDropReward.cs | 77 ++++++++++++++++++++++++++++++++------ 1 files changed, 64 insertions(+), 13 deletions(-) diff --git a/Assets/Scripts/TowerDefense/UI/EndlessDropReward.cs b/Assets/Scripts/TowerDefense/UI/EndlessDropReward.cs index 91a3148..e4aca09 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 (ClickDropEvent != null) - ClickDropEvent(DropData); + // 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