矿场10.6+10.7

This commit is contained in:
杨号敬 2024-12-05 21:23:44 +08:00
parent 0f5a45c7fc
commit e0269ab275
5 changed files with 66 additions and 30 deletions

View File

@ -1389,7 +1389,7 @@ GameObject:
- component: {fileID: 737221601} - component: {fileID: 737221601}
- component: {fileID: 737221600} - component: {fileID: 737221600}
m_Layer: 5 m_Layer: 5
m_Name: Item1 (2) m_Name: NoItem
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
@ -1726,9 +1726,9 @@ RectTransform:
m_Father: {fileID: 229120761} m_Father: {fileID: 229120761}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 467.71002, y: -116} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 572, y: 218.0271} m_SizeDelta: {x: 572, y: 218.0271}
m_Pivot: {x: 0.5, y: 1} m_Pivot: {x: 0.5, y: 1}
--- !u!114 &860805139 --- !u!114 &860805139
@ -2780,7 +2780,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 0 m_IsActive: 1
--- !u!224 &1336997366 --- !u!224 &1336997366
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -3665,7 +3665,7 @@ GameObject:
- component: {fileID: 1778675693} - component: {fileID: 1778675693}
- component: {fileID: 1778675692} - component: {fileID: 1778675692}
m_Layer: 5 m_Layer: 5
m_Name: Item1 m_Name: scussfulItem
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
@ -4381,7 +4381,7 @@ GameObject:
- component: {fileID: 2112656857} - component: {fileID: 2112656857}
- component: {fileID: 2112656856} - component: {fileID: 2112656856}
m_Layer: 5 m_Layer: 5
m_Name: Item1 (1) m_Name: noConstractItem
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0

View File

@ -23,7 +23,7 @@ public class KuangChangTest : MonoBehaviour
async void Start() async void Start()
{ {
//queryMiningContractList.QueryMiningContract(); //queryMiningContractList.QueryMiningContract();
miningContracDetail = await queryMiningContracDetail.QueryMiningContracDetail(3); //miningContracDetail = await queryMiningContracDetail.QueryMiningContracDetail(3);
//bool isBuySucceed = await buyMiningContract.BuyMiningContract(1); //bool isBuySucceed = await buyMiningContract.BuyMiningContract(1);
////Debug.Log("====¹ºÂò===" + isBuySucceed); ////Debug.Log("====¹ºÂò===" + isBuySucceed);

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using TMPro; using TMPro;
using UnityEngine.UI; using UnityEngine.UI;
using static UnityEditor.Progress;
public class NewkuangchangItem : MonoBehaviour public class NewkuangchangItem : MonoBehaviour
{ {
@ -10,20 +11,51 @@ public class NewkuangchangItem : MonoBehaviour
public MiningContract miningContract; public MiningContract miningContract;
public TextMeshProUGUI count; public TextMeshProUGUI count;
public Button BuyButton; public Button BuyButton;
void Start() async void Start()
{ {
BuyButton.onClick.AddListener(BuyItem); BuyButton.onClick.AddListener(BuyItem);
} }
async void 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(); buyMiningContract103 buyMiningContract = new buyMiningContract103();
Debug.Log(miningContract.id); BuyMiningResponse buyMiningResponse = await buyMiningContract.BuyMiningContract(miningContract.id);
bool isBuySucceed = await buyMiningContract.BuyMiningContract(miningContract.id); Debug.Log("购买合约的id" + buyMiningResponse.data);
//bindSlot107 bindSlot = new bindSlot107(); //10.7
//bindSlot.BindSlot() bindSlot107 bindSlot = new bindSlot107();
bindSlot.BindSlot(buyMiningResponse.data, userMiningSlotResponse.data.dataList[NullContractID].id);
//queryUserMiningSlot.QueryUserMiningSlot();
} }
// Update is called once per frame // Update is called once
// per frame
void Update() void Update()
{ {

View File

@ -6,7 +6,7 @@ using UnityEngine;
//10.3,购买合约 //10.3,购买合约
public class buyMiningContract103 : MonoBehaviour public class buyMiningContract103 : MonoBehaviour
{ {
public async Task<bool> BuyMiningContract(long contractId) // 9.1 public async Task<BuyMiningResponse> BuyMiningContract(long contractId) // 9.1
{ {
// 准备请求的头部信息,包含授权令牌 // 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head = new Dictionary<string, string> Dictionary<string, string> head = new Dictionary<string, string>
@ -29,11 +29,10 @@ public class buyMiningContract103 : MonoBehaviour
// 将响应反序列化为对象 // 将响应反序列化为对象
BuyMiningResponse buyMiningResponse = JsonConvert.DeserializeObject<BuyMiningResponse>(response0103); BuyMiningResponse buyMiningResponse = JsonConvert.DeserializeObject<BuyMiningResponse>(response0103);
bool isSucceed; Debug.Log("10.3购买合约的ID" + buyMiningResponse.data);
if (buyMiningResponse.code == 200) { isSucceed = true; } else { isSucceed = false; }
// 返回解析后的对象 // 返回解析后的对象
return isSucceed; return buyMiningResponse;
} }
} }
//==========请求体=========================== //==========请求体===========================
@ -47,5 +46,10 @@ public class BuyMiningContractBody
//==========返回值=========================== //==========返回值===========================
public class BuyMiningResponse : Response public class BuyMiningResponse : Response
{ {
public string data; public long data;
} }
public class BuyResponse
{
public long id;
}

View File

@ -27,17 +27,17 @@ public class queryMyPureContract106 : MonoBehaviour
// 检查返回的数据 // 检查返回的数据
if (contractResponse != null && contractResponse.data != null) if (contractResponse != null && contractResponse.data != null)
{ {
//foreach (var contract in contractResponse.data) foreach (var contract in contractResponse.data)
//{ {
// // 访问合约字段 // 访问合约字段
// Debug.Log($"合约 ID: {contract.id}"); //Debug.Log($"合约 ID: {contract.id}");
// Debug.Log($"合约名称: {contract.contractName}"); //Debug.Log($"合约名称: {contract.contractName}");
// Debug.Log($"每秒奖励: {contract.eachSecondsReward}"); //Debug.Log($"每秒奖励: {contract.eachSecondsReward}");
// Debug.Log($"合约创建时间: {contract.createTime}"); //Debug.Log($"合约创建时间: {contract.createTime}");
// Debug.Log($"合约更新时间: {contract.updateTime}"); //Debug.Log($"合约更新时间: {contract.updateTime}");
// // 这里可以根据需要进行其他处理 // 这里可以根据需要进行其他处理
//} }
} }
else else
{ {