60 lines
2.0 KiB
C#
60 lines
2.0 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using GameCore;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class AdvertShopSlot : MonoBehaviour
|
|
{
|
|
Button btn_buy;
|
|
Image bg;
|
|
TMP_Text text_num;
|
|
TMP_Text text_price;
|
|
Button btn_showItem;
|
|
ShopToken shopToken;
|
|
IAPItemList iAPItemList;
|
|
private void Awake()
|
|
{
|
|
btn_buy = transform.Find("position/btn_purchase/btn_green").GetComponent<Button>();
|
|
btn_showItem = transform.Find("position/reward").GetComponent<Button>();
|
|
bg = transform.Find("position/bg").GetComponent<Image>();
|
|
text_num = transform.Find("position/text_num").GetComponent<TMP_Text>();
|
|
text_price = transform.Find("position/btn_purchase/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
|
|
|
btn_buy.onClick.AddListener(OnBuy);
|
|
btn_showItem.onClick.AddListener(OnShowItemInfo);
|
|
}
|
|
public void SetData(cfg.ShopToken shopToken)
|
|
{
|
|
this.shopToken = shopToken;
|
|
text_num.text = shopToken.Number.ToString();
|
|
iAPItemList = GContext.container.Resolve<Tables>().TbIAPItemList.GetOrDefault(shopToken.IAPID);
|
|
SKUDetailDataEvent sKUDetailDataEvent = new SKUDetailDataEvent(iAPItemList);
|
|
GContext.Publish(sKUDetailDataEvent);
|
|
text_price.text = sKUDetailDataEvent.price;
|
|
}
|
|
|
|
async void OnBuy()
|
|
{
|
|
List<ItemData> itemData = new List<ItemData>
|
|
{
|
|
new ItemData { count = shopToken.Number, id = shopToken.TokenID }
|
|
};
|
|
btn_buy.enabled = false;
|
|
|
|
ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData();
|
|
shopBuyTypeData.type = ShopBuyType.ShopToken;
|
|
shopBuyTypeData.ID = shopToken.ID;
|
|
bool Result = await GContext.container.Resolve<PlayerShopData>().OnBuy(shopToken.TokenID,shopBuyTypeData, iAPItemList, itemData);
|
|
btn_buy.enabled = true;
|
|
}
|
|
|
|
|
|
void OnShowItemInfo()
|
|
{
|
|
GContext.container.Resolve<PlayerItemData>().ShowItemTips(1006, btn_showItem.transform);
|
|
}
|
|
}
|