备份CatanBuilding瘦身独立工程
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using GameCore;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using asap.core;
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
|
||||
public class EventGatherCoreRewardPopupPanel : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Button btnClose;
|
||||
[SerializeField] private RewardItemNew[] rewardDisplayList;
|
||||
private IEventAggregator _eventAggregator;
|
||||
private ItemData _reward;
|
||||
private TaskCompletionSource<bool> _tcs;
|
||||
private const float RewardFlyDuration = 1.4f;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
btnClose.onClick.AddListener(OnClickClose);
|
||||
}
|
||||
|
||||
public void Init(ItemData rewards, IEventAggregator eventAggregator, TaskCompletionSource<bool> tcs )
|
||||
{
|
||||
_eventAggregator = eventAggregator;
|
||||
int i;
|
||||
rewardDisplayList[0].SetData(rewards);
|
||||
rewardDisplayList[0].gameObject.SetActive(true);
|
||||
for (i = 1; i < rewardDisplayList.Length; i++)
|
||||
{
|
||||
rewardDisplayList[i].gameObject.SetActive(false);
|
||||
i++;
|
||||
}
|
||||
_reward = rewards;
|
||||
_tcs = tcs;
|
||||
}
|
||||
|
||||
private async void OnClickClose()
|
||||
{
|
||||
try
|
||||
{
|
||||
btnClose.gameObject.SetActive(false);
|
||||
_ = rewardDisplayList[0].ParticleAttractor();
|
||||
await Task.Delay(TimeSpan.FromSeconds(RewardFlyDuration));
|
||||
_eventAggregator.Publish(new EventGatherCoreRewardPopupPanelClose() { Reward = _reward });
|
||||
_tcs.SetResult(true);
|
||||
UIManager.Instance.DestroyUI(UITypes.EventGatherCoreRewardPopupPanel);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError("[EventGatherCore] reward panel error.");
|
||||
Debug.LogError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user