_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/Scene_shop/shopPanel.cs

57 lines
1.9 KiB
C#
Raw Normal View History

2024-11-26 17:03:30 +08:00
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
2024-11-28 00:39:35 +08:00
using UnityEngine.UI;
2024-11-26 17:03:30 +08:00
using DG.Tweening;
2024-11-27 15:27:50 +08:00
public class shopPanel: ui_huodong
2024-11-27 23:22:34 +08:00
{
public List<itemInfo> itemInfos = new List<itemInfo>();
2024-11-28 00:39:35 +08:00
[Header("<22>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD>")]
public GameObject Panel;
public override void Start()
{
base.Start();
initShop();
}
2024-11-27 23:22:34 +08:00
void initShop()
{
2024-11-27 23:39:41 +08:00
int index = 0;
2024-11-28 00:39:35 +08:00
// <20><><EFBFBD><EFBFBD> shopItemDic <20>е<EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> itemInfos <20>е<EFBFBD><D0B5><EFBFBD>ʾ<EFBFBD><CABE>
2024-11-27 23:39:41 +08:00
foreach (KeyValuePair<int, ProductPro> go in Scene_main_jiekou.instance.shopItemDic)
2024-11-27 23:22:34 +08:00
{
2024-11-28 00:39:35 +08:00
// <20><><EFBFBD><EFBFBD> index <20><><EFBFBD><EFBFBD> itemInfos <20>Ĵ<EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>ʾ<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>Ԫ<EFBFBD>ر<EFBFBD> itemInfos <20><><EFBFBD><EFBFBD>
if (index >= itemInfos.Count)
{
Debug.LogWarning("shopItemDic contains more items than itemInfos. Some items will not be shown.");
break; // <20><><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>е<EFBFBD>Ԫ<EFBFBD>ض<EFBFBD><D8B6><EFBFBD> itemInfos <20>е<EFBFBD><D0B5>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
}
// <20><><EFBFBD>µ<EFBFBD>ǰ itemInfo <20><>ʾ<EFBFBD><CABE>
itemInfos[index].gameObject.SetActive(true); // <20><>ʾ<EFBFBD><CABE>ǰ<EFBFBD><C7B0>
itemInfos[index].initShow(go.Value.ProductId, go.Value.ProductName,go.Value.Price.ToString());
2024-11-28 04:26:44 +08:00
itemInfos[index].GetComponent<Button>().onClick.AddListener(async()=> {
await Scene_main_jiekou.instance.ShopItemDetail(go.Value.ProductId);
GameObject.Instantiate(Panel, GameObject.Find("Canvas").transform).GetComponent<wokePanel>().initShow(go.Value.ProductName, go.Value.ProductName, go.Value.Price.ToString(), Scene_main_jiekou.instance._getProductResponse.Data.DataList[0].ProductName);
2024-11-28 00:39:35 +08:00
});
index++;
}
// <20><><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3>δ<EFBFBD><CEB4><EFBFBD>µ<EFBFBD> itemInfos <20><>
while (index < itemInfos.Count)
{
itemInfos[index].gameObject.SetActive(false); // <20><><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD>
index++;
2024-11-27 23:22:34 +08:00
}
2024-11-28 04:26:44 +08:00
2024-11-27 23:22:34 +08:00
}
2024-11-26 17:03:30 +08:00
}