using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Core.Utilities;
using TowerDefense.Level;
using System;
using Protobuf;
/**
* 无尽模式道具掉落管理器
* @Author: chenxin
* @Date: 2020-10-20 15:00:12
*/
namespace KTGMGemClient
{
public class EndlessDrop
{
///
/// 唯一id,用于区分每一个掉落,获得掉落时EndlessDropManager会为id分配值
///
public int Id;
///
/// 配置数据
///
public reward Reward;
///
/// 自动拾取时间
///
public float AutoPickupTime;
///
/// 未拾取经历时间 > 自动拾取时间,自动获得
///
public float ElapsedTime;
///
/// 是否拾取完成,自动拾取/玩家手动点击拾取完成,拾取完成意味着真正的获得了掉落,清理场景时也要获得所有还未拾取的掉落
///
public bool IsPickupCompleted;
}
public class EndlessDropReward : MonoBehaviour
{
///
/// 发光粒子特效
///
public ParticleSystem LightParticle;
///
/// item图标
///
public Image Icon;
///
/// 自动拾取时间
///
public float AutoPickupTime { get; set; } = 5f;
public EndlessDrop DropData;
private string path = "UI/Props/";
public event Action ClickDropEvent;
// Start is called before the first frame update
private void Start()
{
ClickDropEvent += EndlessDropManager.instance.OnClickDrop;
}
public void OnClick()
{
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(resId);
Icon.SetNativeSize();
}
///
/// 播放发光的粒子特效
///
public void PlayParticle()
{
LightParticle.Play();
}
}
}