备份CatanBuilding瘦身独立工程
This commit is contained in:
68
Assets/Scripts/EventBingo/EventBingoRewardPanel.cs
Normal file
68
Assets/Scripts/EventBingo/EventBingoRewardPanel.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using GameCore;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections.Generic;
|
||||
using asap.core;
|
||||
using UnityEngine.Assertions;
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
|
||||
public class EventBingoRewardPanel : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Button btnClose;
|
||||
[SerializeField] private GameObject[] goBingoBanners;
|
||||
[SerializeField] private RewardItemNew[] rewardDisplayList;
|
||||
private IEventAggregator _eventAggregator1;
|
||||
private ItemData[] _rewards;
|
||||
private TaskCompletionSource<bool> _tcs;
|
||||
private const float RewardFlyDuration = 1.2f;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
btnClose.onClick.AddListener(OnClickClose);
|
||||
}
|
||||
|
||||
public void Init(EventBingoRewardPanelData data, IEventAggregator eventAggregator, TaskCompletionSource<bool> tcs)
|
||||
{
|
||||
for (int i = 0; i < goBingoBanners.Length; i++)
|
||||
goBingoBanners[i].SetActive(i == data.BingoCount - 1);
|
||||
_eventAggregator1 = eventAggregator;
|
||||
Assert.IsTrue(rewardDisplayList.Length == data.Rewards.Count, $"Inconsistent reward count: {rewardDisplayList.Length} in UI vs {data.Rewards.Count} in data.");
|
||||
for (int i = 0; i < data.Rewards.Count; i++)
|
||||
rewardDisplayList[i].SetData(data.Rewards[i]);
|
||||
_rewards = data.Rewards.ToArray();
|
||||
_tcs = tcs;
|
||||
}
|
||||
|
||||
private async void OnClickClose()
|
||||
{
|
||||
try
|
||||
{
|
||||
btnClose.gameObject.SetActive(false);
|
||||
GContext.Publish(new EventRewardFlyStashRequest(
|
||||
reward: _rewards[0],
|
||||
sourceIconRt: rewardDisplayList[0].icon.GetComponent<RectTransform>(),
|
||||
doesPlayOpen: true));
|
||||
GContext.Publish(new EventRewardFlyStashRequest(
|
||||
reward: _rewards[1],
|
||||
sourceIconRt: rewardDisplayList[1].icon.GetComponent<RectTransform>(),
|
||||
doesPlayOpen: true));
|
||||
// _ = rewardDisplayList[0].ParticleAttractor();
|
||||
// _ = rewardDisplayList[1].ParticleAttractor();
|
||||
await Task.Delay(TimeSpan.FromSeconds(RewardFlyDuration - 0.2f));
|
||||
_tcs.SetResult(true);
|
||||
UIManager.Instance.DestroyUI(UITypes.EventBingoRewardPanel);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError("[EventBingo] bingo reward panel error.");
|
||||
Debug.LogError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EventBingoRewardPanelData
|
||||
{
|
||||
public int BingoCount;
|
||||
public List<ItemData> Rewards;
|
||||
}
|
||||
Reference in New Issue
Block a user