备份CatanBuilding瘦身独立工程
This commit is contained in:
139
Assets/Scripts/UI/BattlePass/BattlePassActivePopupPanel.cs
Normal file
139
Assets/Scripts/UI/BattlePass/BattlePassActivePopupPanel.cs
Normal file
@@ -0,0 +1,139 @@
|
||||
using GameCore;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UniRx;
|
||||
using TMPro;
|
||||
using asap.core;
|
||||
using cfg;
|
||||
|
||||
public class BattlePassActivePopupPanel : BasePanel
|
||||
{
|
||||
#region Field
|
||||
[SerializeField]
|
||||
private Button
|
||||
btn_buyNormal,
|
||||
btn_buySpecial,
|
||||
btn_close;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_Text
|
||||
txt_title,
|
||||
txt_normalValue,
|
||||
txt_specialValue,
|
||||
txt_spcialUpLevel,
|
||||
txt_normalCost,
|
||||
txt_specialCost;
|
||||
|
||||
[SerializeField]
|
||||
RewardItemNew
|
||||
rewardItem;
|
||||
[SerializeField]
|
||||
Transform
|
||||
tran_vipBar,
|
||||
tran_nomralBar;
|
||||
|
||||
BattlePassDataProvider _dataProvider;
|
||||
#endregion
|
||||
|
||||
|
||||
#region Func
|
||||
private void Awake()
|
||||
{
|
||||
_dataProvider = GContext.container.Resolve<BattlePassDataProvider>();
|
||||
}
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
var dic_iAPItemList = GContext.container.Resolve<Tables>().TbIAPItemList.DataMap;
|
||||
var curPassMain = _dataProvider.curPassMain;
|
||||
|
||||
// txt_normalValue.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_2", curPassMain.PrimeValue);
|
||||
// txt_specialValue.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_2", curPassMain.DeluxeValue);
|
||||
// txt_spcialUpLevel.text = LocalizationMgr.GetFormatTextValue("UI_BattlePassPanel_18", _dataProvider.GetUpLevelByExp((int) GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(curPassMain.DeluxeReward).FirstOrDefault(x => x.id == 3003).count));
|
||||
SKUDetailDataEvent ssde = new SKUDetailDataEvent(dic_iAPItemList[_dataProvider.curPassMain.PrimeIAPID]);
|
||||
GContext.Publish(ssde);
|
||||
txt_normalCost.text = ssde.price;
|
||||
ssde = new SKUDetailDataEvent(dic_iAPItemList[_dataProvider.curPassMain.DeluxeIAPID]);
|
||||
GContext.Publish(ssde);
|
||||
txt_specialCost.text = ssde.price;
|
||||
txt_title.text = LocalizationMgr.GetText("UI_BattlePassPanel_6");
|
||||
|
||||
rewardItem.gameObject.SetActive(false);
|
||||
var dropID = _dataProvider.curPassMain.PrimeReward;
|
||||
var itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(dropID);
|
||||
for (int i = 1; i < itemDatas.Count; i++)
|
||||
{
|
||||
Instantiate(rewardItem, tran_nomralBar).SetData(itemDatas[i]);
|
||||
}
|
||||
dropID = _dataProvider.curPassMain.DeluxeReward;
|
||||
itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(dropID);
|
||||
for (int i = 1; i < itemDatas.Count; i++)
|
||||
{
|
||||
Instantiate(rewardItem, tran_vipBar).SetData(itemDatas[i]);
|
||||
}
|
||||
|
||||
btn_close.OnClickAsObservable().Subscribe(_ => Close()).AddTo(disposables);
|
||||
btn_buyNormal.OnClickAsObservable().Subscribe(_ => OnBuy(0)).AddTo(disposables);
|
||||
btn_buySpecial.OnClickAsObservable().Subscribe(_ => OnBuy(1)).AddTo(disposables);
|
||||
}
|
||||
|
||||
protected void Close()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.BattlePassActivePopupPanel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="scope">0:Normal 1:Special</param>
|
||||
async void OnBuy(int scope)
|
||||
{
|
||||
var iAPItemID = scope == 0 ? _dataProvider.curPassMain.PrimeIAPID : scope == 1 ? _dataProvider.curPassMain.DeluxeIAPID : -1;
|
||||
var iAPItemList = GContext.container.Resolve<Tables>().TbIAPItemList.GetOrDefault(iAPItemID);
|
||||
var dropID = scope == 0 ? _dataProvider.curPassMain.PrimeReward : scope == 1 ? _dataProvider.curPassMain.DeluxeReward : -1;
|
||||
var itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(dropID);
|
||||
var startLevel = _dataProvider.GetBPCurLevel;
|
||||
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
|
||||
shopBuyTypeData.type = ShopBuyType.None;
|
||||
bool Result = await GContext.container.Resolve<PlayerShopData>().OnBuy(dropID, shopBuyTypeData, iAPItemList, itemDatas);
|
||||
if (Result)
|
||||
{
|
||||
#if AGG
|
||||
using ( var e = GEvent.GameEvent("bp_active") )
|
||||
{
|
||||
e.AddContent("bp_level", startLevel)
|
||||
.AddContent("active_type", scope+1);
|
||||
}
|
||||
#endif
|
||||
OnBuySuccess(scope);
|
||||
}
|
||||
}
|
||||
|
||||
/*async*/ void OnBuySuccess(int scope)
|
||||
{
|
||||
|
||||
GContext.Publish(new BpVipUnlock());
|
||||
if (scope == 1)
|
||||
GContext.Publish(new BpGetExp());
|
||||
Close();
|
||||
//await WaitForRewardPanel();
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task WaitForRewardPanel()
|
||||
{
|
||||
var count = 0;
|
||||
var rewardInfo = new RewardPopupData();
|
||||
while (count++ < 5)
|
||||
{
|
||||
GContext.Publish(rewardInfo);
|
||||
if (rewardInfo.isShow)
|
||||
{
|
||||
await rewardInfo.tcs.Task;
|
||||
break;
|
||||
}
|
||||
await new WaitForSeconds(0.2f);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user