79 lines
2.7 KiB
C#
79 lines
2.7 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using game;
|
|
using GameCore;
|
|
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UniRx;
|
|
|
|
public class PlayerGradeBenefitPopupPanel : MonoBehaviour
|
|
{
|
|
RewardItemNew[] rewardItemNews;
|
|
Button btn_close;
|
|
Button btn_go;
|
|
IDisposable disposable;
|
|
private void Awake()
|
|
{
|
|
rewardItemNews = transform.Find("root/info").GetComponentsInChildren<RewardItemNew>();
|
|
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
|
btn_go = transform.Find("root/btn_go/btn_green").GetComponent<Button>();
|
|
}
|
|
private void Start()
|
|
{
|
|
btn_close.onClick.AddListener(() =>
|
|
{
|
|
UIManager.Instance.DestroyUI(UITypes.PlayerGradeBenefitPopupPanel);
|
|
});
|
|
btn_go.onClick.AddListener(OnGoBuild);
|
|
var table = GContext.container.Resolve<Tables>();
|
|
var playerData = GContext.container.Resolve<PlayerData>();
|
|
int id;
|
|
Item item;
|
|
for (int i = 0; i < rewardItemNews.Length; i++)
|
|
{
|
|
if (i >= playerData.benefitsLevel.Count)
|
|
{
|
|
break;
|
|
}
|
|
id = 12001 + i;
|
|
item = table.TbItem.GetOrDefault(id);
|
|
rewardItemNews[i].SetData(item, playerData.benefitsLevel[i], true);
|
|
}
|
|
disposable = GContext.OnEvent<CurBenefitPanelEvent>().Subscribe(_ => _.panelName = name);
|
|
}
|
|
async void OnGoBuild()
|
|
{
|
|
// TODO: restore when CampDataMM is available
|
|
var campData = GContext.container.Resolve<CampDataMM>();
|
|
|
|
ILoadResourceService loadResourceService = GContext.container.Resolve<ILoadResourceService>();
|
|
bool isCanEnter = await loadResourceService.Loads(campData.AllPrefabs);
|
|
if (isCanEnter)
|
|
{
|
|
EnterBuild();
|
|
}
|
|
else
|
|
{
|
|
var panel = await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
|
|
panel.GetComponent<CloudTransitionPanel>().SetBtn(true, EnterBuild);
|
|
//var panel = await UIManager.Instance.ShowUI(UITypes.FishingDownLoadPopupPanel);
|
|
//panel.GetComponent<FishingDownLoadPopupPanel>().SetBtn(null, EnterBuild);
|
|
}
|
|
await System.Threading.Tasks.Task.CompletedTask;
|
|
}
|
|
void EnterBuild()
|
|
{
|
|
GContext.Publish(new HideHomePanelEvent());
|
|
GContext.Publish(new VibrationData(HapticTypes.LightImpact));
|
|
UIManager.Instance.DestroyUI(UITypes.PlayerGradeBenefitPopupPanel);
|
|
UIManager.Instance.DestroyUI(UITypes.PlayerGradePanel);
|
|
GContext.Publish(new UnloadActToNextAct("BuildAct"));
|
|
}
|
|
private void OnDisable()
|
|
{
|
|
disposable?.Dispose();
|
|
disposable = null;
|
|
}
|
|
}
|