93 lines
2.9 KiB
C#
93 lines
2.9 KiB
C#
using asap.core;
|
|
using GameCore;
|
|
using System;
|
|
using System.Linq;
|
|
using game;
|
|
using UniRx;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace EventBossFight
|
|
{
|
|
public class EventBossFightRewardPanel : BasePanel
|
|
{
|
|
private Button btn_play;
|
|
private RewardItemNew[] rewards;
|
|
|
|
private EventBossFightManager _manager;
|
|
private EventBossFightManager Manager => _manager ??= GContext.container.Resolve<EventBossFightManager>();
|
|
private EventBossFightData Data => Manager.Data;
|
|
private bool _isHasBox = false;
|
|
private void Awake()
|
|
{
|
|
btn_play = gameObject.FindChildGameObject(nameof(btn_play)).GetComponentInChildren<Button>();
|
|
btn_play.onClick.AddListener(OnClick_btn_play);
|
|
rewards = this.gameObject.GetComponentsInChildren<RewardItemNew>(true);
|
|
foreach (var item in rewards)
|
|
{
|
|
item?.gameObject.SetActive(false);
|
|
}
|
|
GContext.OnEvent<RewardPanelClose>().Subscribe(OnRewardPanelClose).AddTo(this);
|
|
}
|
|
|
|
protected override void Start()
|
|
{
|
|
ShowUI();
|
|
}
|
|
|
|
private void ShowUI()
|
|
{
|
|
var lastStageConfig = Manager.GetPreviousStage();
|
|
var itemDatas = GContext.container.Resolve<PlayerItemData>()
|
|
.GetItemDataByDropIdLureInflation(Data.InflationRate, lastStageConfig.DropId);
|
|
if (itemDatas == null) return;
|
|
|
|
for (int i = 0; i < itemDatas.Count && i < rewards.Length; i++)
|
|
{
|
|
if (itemDatas[i] == null) continue;
|
|
rewards[i].SetData(itemDatas[i]);
|
|
rewards[i].gameObject.SetActive(true);
|
|
}
|
|
}
|
|
|
|
protected override void OnDestroy()
|
|
{
|
|
btn_play.onClick.RemoveAllListeners();
|
|
base.OnDestroy();
|
|
}
|
|
|
|
private async void OnClick_btn_play()
|
|
{
|
|
try
|
|
{
|
|
btn_play.gameObject.SetActive(false);
|
|
for (int i = 1; i < rewards.Length; i++)
|
|
{
|
|
_ = rewards[i].ParticleAttractor();
|
|
}
|
|
await rewards[0].ParticleAttractor();
|
|
var curRewardQCount = new CurRewardQCount();
|
|
GContext.Publish(curRewardQCount);
|
|
if (curRewardQCount.count > 0)
|
|
{
|
|
GContext.Publish(new ShowData());
|
|
}
|
|
else
|
|
{
|
|
Manager.ShowReviewPanel();
|
|
UIManager.Instance.DestroyUI(UITypes.EventBossFightRewardPopupPanel);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Debug.LogError(e);
|
|
}
|
|
}
|
|
|
|
private void OnRewardPanelClose(RewardPanelClose e)
|
|
{
|
|
Manager.ShowReviewPanel();
|
|
UIManager.Instance.DestroyUI(UITypes.EventBossFightRewardPopupPanel);
|
|
}
|
|
}
|
|
} |