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

116 lines
3.0 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;
public List<Sprite> petsp = new List<Sprite>();
2024-12-25 21:48:50 +08:00
public List<PetFightingBtn> fightinglist = new List<PetFightingBtn>();
public Button ClosefightingBtn;
async void Start()
2024-11-14 16:05:27 +08:00
{
2024-11-14 16:15:28 +08:00
LotteryBtn.onClick.AddListener(LotteryClick);
2024-12-25 21:48:50 +08:00
ClosefightingBtn.onClick.AddListener(CloseBtnClick);
Update_itemClick();
}
2024-12-25 21:48:50 +08:00
public void CloseBtnClick()//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չʾitem<65><6D>btn
{
foreach (PetFightingBtn btn in fightinglist)
{
btn.gameObject.SetActive(false);
}
}
async void Update_itemClick()
{
PetHome info = await Scene_main_jiekou.instance.getPetHomes();
2024-12-25 21:48:50 +08:00
for (int i = 0; i < info.data.items.Count; i++)//<2F><><EFBFBD><EFBFBD><EFBFBD>Ƭ<EFBFA8><C6AC>item<65><6D><EFBFBD><EFBFBD>id<69><64><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD><CCAC><EFBFBD>ɵĿ<C9B5>Ƭ<EFBFBD><C6AC><EFBFBD><EFBFBD><EFBFBD>صķ<D8B5><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥ
{
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;
obj.GetComponent<PetCard>().petimage.sprite = showSprite(info.data.items[i].name);
2024-12-25 21:48:50 +08:00
obj.GetComponent<PetCard>().petFightingBtn.lottery = this;
fightinglist.Add(obj.GetComponent<PetCard>().petFightingBtn);
}
2024-11-14 16:15:28 +08:00
}
Sprite showSprite(string n)
{
switch (n)
{
case "<22><>":
return petsp[0];
break;
case "ţ":
return petsp[1];
break;
case "<22><>":
return petsp[2];
break;
case "<22><>":
return petsp[3];
break;
case "<22><>":
return petsp[4];
break;
case "<22><>":
return petsp[5];
break;
case "<22><>":
return petsp[6];
break;
case "<22><>":
return petsp[7];
break;
case "<22><>":
return petsp[8];
break;
case "<22><>":
return petsp[9];
break;
case "<22><>":
return petsp[10];
break;
case "<22><>":
return petsp[11];
break;
}
return null;
}
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);
2024-12-25 21:48:50 +08:00
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()
{
}
}