备份CatanBuilding瘦身独立工程
This commit is contained in:
76
Assets/Scripts/UI/Grade/PlayerGradeBenefitPopupPanel.cs
Normal file
76
Assets/Scripts/UI/Grade/PlayerGradeBenefitPopupPanel.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
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()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user