_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/HistoryPanel.cs

134 lines
4.2 KiB
C#
Raw Normal View History

2024-11-20 02:41:39 +08:00
using System.Collections;
using System.Collections.Generic;
2024-11-25 17:16:41 +08:00
using System.Globalization;
2024-11-20 02:41:39 +08:00
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class HistoryPanel : BasePanel
{
public Button returnBtn;
public List<HistoryItem> KillTimesList;//100<30>λ<EFBFBD>ɱͳ<C9B1><CDB3>
public GameObject historyItemPre;//<2F><>ƷԤ<C6B7><D4A4><EFBFBD><EFBFBD>
public Transform ItemPreGrid;//Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD>
public List<GameObject> ItemList;
2024-11-25 14:37:44 +08:00
public TextMeshProUGUI throwEggText;//Ͷ<><CDB6><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>
public TextMeshProUGUI getEggText;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>
2024-11-25 15:57:15 +08:00
public GameObject JournalPanelPre;//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD>
public Transform JournParent;//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E5B8B8><EFBFBD><EFBFBD>
2024-11-25 17:16:41 +08:00
public List<GameObject> journalPanels=new List<GameObject>();
2024-11-20 02:41:39 +08:00
public override void Start()
{
base.Start();
returnBtn.onClick.AddListener(OnClickReBtn);
}
public void OnClickReBtn()
{
HidePanel();
}
public void SetKilledText(gameEscapeRoomKillCountResponseVo gameKill)//<2F><>100<30>α<EFBFBD>ɱ<EFBFBD><C9B1>¼<EFBFBD><C2BC><EFBFBD>ı<EFBFBD><C4B1>޸ķ<DEB8><C4B7><EFBFBD>
{
for (int i=0;i<KillTimesList.Count;i++)
{
if (KillTimesList[i].roomNo == gameKill.roomNo)
{
KillTimesList[i].TextPro.text = gameKill.kill+"<22><>";//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
}
}
}
2024-11-25 17:16:41 +08:00
public void CreateJournalPanel(List<dataList> gameData) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʷ<EFBFBD><CAB7>¼
2024-11-25 15:57:15 +08:00
{
foreach (dataList item in gameData)
{
2024-11-25 17:16:41 +08:00
// ʵ<><CAB5><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>µ<EFBFBD> JournalPanelPre <20><><EFBFBD><EFBFBD>
GameObject newPanel = Instantiate(JournalPanelPre, JournParent);
// <20><>ȡ<EFBFBD><C8A1>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD> JournalPanel <20><><EFBFBD><EFBFBD>
JournalPanel panelComponent = newPanel.GetComponent<JournalPanel>();
// <20><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
panelComponent.gameNoText.text = item.gameNo + "<22><>";
panelComponent.gameNo = item.gameNo;
panelComponent.betText.text = item.bet.ToString();
panelComponent.roomNo = item.roomNo;
panelComponent.roomNoKill = item.roomNoKill;
panelComponent.beansCoinText.text = item.beansCoin.ToString();
panelComponent.createTimeText.text = item.createTime;
panelComponent.outcome = item.outcome;
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>Ѵ<EFBFBD><D1B4><EFBFBD>
bool exists = false;
foreach (GameObject panel in journalPanels)
{
if (panel.GetComponent<JournalPanel>().gameNo == item.gameNo)
{
exists = true;
break;
}
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>б<EFBFBD>
if (!exists)
{
journalPanels.Add(newPanel);
2024-11-25 17:16:41 +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);
}
2024-11-25 15:57:15 +08:00
}
}
2024-11-20 02:41:39 +08:00
2024-11-25 17:16:41 +08:00
public void SetKillHouse(gameEscapeModel gameEscapeModelList) // <20><>¼<EFBFBD><C2BC> 10 <20>α<EFBFBD><CEB1><EFBFBD>ɱ<EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>
2024-11-20 02:41:39 +08:00
{
2024-11-25 17:16:41 +08:00
string[] parts = gameEscapeModelList.roomNoKill.Split(","); // <20><><EFBFBD><EFBFBD> ',' <20>ָ<EFBFBD><D6B8>ַ<EFBFBD><D6B7><EFBFBD>
Debug.Log("<22><><EFBFBD><EFBFBD>ɱ<EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD>: " + gameEscapeModelList.roomNoKill + "---------------");
2024-11-20 02:41:39 +08:00
foreach (string part in parts)
{
2024-11-25 17:16:41 +08:00
foreach (HistoryItem item in KillTimesList)
2024-11-20 02:41:39 +08:00
{
2024-11-25 17:16:41 +08:00
if (item.roomNo == int.Parse(part))
2024-11-20 02:41:39 +08:00
{
2024-11-25 17:16:41 +08:00
// ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>µĶ<C2B5><C4B6><EFBFBD>
GameObject newHistoryItem = Instantiate(historyItemPre, ItemPreGrid);
2024-11-20 02:41:39 +08:00
2024-11-25 17:16:41 +08:00
// <20><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
HistoryItem historyItemComponent = newHistoryItem.GetComponent<HistoryItem>();
historyItemComponent.nameTextPro.text = item.nameTextPro.text; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
historyItemComponent.TextPro.text = gameEscapeModelList.gameNo + "<22><>"; // <20>ں<EFBFBD>
historyItemComponent.image.sprite = item.sprite; // <20><><EFBFBD><EFBFBD>ͼƬ
2024-11-20 02:41:39 +08:00
2024-11-25 17:16:41 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><E0B1A3> 10 <20><>ʵ<EFBFBD><CAB5>
if (ItemList.Count >= 10)
2024-11-20 02:41:39 +08:00
{
2024-11-25 17:16:41 +08:00
Destroy(ItemList[0]); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
ItemList.RemoveAt(0); // <20><><EFBFBD>б<EFBFBD><D0B1>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
2024-11-20 02:41:39 +08:00
}
2024-11-25 17:16:41 +08:00
// <20><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>б<EFBFBD>
ItemList.Add(newHistoryItem);
2024-11-20 02:41:39 +08:00
}
}
}
}
2024-11-25 17:16:41 +08:00
2024-11-20 02:41:39 +08:00
}