From d69755fa3459b2183a01476901211dbee45096f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8F=B7=E6=95=AC?= <153802103@qq.com> Date: Mon, 9 Dec 2024 12:00:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=9C=97=E8=88=8D=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TheStrongestSnail/Assets/Scenes/yhjtext.unity | 2 +- .../Assets/Scripts/SnailHouse/SnailPanel.cs | 3 +- .../Assets/Scripts/SnailHouse/SnaolHouse.cs | 4 +-- .../Scripts/lianghaoLL/ExchangePanel.cs | 4 +-- .../Assets/Scripts/snailFactory/NoCard.cs | 2 +- .../Scripts/snailFactory/NoSnailCard.cs | 13 ++++++--- .../Scripts/snailFactory/PointFollow.cs | 5 ++-- .../Scripts/snailFactory/SuccessfulCard.cs | 3 +- .../snailFactory/queryUserSnailCount.cs | 28 +++++++++++++++++-- .../Assets/prefabs/YHJPrefabs/Snail.prefab | 5 ++-- 10 files changed, 50 insertions(+), 19 deletions(-) diff --git a/TheStrongestSnail/Assets/Scenes/yhjtext.unity b/TheStrongestSnail/Assets/Scenes/yhjtext.unity index 6861888..ee87a92 100644 --- a/TheStrongestSnail/Assets/Scenes/yhjtext.unity +++ b/TheStrongestSnail/Assets/Scenes/yhjtext.unity @@ -1504,7 +1504,7 @@ MonoBehaviour: m_SelectOnDown: {fileID: 0} m_SelectOnLeft: {fileID: 0} m_SelectOnRight: {fileID: 0} - m_Transition: 1 + m_Transition: 0 m_Colors: m_NormalColor: {r: 1, g: 1, b: 1, a: 1} m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} diff --git a/TheStrongestSnail/Assets/Scripts/SnailHouse/SnailPanel.cs b/TheStrongestSnail/Assets/Scripts/SnailHouse/SnailPanel.cs index 854062a..f82b070 100644 --- a/TheStrongestSnail/Assets/Scripts/SnailHouse/SnailPanel.cs +++ b/TheStrongestSnail/Assets/Scripts/SnailHouse/SnailPanel.cs @@ -59,7 +59,8 @@ public class SnailPanel : MonoBehaviour ob.transform.SetParent(transform); ob.transform.localPosition = spawnPosition; Snailmove snailmove = ob.GetComponent(); - snailmove.id = usersnail.data[i].snailId; + snailmove.id = usersnail.data[i].id; + Debug.Log(usersnail.data[i].id); Snails.Add(ob); } } diff --git a/TheStrongestSnail/Assets/Scripts/SnailHouse/SnaolHouse.cs b/TheStrongestSnail/Assets/Scripts/SnailHouse/SnaolHouse.cs index c2aea03..b458c4b 100644 --- a/TheStrongestSnail/Assets/Scripts/SnailHouse/SnaolHouse.cs +++ b/TheStrongestSnail/Assets/Scripts/SnailHouse/SnaolHouse.cs @@ -43,7 +43,7 @@ public class SnaolHouse : MonoBehaviour factoryList = await queryFactory.QueryFactoryList(); foreach (var FacItem in factoryList.data.dataList) { - if(FacItem.contractId <= 6 && FacItem.contractId >= 3) + if(FacItem.snailId>0) { GameObject ob = Instantiate(Successfulcard); ob.transform.SetParent(content.transform); @@ -54,7 +54,7 @@ public class SnaolHouse : MonoBehaviour foreach (var FacItem in factoryList.data.dataList) { - if (FacItem.contractId > 6 || FacItem.contractId < 3) + if (FacItem.snailId == 0) { GameObject ob = Instantiate(Nosnailcard); ob.transform.SetParent(content.transform); diff --git a/TheStrongestSnail/Assets/Scripts/lianghaoLL/ExchangePanel.cs b/TheStrongestSnail/Assets/Scripts/lianghaoLL/ExchangePanel.cs index ef5a4fa..4a1f513 100644 --- a/TheStrongestSnail/Assets/Scripts/lianghaoLL/ExchangePanel.cs +++ b/TheStrongestSnail/Assets/Scripts/lianghaoLL/ExchangePanel.cs @@ -26,9 +26,9 @@ public class ExchangePanel : Base async void ConfrimPanel() { string response = "";//测试 - string body = "{\"exchangeCode\":\"" + exchangeInput.text + "}"; + string body = "{\"exchangeCode\":\"" + exchangeInput.text + "\"}"; Debug.Log(body); - response = await web.SendRequest(web.URL + "/snail/exchangeCode", "POST", body, Global.global.CreateHeaders()); + response = await web.SendRequest(web.URL + "/snail/snail/exchangeCode", "POST", body, Global.global.CreateHeaders()); Debug.Log(response); } diff --git a/TheStrongestSnail/Assets/Scripts/snailFactory/NoCard.cs b/TheStrongestSnail/Assets/Scripts/snailFactory/NoCard.cs index 7cc93cf..74f1256 100644 --- a/TheStrongestSnail/Assets/Scripts/snailFactory/NoCard.cs +++ b/TheStrongestSnail/Assets/Scripts/snailFactory/NoCard.cs @@ -17,7 +17,7 @@ public class NoCard : Base string strIS = buyNewFactoryResponse.message; addEventPopUp(strIS); if (buyNewFactoryResponse.code == 200) - { + { SnaolHouse.Instance.InitItem(); } })); diff --git a/TheStrongestSnail/Assets/Scripts/snailFactory/NoSnailCard.cs b/TheStrongestSnail/Assets/Scripts/snailFactory/NoSnailCard.cs index a8b47c3..40dc31d 100644 --- a/TheStrongestSnail/Assets/Scripts/snailFactory/NoSnailCard.cs +++ b/TheStrongestSnail/Assets/Scripts/snailFactory/NoSnailCard.cs @@ -19,12 +19,16 @@ public class NoSnailCard : MonoBehaviour if (Bs.code == 200) { SnaolHouse.Instance.InitItem(); - foreach (var instanceSnail in SnailPanel.Instance.Snails) + + // 使用 for 循环来安全地删除元素 + for (int i = 0; i < SnailPanel.Instance.Snails.Count; i++) { + var instanceSnail = SnailPanel.Instance.Snails[i]; if (snailid == instanceSnail.GetComponent().id) { - SnailPanel.Instance.Snails.Remove(instanceSnail); - Destroy(instanceSnail); + SnailPanel.Instance.Snails.RemoveAt(i); // 删除元素 + Destroy(instanceSnail); // 销毁物体 + i--; // 删除元素后需要调整索引 } } } @@ -34,10 +38,11 @@ public class NoSnailCard : MonoBehaviour { if (snailid == instanceSnail.GetComponent().id) { - instanceSnail.gameObject.transform.localPosition = new Vector3(0, 0, 0); + instanceSnail.gameObject.transform.localPosition = new Vector3(0, 0, 0); // 重置位置 } } } + } void OnTriggerEnter2D(Collider2D other) diff --git a/TheStrongestSnail/Assets/Scripts/snailFactory/PointFollow.cs b/TheStrongestSnail/Assets/Scripts/snailFactory/PointFollow.cs index 6809e6f..20a1216 100644 --- a/TheStrongestSnail/Assets/Scripts/snailFactory/PointFollow.cs +++ b/TheStrongestSnail/Assets/Scripts/snailFactory/PointFollow.cs @@ -3,9 +3,10 @@ using UnityEngine.EventSystems; public class PointFollow : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler { + public Vector3 StarTransform; public void OnBeginDrag(PointerEventData eventData) { - + StarTransform = transform.position; } public void OnDrag(PointerEventData eventData) @@ -15,6 +16,6 @@ public class PointFollow : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndD public void OnEndDrag(PointerEventData eventData) { - + transform.position = StarTransform; } } \ No newline at end of file diff --git a/TheStrongestSnail/Assets/Scripts/snailFactory/SuccessfulCard.cs b/TheStrongestSnail/Assets/Scripts/snailFactory/SuccessfulCard.cs index 0b0ce15..b810d71 100644 --- a/TheStrongestSnail/Assets/Scripts/snailFactory/SuccessfulCard.cs +++ b/TheStrongestSnail/Assets/Scripts/snailFactory/SuccessfulCard.cs @@ -13,7 +13,8 @@ public class SuccessfulCard : MonoBehaviour public Text Hptext; void Start() { - Hptext.text = "HP 90/103"; + HpFill.fillAmount = (float)(100 - (FactoryItem.settle * 2.5)) / 100; + Hptext.text = $"HP {100-FactoryItem.settle * 2.5}/100"; } // Update is called once per frame diff --git a/TheStrongestSnail/Assets/Scripts/snailFactory/queryUserSnailCount.cs b/TheStrongestSnail/Assets/Scripts/snailFactory/queryUserSnailCount.cs index 4244830..75aeca8 100644 --- a/TheStrongestSnail/Assets/Scripts/snailFactory/queryUserSnailCount.cs +++ b/TheStrongestSnail/Assets/Scripts/snailFactory/queryUserSnailCount.cs @@ -1,4 +1,5 @@ 锘縰sing Newtonsoft.Json; +using System; using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; @@ -22,7 +23,7 @@ public class queryUserSnailCount : MonoBehaviour // 灏嗗搷搴斿弽搴忓垪鍖栦负瀵硅薄 UserSnail userSnail = JsonConvert.DeserializeObject(response92); - + // 杩斿洖瑙f瀽鍚庣殑瀵硅薄 return userSnail; } @@ -32,11 +33,32 @@ public class queryUserSnailCount : MonoBehaviour //聽 聽 聽 聽 message锛氭垚鍔燂紝鎻愮ず璇 //聽 聽 聽 聽 data锛氱┖闂茶湕鐗涚殑鏁扮粍锛岃繖閲屽彇鏁扮粍鐨勯暱搴﹀嵆鍙紝鏈澶ф覆鏌10鍙湕鐗 //聽 聽 聽 聽 聽 聽 id锛歀ong锛岃湕鐗涚殑id聽 -public class UserSnail : Response +public class UserSnail:Response +{ + public List data { get; set; } // 鐢ㄤ簬瀛樺偍鏁版嵁鍒楄〃 +} + +public class UserSnailData +{ + public int id { get; set; } // id + public int userId { get; set; } // userId + public int orderId { get; set; } // orderId + public int slotId { get; set; } // slotId + public int source { get; set; } // source + public string exchangeCode { get; set; } // exchangeCode + public string workBegin { get; set; } // workBegin + public string workEnd { get; set; } // workEnd + public string workNow { get; set; } // workNow + public int settle { get; set; } // settle + public int status { get; set; } // status + public string createTime { get; set; } // createTime + public string updateTime { get; set; } // updateTime +} +/*public class UserSnail : Response { public List data; } public class UserSnailData { public long snailId; -} \ No newline at end of file +}*/ diff --git a/TheStrongestSnail/Assets/prefabs/YHJPrefabs/Snail.prefab b/TheStrongestSnail/Assets/prefabs/YHJPrefabs/Snail.prefab index 8aac839..93be0c8 100644 --- a/TheStrongestSnail/Assets/prefabs/YHJPrefabs/Snail.prefab +++ b/TheStrongestSnail/Assets/prefabs/YHJPrefabs/Snail.prefab @@ -95,6 +95,7 @@ MonoBehaviour: m_EditorClassIdentifier: moveDirection: {x: 0, y: 0, z: 0} animator: {fileID: 2063921404481402532} + id: 0 --- !u!95 &2063921404481402532 Animator: serializedVersion: 5 @@ -141,7 +142,7 @@ BoxCollider2D: m_IsTrigger: 0 m_UsedByEffector: 0 m_UsedByComposite: 0 - m_Offset: {x: -0.5000305, y: 0.38305664} + m_Offset: {x: -3.2713928, y: 1.4916382} m_SpriteTilingProperty: border: {x: 0, y: 0, z: 0, w: 0} pivot: {x: 0, y: 0} @@ -152,7 +153,7 @@ BoxCollider2D: adaptiveTiling: 0 m_AutoTiling: 0 serializedVersion: 2 - m_Size: {x: 101.12958, y: 98.29883} + m_Size: {x: 142.14545, y: 131.55505} m_EdgeRadius: 0 --- !u!50 &3987721522704656746 Rigidbody2D: