From e0269ab275a0a580f4da6135ecbe6ea283cd1384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8F=B7=E6=95=AC?= <153802103@qq.com> Date: Thu, 5 Dec 2024 21:23:44 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9F=BF=E5=9C=BA10.6+10.7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TheStrongestSnail/Assets/Scenes/yhjtext.unity | 14 +++--- .../Scripts/kuangChang10/KuangChangTest.cs | 2 +- .../Scripts/kuangChang10/NewkuangchangItem.cs | 44 ++++++++++++++++--- .../kuangChang10/buyMiningContract103.cs | 16 ++++--- .../kuangChang10/queryMyPureContract106.cs | 20 ++++----- 5 files changed, 66 insertions(+), 30 deletions(-) diff --git a/TheStrongestSnail/Assets/Scenes/yhjtext.unity b/TheStrongestSnail/Assets/Scenes/yhjtext.unity index 60ede8a..9139842 100644 --- a/TheStrongestSnail/Assets/Scenes/yhjtext.unity +++ b/TheStrongestSnail/Assets/Scenes/yhjtext.unity @@ -1389,7 +1389,7 @@ GameObject: - component: {fileID: 737221601} - component: {fileID: 737221600} m_Layer: 5 - m_Name: Item1 (2) + m_Name: NoItem m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -1726,9 +1726,9 @@ RectTransform: m_Father: {fileID: 229120761} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 467.71002, y: -116} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 572, y: 218.0271} m_Pivot: {x: 0.5, y: 1} --- !u!114 &860805139 @@ -2780,7 +2780,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &1336997366 RectTransform: m_ObjectHideFlags: 0 @@ -3665,7 +3665,7 @@ GameObject: - component: {fileID: 1778675693} - component: {fileID: 1778675692} m_Layer: 5 - m_Name: Item1 + m_Name: scussfulItem m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -4381,7 +4381,7 @@ GameObject: - component: {fileID: 2112656857} - component: {fileID: 2112656856} m_Layer: 5 - m_Name: Item1 (1) + m_Name: noConstractItem m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 diff --git a/TheStrongestSnail/Assets/Scripts/kuangChang10/KuangChangTest.cs b/TheStrongestSnail/Assets/Scripts/kuangChang10/KuangChangTest.cs index 2b8fbfe..36c19e3 100644 --- a/TheStrongestSnail/Assets/Scripts/kuangChang10/KuangChangTest.cs +++ b/TheStrongestSnail/Assets/Scripts/kuangChang10/KuangChangTest.cs @@ -23,7 +23,7 @@ public class KuangChangTest : MonoBehaviour async void Start() { //queryMiningContractList.QueryMiningContract(); - miningContracDetail = await queryMiningContracDetail.QueryMiningContracDetail(3); + //miningContracDetail = await queryMiningContracDetail.QueryMiningContracDetail(3); //bool isBuySucceed = await buyMiningContract.BuyMiningContract(1); ////Debug.Log("====购买===" + isBuySucceed); diff --git a/TheStrongestSnail/Assets/Scripts/kuangChang10/NewkuangchangItem.cs b/TheStrongestSnail/Assets/Scripts/kuangChang10/NewkuangchangItem.cs index e866a7f..50c04f3 100644 --- a/TheStrongestSnail/Assets/Scripts/kuangChang10/NewkuangchangItem.cs +++ b/TheStrongestSnail/Assets/Scripts/kuangChang10/NewkuangchangItem.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using UnityEngine; using TMPro; using UnityEngine.UI; +using static UnityEditor.Progress; public class NewkuangchangItem : MonoBehaviour { @@ -10,20 +11,51 @@ public class NewkuangchangItem : MonoBehaviour public MiningContract miningContract; public TextMeshProUGUI count; public Button BuyButton; - void Start() + 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(); - Debug.Log(miningContract.id); - bool isBuySucceed = await buyMiningContract.BuyMiningContract(miningContract.id); - //bindSlot107 bindSlot = new bindSlot107(); - //bindSlot.BindSlot() + 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 + // Update is called once + // per frame void Update() { diff --git a/TheStrongestSnail/Assets/Scripts/kuangChang10/buyMiningContract103.cs b/TheStrongestSnail/Assets/Scripts/kuangChang10/buyMiningContract103.cs index dd99e8f..c783011 100644 --- a/TheStrongestSnail/Assets/Scripts/kuangChang10/buyMiningContract103.cs +++ b/TheStrongestSnail/Assets/Scripts/kuangChang10/buyMiningContract103.cs @@ -6,7 +6,7 @@ using UnityEngine; //10.3,购买合约 public class buyMiningContract103 : MonoBehaviour { - public async Task BuyMiningContract(long contractId) // 9.1 + public async Task BuyMiningContract(long contractId) // 9.1 { // 准备请求的头部信息,包含授权令牌 Dictionary head = new Dictionary @@ -29,11 +29,10 @@ public class buyMiningContract103 : MonoBehaviour // 将响应反序列化为对象 BuyMiningResponse buyMiningResponse = JsonConvert.DeserializeObject(response0103); - bool isSucceed; - if (buyMiningResponse.code == 200) { isSucceed = true; } else { isSucceed = false; } + Debug.Log("10.3购买合约的ID" + buyMiningResponse.data); // 返回解析后的对象 - return isSucceed; + return buyMiningResponse; } } //==========请求体=========================== @@ -47,5 +46,10 @@ public class BuyMiningContractBody //==========返回值=========================== public class BuyMiningResponse : Response { - public string data; -} \ No newline at end of file + public long data; +} + +public class BuyResponse +{ + public long id; +} diff --git a/TheStrongestSnail/Assets/Scripts/kuangChang10/queryMyPureContract106.cs b/TheStrongestSnail/Assets/Scripts/kuangChang10/queryMyPureContract106.cs index ce8d9aa..377519a 100644 --- a/TheStrongestSnail/Assets/Scripts/kuangChang10/queryMyPureContract106.cs +++ b/TheStrongestSnail/Assets/Scripts/kuangChang10/queryMyPureContract106.cs @@ -27,17 +27,17 @@ public class queryMyPureContract106 : MonoBehaviour // 妫鏌ヨ繑鍥炵殑鏁版嵁 if (contractResponse != null && contractResponse.data != null) { - //foreach (var contract in contractResponse.data) - //{ - // // 璁块棶鍚堢害瀛楁 - // Debug.Log($"鍚堢害 ID: {contract.id}"); - // Debug.Log($"鍚堢害鍚嶇О: {contract.contractName}"); - // Debug.Log($"姣忕濂栧姳: {contract.eachSecondsReward}"); - // Debug.Log($"鍚堢害鍒涘缓鏃堕棿: {contract.createTime}"); - // Debug.Log($"鍚堢害鏇存柊鏃堕棿: {contract.updateTime}"); + foreach (var contract in contractResponse.data) + { + // 璁块棶鍚堢害瀛楁 + //Debug.Log($"鍚堢害 ID: {contract.id}"); + //Debug.Log($"鍚堢害鍚嶇О: {contract.contractName}"); + //Debug.Log($"姣忕濂栧姳: {contract.eachSecondsReward}"); + //Debug.Log($"鍚堢害鍒涘缓鏃堕棿: {contract.createTime}"); + //Debug.Log($"鍚堢害鏇存柊鏃堕棿: {contract.updateTime}"); - // // 杩欓噷鍙互鏍规嵁闇瑕佽繘琛屽叾浠栧鐞 - //} + // 杩欓噷鍙互鏍规嵁闇瑕佽繘琛屽叾浠栧鐞 + } } else {