_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/ListPanel.cs

212 lines
5.7 KiB
C#
Raw Normal View History

2024-11-23 21:47:04 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ListPanel : BasePanel
{
public static ListPanel instance;
public Button returnBtn;
2024-11-23 23:44:16 +08:00
public Toggle toggle1; // <20><>һ<EFBFBD><D2BB> Toggle
public Toggle toggle2; // <20>ڶ<EFBFBD><DAB6><EFBFBD> Toggle
public GameObject panel1; // <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public GameObject panel2; // <20>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-11-24 00:01:23 +08:00
public Transform tog1;
public Transform tog2;
public Transform parent1;//<2F>ɰ常<C9B0><E5B8B8><EFBFBD><EFBFBD>
public Transform parent2;
public Transform Orparent1;//ԭʼ<D4AD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public Transform Orparent2;
public GameObject ListItemPre;//<2F><><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD>
public List<GameObject> ItemList;
2024-11-26 15:48:20 +08:00
public List<GameObject> ItemListLastDay;
public Transform CreateParentToDay;
public Transform CreateParentLastDay;
2024-11-26 15:48:20 +08:00
public ListItem SelfListToDay;//<2F>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD>
public ListItem SelfListLastDay;//<2F>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD>
public AllHouseContro allHouseContro;
2024-11-23 21:47:04 +08:00
public override void Start()
{
base.Start();
instance = this;
returnBtn.onClick.AddListener(OnClickReBtn);
2024-11-23 23:44:16 +08:00
2024-11-26 15:48:20 +08:00
allHouseContro.GetInfo518();
allHouseContro.GetInfo518(1);
2024-11-23 23:44:16 +08:00
// <20><>ʼ<EFBFBD><CABC> Toggle <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>¼<EFBFBD>
toggle1.onValueChanged.AddListener(OnToggle1Changed);
toggle2.onValueChanged.AddListener(OnToggle2Changed);
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Toggle <20>ij<EFBFBD>ʼֵ
UpdatePanels();
}
// <20><>һ<EFBFBD><D2BB> Toggle <20>ı<C4B1>¼<EFBFBD>
private void OnToggle1Changed(bool isOn)
{
if (isOn)
{
2024-11-24 00:01:23 +08:00
SetMarsk(2);
2024-11-23 23:44:16 +08:00
panel1.SetActive(true);
panel2.SetActive(false);
2024-11-26 15:48:20 +08:00
SelfListToDay.gameObject.SetActive(true);
SelfListLastDay.gameObject.SetActive(false);
2024-11-23 23:44:16 +08:00
}
2024-11-23 21:47:04 +08:00
}
2024-11-23 23:44:16 +08:00
// <20>ڶ<EFBFBD><DAB6><EFBFBD> Toggle <20>ı<C4B1>¼<EFBFBD>
private void OnToggle2Changed(bool isOn)
{
if (isOn)
{
2024-11-24 00:01:23 +08:00
SetMarsk(1);
2024-11-23 23:44:16 +08:00
panel1.SetActive(false);
panel2.SetActive(true);
2024-11-26 15:48:20 +08:00
SelfListLastDay.gameObject.SetActive(true);
SelfListToDay.gameObject.SetActive(false);
//allHouseContro.GetInfo518(1);
2024-11-23 23:44:16 +08:00
}
}
// <20><><EFBFBD>ݵ<EFBFBD>ǰ Toggle <20><>״̬<D7B4><CCAC>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-11-26 15:48:20 +08:00
public void UpdatePanels()
2024-11-23 23:44:16 +08:00
{
panel1.SetActive(toggle1.isOn);
panel2.SetActive(toggle2.isOn);
}
2024-11-26 15:48:20 +08:00
public void ShowPanels()//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
panel1.SetActive(true);
panel2.SetActive(true);
}
2024-11-23 23:44:16 +08:00
void OnDestroy()
{
// ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>й©
toggle1.onValueChanged.RemoveListener(OnToggle1Changed);
toggle2.onValueChanged.RemoveListener(OnToggle2Changed);
}
2024-11-23 21:47:04 +08:00
public void OnClickReBtn()
{
HidePanel();
}
2024-11-24 00:01:23 +08:00
public void SetMarsk(int i)
{
if (i==1)
{
tog1.SetParent(parent1);
tog2.SetParent(Orparent2);
}
else
{
tog1.SetParent(Orparent1);
tog2.SetParent(parent2);
}
}
2024-11-26 15:48:20 +08:00
public void CreateListItem(List<gameEscapeUserBetResponseVoList> gameData,Transform parent,int flag=0)
{
foreach (gameEscapeUserBetResponseVoList item in gameData)
{
GameObject newPanel = Instantiate(ListItemPre, parent);
ListItem panelComponent = newPanel.GetComponent<ListItem>();
// <20><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
panelComponent.list=item.orderNo;
2024-11-26 15:48:20 +08:00
panelComponent.listText.text= item.orderNo.ToString();
panelComponent.nameText.text=item.nickName;
2024-11-26 14:07:07 +08:00
panelComponent.numText.text = item.bet.ToString();
2024-11-26 15:48:20 +08:00
if (flag==0)
{
2024-11-26 15:48:20 +08:00
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>Ѵ<EFBFBD><D1B4><EFBFBD>
bool exists = false;
foreach (GameObject panel in ItemList)
{
2024-11-26 15:48:20 +08:00
if (panel.GetComponent<ListItem>().list == item.orderNo)
{
exists = true;
break;
}
}
2024-11-26 15:48:20 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>б<EFBFBD>
if (!exists)
{
ItemList.Add(newPanel);
2024-11-26 15:48:20 +08:00
}
else
{
// <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD><D1B4>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD>Ը<EFBFBD><D4B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ٸ<EFBFBD>ʵ<EFBFBD><CAB5>
Destroy(newPanel);
}
}
else
{
2024-11-26 15:48:20 +08:00
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>Ѵ<EFBFBD><D1B4><EFBFBD>
bool exists = false;
foreach (GameObject panel in ItemListLastDay)
{
if (panel.GetComponent<ListItem>().list == item.orderNo)
{
exists = true;
break;
}
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>б<EFBFBD>
if (!exists)
{
ItemListLastDay.Add(newPanel);
}
else
{
// <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD><D1B4>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD>Ը<EFBFBD><D4B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ٸ<EFBFBD>ʵ<EFBFBD><CAB5>
Destroy(newPanel);
}
}
2024-11-26 15:48:20 +08:00
}
}
2024-11-26 15:48:20 +08:00
public void SetSelfList(userBetInfo info,int flag=0)
{
2024-11-26 15:48:20 +08:00
if (flag==0)
{
SelfListToDay.listText.text = info.orderNo;
SelfListToDay.nameText.text = info.nickName;
SelfListToDay.numText.text = info.bet.ToString();
SelfListToDay.headPath = info.headImg;
SelfListToDay.SetListImage();
SelfListToDay.ListBgImage();
}
else
{
SelfListLastDay.listText.text = info.orderNo;
SelfListLastDay.nameText.text = info.nickName;
SelfListLastDay.numText.text = info.bet.ToString();
SelfListLastDay.headPath = info.headImg;
2024-11-26 15:48:20 +08:00
SelfListLastDay.SetListImage();
SelfListLastDay.ListBgImage();
}
}
2024-11-23 21:47:04 +08:00
}