Files
ft/Client/Assets/Scripts/UI/Potion/EventPotionRewardPopupPanel.cs
2026-06-29 21:18:33 +08:00

61 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using asap.core;
using GameCore;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
namespace game
{
public class EventPotionRewardPopupPanel : MonoBehaviour
{
[SerializeField] private Button btnNormal;
[SerializeField] private GameObject rewardRoot;
[SerializeField] private ShootingRewardLayout normalRewardLayout;
IDisposable disposable;
public void Init(List<ItemData> rewardItems, bool isFinalStage = false)
{
btnNormal.onClick.AddListener(OnClickClaim);
rewardRoot.SetActive(true);
normalRewardLayout.SetRewards(rewardItems, true);
}
void RewardFly()
{
normalRewardLayout.RewardFly();
}
private async void OnClickClaim()
{
btnNormal.onClick.RemoveAllListeners();
RewardFly();
await Awaiters.Seconds(2.5f);
CurRewardQCount curRewardQCount = new CurRewardQCount();
GContext.Publish(curRewardQCount);
if (curRewardQCount.count <= 0)
{
Exit();
}
else
{
disposable = GContext.OnEvent<RewardPanelClose>().Subscribe(OnRewardPanelClose);
GContext.Publish(new ShowData());
}
}
void OnRewardPanelClose(RewardPanelClose rewardPanelClose)
{
Exit();
}
void Exit()
{
disposable?.Dispose();
disposable = null;
FishingPotionAct.Publish<EventPotionCloseCameraData>(new EventPotionCloseCameraData());
// 关闭当前Act
GContext.Publish(new UnloadActToNextAct());
UIManager.Instance.DestroyUI(gameObject.name);
}
}
}