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

54 lines
1.3 KiB
C#

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()
{
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;
}
}
async void LotteryClick()
{
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("Ë®µÎÓà¶î²»×ã");
}
}
// Update is called once per frame
void Update()
{
}
}