_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/kuangChang10/NewkuangchangItem.cs
2024-12-05 21:23:44 +08:00

64 lines
2.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.UI;
using static UnityEditor.Progress;
public class NewkuangchangItem : MonoBehaviour
{
// Start is called before the first frame update
public MiningContract miningContract;
public TextMeshProUGUI count;
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("卡槽不为空");
openSlot105 openSlot5 = new openSlot105();
openSlot5.OpenSlot();
//Debug.Log("卡槽ID" + userMiningSlotResponse.data.dataList[NullContractID+1].id);
return;
}
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);
//queryUserMiningSlot.QueryUserMiningSlot();
}
// Update is called once
// per frame
void Update()
{
}
}