River Jiang
2020-10-27 24f59b89e9eabcfe948fc0ba304a8dbec2deda14
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();
        }
    }
}