备份CatanBuilding瘦身独立工程
This commit is contained in:
92
Assets/Scripts/Duel/UI/PvpStoreItem.cs
Normal file
92
Assets/Scripts/Duel/UI/PvpStoreItem.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PvpStoreItem : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
protected Button btn_buy;
|
||||
|
||||
[SerializeField]
|
||||
protected RewardItemNew rewardItem;
|
||||
|
||||
[SerializeField]
|
||||
protected GameObject go_soldOut;
|
||||
|
||||
[SerializeField]
|
||||
protected TMP_Text btn_buy_text;
|
||||
protected PvpStore pvpStore;
|
||||
protected ItemData itemData;
|
||||
private void Reset()
|
||||
{
|
||||
btn_buy = transform.Find("position/btn_purchase/btn_green").GetComponent<Button>();
|
||||
rewardItem = transform.Find("position/reward").GetComponent<RewardItemNew>();
|
||||
go_soldOut = transform.Find("position/soldout").gameObject;
|
||||
btn_buy_text = transform.Find("position/btn_purchase/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_buy.onClick.AddListener(OnBuy);
|
||||
}
|
||||
public void Init(PvpStore pvpStore, bool soldOut)
|
||||
{
|
||||
this.pvpStore = pvpStore;
|
||||
itemData = new ItemData(pvpStore.ItemId, pvpStore.ItemNumber);
|
||||
if (itemData.id == 1002)
|
||||
{
|
||||
itemData.count = GContext.container.Resolve<PlayerItemData>().GetExtraCoinMag(itemData.count);
|
||||
}
|
||||
rewardItem.SetData(itemData);
|
||||
btn_buy_text.text = pvpStore.TokenNumber.ToString();
|
||||
go_soldOut.SetActive(soldOut);
|
||||
btn_buy.gameObject.SetActive(!soldOut);
|
||||
Init();
|
||||
}
|
||||
protected virtual void Init()
|
||||
{
|
||||
|
||||
}
|
||||
void OnBuy()
|
||||
{
|
||||
FishingEventData fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
if (pvpStore.TokenNumber > fishingEventData.PVPToken)
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_87"));
|
||||
//代币不足
|
||||
return;
|
||||
}
|
||||
if (fishingEventData.BuyPVPItem(pvpStore.Id))
|
||||
{
|
||||
fishingEventData.AddPVPToken(-pvpStore.TokenNumber);
|
||||
GContext.Publish(new ResAddEvent(pvpStore.TokenId));
|
||||
itemData.curCount = (ulong)GContext.container.Resolve<PlayerItemData>().GetItemCount(itemData.id);
|
||||
GContext.Publish(new ShowData(itemData));
|
||||
GContext.container.Resolve<PlayerItemData>().AddItem(itemData);
|
||||
GContext.Publish(new ShowData());
|
||||
BuyEnd();
|
||||
var duelData = fishingEventData.duelData;
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("pvp_store"))
|
||||
{
|
||||
e.AddContent("cost_token_id", 2052)
|
||||
.AddContent("cost_token_count", pvpStore.TokenNumber)
|
||||
.AddContent("change_type", pvpStore.Type)
|
||||
.AddContent("item_id", itemData.id)
|
||||
.AddContent("cost_token_count_sum", duelData == null ? 0 : duelData.rePVPToken)
|
||||
.AddContent("available_token", fishingEventData.PVPToken)
|
||||
.AddContent("change_count", itemData.count);
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
protected virtual void BuyEnd()
|
||||
{
|
||||
go_soldOut.SetActive(true);
|
||||
btn_buy.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user