using System.Collections; using System.Collections.Generic; using Api; using Plugins.CxShine.page; using UI; using UI.Common; using Unity.VisualScripting; using UnityEngine; public class MarketPageComp : MonoBehaviour { public Transform ScrollRect; public GameObject CockItemPreafab; void Start() { ApiComp.Instance.cockMarket(data => { foreach (var marketCock in data.market) { var itemComp=Instantiate(CockItemPreafab, ScrollRect, false).GetComponent(); itemComp.ModeBuy(marketCock); itemComp.ClickBuyAction += BuyCock; } }, null); GetComponent().setOnPageCloseListener((() => { HallComp.Instance.BackToHallAndRefreshUI(); ; })); } private void BuyCock(MarketCock marketCock) { if (marketCock.diamond > AccountManager.Instance.GetDiamond()) { TipsComp.ShowTips("Not enough diamonds"); return; } ApiComp.Instance.BuyCock(marketCock.marketId, data => { TipsComp.ShowTips("Success!"); }, (code, err) => { TipsComp.ShowTips(err); }); } }