75 lines
2.4 KiB
C#
75 lines
2.4 KiB
C#
using asap.core;
|
|
using GameCore;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UniRx;
|
|
using game;
|
|
|
|
public class ShowTurntableData
|
|
{
|
|
public ItemData itemData;
|
|
public ShowTurntableData(ItemData itemData)
|
|
{
|
|
this.itemData = itemData;
|
|
}
|
|
}
|
|
public class TurntableRewardPopupPanel : MonoBehaviour
|
|
{
|
|
Button btnClose;
|
|
RewardItemNew itemNew;
|
|
[SerializeField] private int popDurationInMilliseconds;//窗口停留时间,毫秒。如果为非正整数则无限期停留,需要手动点击关闭。
|
|
//Image icon;
|
|
//TMP_Text txtName;
|
|
System.IDisposable disposable;
|
|
|
|
private void Awake()
|
|
{
|
|
btnClose = transform.Find("mask").GetComponent<Button>();
|
|
itemNew = transform.Find("root/reward").GetComponent<RewardItemNew>();
|
|
//icon = transform.Find("root/reward/icon").GetComponent<Image>();
|
|
//txtName = transform.Find("root/reward/text_num").GetComponent<TMP_Text>();
|
|
disposable = GContext.OnEvent<ShowTurntableData>().Subscribe(OnShowTurntableData);
|
|
}
|
|
private async void Start()
|
|
{
|
|
//btnClose.onClick.AddListener(OnBtnCloseClick);
|
|
if (popDurationInMilliseconds > 0)
|
|
{
|
|
await System.Threading.Tasks.Task.Delay(popDurationInMilliseconds);
|
|
UIManager.Instance.DestroyUI(UITypes.TurntableRewardPopupPanel);
|
|
}
|
|
}
|
|
//void OnBtnCloseClick()
|
|
//{
|
|
// UIManager.Instance.DestroyUI(UITypes.TurntableRewardPopupPanel);
|
|
//}
|
|
void OnShowTurntableData(ShowTurntableData data)
|
|
{
|
|
try
|
|
{
|
|
// Debug.Log($"[turntable] Current thread ID @ OnShowTurntableData: {System.Threading.Thread.CurrentThread.ManagedThreadId}");
|
|
if (btnClose != null)
|
|
btnClose.enabled = false;
|
|
itemNew.SetData(data.itemData, isCanClick: true);
|
|
}
|
|
catch (System.Exception e)
|
|
{
|
|
Debug.LogError(e);
|
|
}
|
|
//await Awaiters.Seconds(1.34f);
|
|
//await itemNew.PlayClose();
|
|
//await itemNew.ParticleAttractor();
|
|
//OnBtnCloseClick();
|
|
//btnClose.enabled = true;
|
|
//GContext.container.Resolve<IUIService>().SetImageSprite(icon, item.Icon, BasePanel.PanelName);
|
|
//txtName.text = ConvertTools.GetNumberString((int)data.itemData.count);
|
|
|
|
}
|
|
private void OnDestroy()
|
|
{
|
|
GContext.Publish(new ShowData());
|
|
disposable.Dispose();
|
|
disposable = null;
|
|
}
|
|
}
|