using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; using UnityEngine.UI; using static UnityEditor.Progress; public class NewkuangchangItem : Base { // Start is called before the first frame update public MiningContract miningContract; [Header("购买合约价格")] public TextMeshProUGUI count; [Header("购买合约按钮")] public Button BuyButton; async void Start() { BuyButton.onClick.AddListener(BuyItem); } async void BuyItem() { queryUserMiningSlot104 queryUserMiningSlot = new queryUserMiningSlot104(); UserMiningSlotResponse userMiningSlotResponse = await queryUserMiningSlot.QueryUserMiningSlot(); bool IsNull = true; int NullContractID = 0; for (; NullContractID < userMiningSlotResponse.data.dataList.Count; NullContractID++) { var contract = userMiningSlotResponse.data.dataList[NullContractID]; if (contract.contractId < 3 || contract.contractId > 6) { IsNull = false; break; } } if (IsNull) { Debug.Log("卡槽不为空"); Debug.Log("开启卡槽"); //开启卡槽 openSlot105 openSlot5 = new openSlot105(); openSlot5.OpenSlot(); string strIS= await openSlot5.OpenSlotstr(); addEventPopUp(strIS); KuangChang.Instance.onSetActive(false); } Debug.Log("卡槽ID"+ userMiningSlotResponse.data.dataList[NullContractID].id); //10.3返回合约ID buyMiningContract103 buyMiningContract = new buyMiningContract103(); BuyMiningResponse buyMiningResponse = await buyMiningContract.BuyMiningContract(miningContract.id); Debug.Log("购买合约的id" + buyMiningResponse.data); //10.7 bindSlot107 bindSlot = new bindSlot107(); bindSlot.BindSlot(buyMiningResponse.data, userMiningSlotResponse.data.dataList[NullContractID].id); KuangChang.Instance.UpdateUserdata(); KuangChang.Instance.IninItem(); KuangChang.Instance.onSetActive(false); } }