2024-11-14 16:05:27 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
2024-12-25 23:35:36 +08:00
|
|
|
|
using Unity.VisualScripting;
|
2024-11-14 16:05:27 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
public class Lottery : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public GameObject LotteryPanel;
|
|
|
|
|
public Button LotteryBtn;
|
2024-12-18 23:39:18 +08:00
|
|
|
|
|
|
|
|
|
public GameObject petItem;
|
|
|
|
|
public Transform Connect;
|
2024-12-25 23:35:36 +08:00
|
|
|
|
public Text WaterText;
|
2024-12-18 23:39:18 +08:00
|
|
|
|
|
2024-12-25 17:33:42 +08:00
|
|
|
|
public List<Sprite> petsp = new List<Sprite>();
|
2024-12-25 21:48:50 +08:00
|
|
|
|
public List<PetFightingBtn> fightinglist = new List<PetFightingBtn>();
|
2025-01-06 11:46:12 +08:00
|
|
|
|
public List<GameObject> ExuExhibitmusklist = new List<GameObject>();
|
|
|
|
|
|
2024-12-25 21:48:50 +08:00
|
|
|
|
public Button ClosefightingBtn;
|
2024-12-25 23:35:36 +08:00
|
|
|
|
public List<GameObject> objitem = new List<GameObject>();
|
2024-12-30 14:12:56 +08:00
|
|
|
|
public List<string> shenxiaocard = new List<string>();
|
|
|
|
|
|
|
|
|
|
async void OnEnable()
|
2024-12-25 23:35:36 +08:00
|
|
|
|
{
|
|
|
|
|
TreeInfo info = await Scene_main_jiekou.instance.TreeInfoS();
|
|
|
|
|
WaterText.text = info.Data.Water.ToString();
|
2025-01-07 17:28:25 +08:00
|
|
|
|
Update_itemClick();
|
2024-12-25 23:35:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-12-25 21:48:50 +08:00
|
|
|
|
|
2024-12-18 23:39:18 +08:00
|
|
|
|
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);
|
2024-12-25 23:35:36 +08:00
|
|
|
|
|
2024-12-18 23:39:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-06 11:46:12 +08:00
|
|
|
|
public void Closemusk()//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չʾ<D5B9><CABE>musk
|
|
|
|
|
{
|
|
|
|
|
foreach (GameObject obj in ExuExhibitmusklist)
|
|
|
|
|
{
|
|
|
|
|
obj.gameObject.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-18 23:39:18 +08:00
|
|
|
|
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>ȥ
|
2024-12-18 23:39:18 +08:00
|
|
|
|
{
|
|
|
|
|
GameObject obj = GameObject.Instantiate(petItem, Connect);
|
2024-12-25 23:35:36 +08:00
|
|
|
|
objitem.Add(obj);
|
2024-12-18 23:39:18 +08:00
|
|
|
|
obj.GetComponent<PetCard>().petName.text = info.data.items[i].name;
|
|
|
|
|
obj.GetComponent<PetCard>().petFightingBtn.id = info.data.items[i].id;
|
2024-12-25 17:33:42 +08:00
|
|
|
|
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;
|
2025-01-06 11:46:12 +08:00
|
|
|
|
obj.GetComponent<PetCard>().petFightingBtn.Exhibitmusk = obj.GetComponent<PetCard>().Exhibitmusk;
|
|
|
|
|
fightinglist.Add(obj.GetComponent<PetCard>().petFightingBtn);
|
|
|
|
|
ExuExhibitmusklist.Add(obj.GetComponent<PetCard>().Exhibitmusk);
|
|
|
|
|
if (info.data.items[i].battles_status == 1)
|
|
|
|
|
{
|
|
|
|
|
obj.GetComponent<PetCard>().petFightingBtn.Exhibitmusk.SetActive(true);
|
|
|
|
|
}
|
2024-12-18 23:39:18 +08:00
|
|
|
|
}
|
2024-12-25 23:35:36 +08:00
|
|
|
|
|
2024-11-14 16:15:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-12-25 17:33:42 +08:00
|
|
|
|
Sprite showSprite(string n)
|
|
|
|
|
{
|
2024-12-30 14:12:56 +08:00
|
|
|
|
for (int i = 0; i < shenxiaocard.Count; i++)
|
|
|
|
|
{
|
2024-12-30 14:36:08 +08:00
|
|
|
|
if (shenxiaocard[i].Equals(n))
|
2024-12-30 14:12:56 +08:00
|
|
|
|
{
|
|
|
|
|
return petsp[i];
|
|
|
|
|
}
|
2024-12-25 17:33:42 +08:00
|
|
|
|
}
|
|
|
|
|
return null;
|
2024-12-30 14:12:56 +08:00
|
|
|
|
}
|
2024-12-25 17:33:42 +08:00
|
|
|
|
|
|
|
|
|
|
2024-12-18 23:39:18 +08:00
|
|
|
|
async void LotteryClick()
|
2024-11-14 17:23:08 +08:00
|
|
|
|
{
|
2024-12-18 23:39:18 +08:00
|
|
|
|
PetAdoptResponse response = await Scene_main_jiekou.instance.PetAdopts();
|
|
|
|
|
if (response.code == 200)
|
|
|
|
|
{
|
2024-12-25 23:35:36 +08:00
|
|
|
|
foreach (GameObject ob in objitem)
|
|
|
|
|
{
|
|
|
|
|
Destroy(ob);
|
|
|
|
|
}
|
|
|
|
|
objitem.Clear();
|
|
|
|
|
fightinglist.Clear();
|
2025-01-07 17:28:25 +08:00
|
|
|
|
foreach (GameObject obj in ExuExhibitmusklist)
|
|
|
|
|
{
|
|
|
|
|
Destroy(obj);
|
|
|
|
|
}
|
|
|
|
|
ExuExhibitmusklist.Clear();
|
2024-12-18 23:39:18 +08:00
|
|
|
|
Update_itemClick();
|
|
|
|
|
TreeInfo info = await Scene_main_jiekou.instance.TreeInfoS();
|
2024-12-25 23:35:36 +08:00
|
|
|
|
WaterText.text = info.Data.Water.ToString();
|
2024-12-18 23:39:18 +08:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2025-01-07 17:28:25 +08:00
|
|
|
|
private void OnDisable()
|
|
|
|
|
{
|
|
|
|
|
foreach (GameObject ob in objitem)
|
|
|
|
|
{
|
|
|
|
|
Destroy(ob);
|
|
|
|
|
}
|
|
|
|
|
objitem.Clear();
|
|
|
|
|
foreach (GameObject obj in ExuExhibitmusklist)
|
|
|
|
|
{
|
|
|
|
|
Destroy(obj);
|
|
|
|
|
}
|
|
|
|
|
ExuExhibitmusklist.Clear();
|
|
|
|
|
fightinglist.Clear();
|
|
|
|
|
}
|
2024-11-14 16:05:27 +08:00
|
|
|
|
// Update is called once per frame
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|