106 lines
3.3 KiB
C#
106 lines
3.3 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using game;
|
|
using GameCore;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class GiftPopupPanel : MonoBehaviour
|
|
{
|
|
protected GiftRewardAttached giftRewardAttached3;
|
|
protected GiftRewardAttached giftRewardAttached4;
|
|
protected Tables _tables;
|
|
//Button btn_mask;
|
|
protected Button btn_close;
|
|
protected Button btn_buy;
|
|
protected TMP_Text text_buy;
|
|
|
|
protected TMP_Text text_time;
|
|
protected GameObject tag_more;
|
|
protected TMP_Text text_best;
|
|
protected TMP_Text Remaining;
|
|
|
|
protected Pack pack;
|
|
protected IAPItemList iAPItemList;
|
|
protected List<ItemData> itemDatas = new List<ItemData>();
|
|
|
|
private void Reset()
|
|
{
|
|
Awake();
|
|
}
|
|
protected virtual void Awake()
|
|
{
|
|
btn_close = transform.Find("root/btn_close").GetComponent<Button>();
|
|
btn_buy = transform.Find("root/btn_buy/btn_green").GetComponent<Button>();
|
|
text_buy = transform.Find("root/btn_buy/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
|
text_time = transform.Find("root/text_time").GetComponent<TMP_Text>();
|
|
giftRewardAttached3 = transform.Find("root/reward_3").GetComponent<GiftRewardAttached>();
|
|
giftRewardAttached4 = transform.Find("root/reward_4").GetComponent<GiftRewardAttached>();
|
|
tag_more = transform.Find("root/tag_more").gameObject;
|
|
text_best = transform.Find("root/tag_more/text_best").GetComponent<TMP_Text>();
|
|
Remaining = transform.Find("root/text_remaining").GetComponent<TMP_Text>();
|
|
_tables = GContext.container.Resolve<Tables>();
|
|
}
|
|
|
|
protected virtual void Start()
|
|
{
|
|
btn_buy.onClick.AddListener(OnBuy);
|
|
}
|
|
|
|
async void OnBuy()
|
|
{
|
|
btn_buy.enabled = false;
|
|
if (iAPItemList == null)
|
|
{
|
|
GContext.Publish(new ShowData(itemDatas));
|
|
GContext.container.Resolve<PlayerItemData>().AddItem(itemDatas, null);
|
|
GContext.Publish(new ShowData());
|
|
OnSuccess();
|
|
}
|
|
else
|
|
{
|
|
ShopBuyTypeData shopBuyTypeData = GetShopBuyTypeData();
|
|
bool Result = await GContext.container.Resolve<PlayerShopData>().OnBuy(pack.DropID, shopBuyTypeData, iAPItemList, itemDatas);
|
|
if (Result)
|
|
{
|
|
OnBuySuccess();
|
|
}
|
|
}
|
|
btn_buy.enabled = true;
|
|
}
|
|
protected virtual ShopBuyTypeData GetShopBuyTypeData()
|
|
{
|
|
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
|
|
shopBuyTypeData.type = ShopBuyType.ShopPackDailyBuy;
|
|
return shopBuyTypeData;
|
|
}
|
|
protected virtual void OnSuccess()
|
|
{
|
|
|
|
}
|
|
protected virtual void OnBuySuccess()
|
|
{
|
|
|
|
}
|
|
|
|
protected virtual void SetShowData()
|
|
{
|
|
if (itemDatas != null && itemDatas.Count > 0)
|
|
{
|
|
giftRewardAttached3.gameObject.SetActive(itemDatas.Count <= 3);
|
|
giftRewardAttached4.gameObject.SetActive(itemDatas.Count > 3);
|
|
if (itemDatas.Count <= 3)
|
|
{
|
|
giftRewardAttached3.SetData(itemDatas);
|
|
}
|
|
else
|
|
{
|
|
giftRewardAttached4.SetData(itemDatas);
|
|
}
|
|
}
|
|
Remaining.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_1", 1, 1);
|
|
}
|
|
}
|