50 lines
1.7 KiB
C#
50 lines
1.7 KiB
C#
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<bool> _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<RectTransform>()));
|
|
btnClaim.gameObject.SetActive(false);
|
|
await Task.Delay(System.TimeSpan.FromSeconds(
|
|
GContext.container.Resolve<EventLuckMagicModel>().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<bool> TaskCompletionSource;
|
|
}
|