using System.Threading.Tasks; using asap.core; using GameCore; using UnityEngine; using UnityEngine.UI; public class EventLuckMagicTaskRewardPopupPanel : MonoBehaviour { [SerializeField] private Button btnClaim; [SerializeField] private RewardItemNew reward; [SerializeField] private GameObject goUpperTask, goLowerTask; private ItemData _rawRewardData; private TaskCompletionSource _taskCompletionSource; public void Init(EventLuckMagicRewardPanelInfo info) { btnClaim.onClick.AddListener(OnClickClaim); bool isUpperTaskType = EventLuckMagicAct.TableContext.JudgeItemId(info.TaskItemId) == EEventLuckMagicItemType.UpperTaskItem; goUpperTask.SetActive(isUpperTaskType); goLowerTask.SetActive(!isUpperTaskType); reward.SetData(info.Reward); _rawRewardData = info.Reward; _taskCompletionSource = info.TaskCompletionSource; } private async void OnClickClaim() { try { GContext.Publish(new EventRewardFlyStashRequest(_rawRewardData, reward.icon.GetComponent())); btnClaim.gameObject.SetActive(false); await Task.Delay(System.TimeSpan.FromSeconds( GContext.container.Resolve().ParamsCtrl.RewardPopupPanelCloseDelay)); _taskCompletionSource.SetResult(true); UIManager.Instance.DestroyUI(UITypes.EventLuckMagicTaskRewardPopupPanel); } catch (System.Exception e) { Debug.Log(e); } } } public class EventLuckMagicRewardPanelInfo { public ItemData Reward; public int TaskItemId; public TaskCompletionSource TaskCompletionSource; }