Cute_demon_attacks/meng_yao/Assets/script/TanChuang/Lottery.cs

54 lines
1.3 KiB
C#
Raw Normal View History

2024-11-14 16:05:27 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Lottery : MonoBehaviour
{
public GameObject LotteryPanel;
public Button LotteryBtn;
public GameObject petItem;
public Transform Connect;
async void Start()
2024-11-14 16:05:27 +08:00
{
2024-11-14 16:15:28 +08:00
LotteryBtn.onClick.AddListener(LotteryClick);
Update_itemClick();
}
async void Update_itemClick()
{
PetHome info = await Scene_main_jiekou.instance.getPetHomes();
for (int i = 0; i < info.data.items.Count; i++)
{
GameObject obj = GameObject.Instantiate(petItem, Connect);
obj.GetComponent<PetCard>().petName.text = info.data.items[i].name;
obj.GetComponent<PetCard>().petFightingBtn.id = info.data.items[i].id;
}
2024-11-14 16:15:28 +08:00
}
async void LotteryClick()
2024-11-14 17:23:08 +08:00
{
PetAdoptResponse response = await Scene_main_jiekou.instance.PetAdopts();
if (response.code == 200)
{
Update_itemClick();
TreeInfo info = await Scene_main_jiekou.instance.TreeInfoS();
WaterPanel.instance.Updated_water(info);
Debug.Log(response);
}
else
{
Promptmgr.Instance.PromptBubble(<><CBAE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB2BB>");
}
2024-11-14 16:05:27 +08:00
}
// Update is called once per frame
void Update()
{
}
}