蜗舍完成

This commit is contained in:
杨号敬 2024-12-09 12:00:50 +08:00
parent f6d8f53f6c
commit d69755fa34
10 changed files with 50 additions and 19 deletions

View File

@ -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}

View File

@ -59,7 +59,8 @@ public class SnailPanel : MonoBehaviour
ob.transform.SetParent(transform);
ob.transform.localPosition = spawnPosition;
Snailmove snailmove = ob.GetComponent<Snailmove>();
snailmove.id = usersnail.data[i].snailId;
snailmove.id = usersnail.data[i].id;
Debug.Log(usersnail.data[i].id);
Snails.Add(ob);
}
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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<Snailmove>().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<Snailmove>().id)
{
instanceSnail.gameObject.transform.localPosition = new Vector3(0, 0, 0);
instanceSnail.gameObject.transform.localPosition = new Vector3(0, 0, 0); // 重置位置
}
}
}
}
void OnTriggerEnter2D(Collider2D other)

View File

@ -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;
}
}

View File

@ -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

View File

@ -1,4 +1,5 @@
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
@ -32,11 +33,32 @@ public class queryUserSnailCount : MonoBehaviour
//        message成功提示语
//        data空闲蜗牛的数组这里取数组的长度即可最大渲染10只蜗牛
//            idLong蜗牛的id 
public class UserSnail : Response
public class UserSnail:Response
{
public List<UserSnailData> 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<UserSnailData> data;
}
public class UserSnailData
{
public long snailId;
}
}*/

View File

@ -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: