_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/HistoryPanel.cs

319 lines
9.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 List<HistoryItem> WinTimesList;//100<30>ζ<EFBFBD><CEB6><EFBFBD>ͳ<EFBFBD><CDB3>
2024-11-20 02:41:39 +08:00
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-12-09 09:14:09 +08:00
public ScrollRect scrollRect; // <20><>ScrollRect<63><74>ק<EFBFBD><D7A7><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>
2024-11-20 02:41:39 +08:00
public override void Start()
{
2024-12-09 09:14:09 +08:00
scrollRect.vertical = false; // <20><><EFBFBD>ô<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>
2024-11-20 02:41:39 +08:00
base.Start();
returnBtn.onClick.AddListener(OnClickReBtn);
2024-12-09 09:14:09 +08:00
// <20><><EFBFBD><EFBFBD>ScrollViewĬ<77><C4AC><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-11-20 02:41:39 +08:00
}
public void OnClickReBtn()
{
HidePanel();
}
2024-12-09 09:14:09 +08:00
public override void HidePanel()
{
scrollRect.vertical = false; // <20><><EFBFBD>ô<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>
base.HidePanel();
}
public override void ShowPanel()
{
scrollRect.vertical = true; // <20><><EFBFBD>ô<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>
base.ShowPanel();
}
2024-11-20 02:41:39 +08:00
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>ֵ
}
}
}
public void SetWinText(List<gameKnightHorseResponseVo> gameKnightHorseResponseVoList)//<2F><>100<30>ζ<EFBFBD><CEB6>ڼ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ı<EFBFBD><C4B1>޸ķ<DEB8><C4B7><EFBFBD>
{
foreach (gameKnightHorseResponseVo gameKnightHorseResponseVo in gameKnightHorseResponseVoList)
{
for (int i = 0; i < WinTimesList.Count; i++)
{
if (WinTimesList[i].roomNo ==int.Parse (gameKnightHorseResponseVo.horseNo))
{
WinTimesList[i].TextPro.text = gameKnightHorseResponseVo.horseCount + "<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
{
2024-12-12 14:45:23 +08:00
if (journalPanels.Count > 0)
{
for (int i = 0; i < journalPanels.Count; i++)
{
Destroy(journalPanels[i]);
}
journalPanels.Clear();
}
2024-11-25 15:57:15 +08:00
foreach (dataList item in gameData)
{
2024-12-12 14:45:23 +08:00
2024-11-25 17:16:41 +08:00
// ʵ<><CAB5><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>µ<EFBFBD> JournalPanelPre <20><><EFBFBD><EFBFBD>
GameObject newPanel = Instantiate(JournalPanelPre, JournParent);
2024-12-09 09:14:09 +08:00
2024-11-25 17:16:41 +08:00
// <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-12-09 09:14:09 +08:00
2024-11-25 15:57:15 +08:00
}
2024-11-20 02:41:39 +08:00
2024-11-25 17:16:41 +08:00
2024-12-09 10:48:14 +08:00
public void SetKillHouse(List<gameEscapeModel> gameEscapeModelList) // <20><>¼<EFBFBD><C2BC> 10 <20>α<EFBFBD><CEB1><EFBFBD>ɱ<EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>
2024-11-20 02:41:39 +08:00
{
2024-12-09 10:48:14 +08:00
foreach (gameEscapeModel gameEscape in gameEscapeModelList)
2024-11-20 02:41:39 +08:00
{
2024-12-09 10:48:14 +08:00
string[] parts = gameEscape.roomNoKill.Split(","); // <20><><EFBFBD><EFBFBD> ',' <20>ָ<EFBFBD><D6B8>ַ<EFBFBD><D6B7><EFBFBD>
Debug.Log("<22><><EFBFBD><EFBFBD>ɱ<EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD>: " + gameEscape.roomNoKill + "---------------");
// ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>µĶ<C2B5><C4B6><EFBFBD>
GameObject newHistoryItem = Instantiate(historyItemPre, ItemPreGrid);
// <20><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
HistoryItem historyItemComponent = newHistoryItem.GetComponent<HistoryItem>();
foreach (string killNo in parts)
2024-11-20 02:41:39 +08:00
{
2024-12-09 10:48:14 +08:00
historyItemComponent.nameTextPro.text += AddName(int.Parse(killNo)); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-11-20 02:41:39 +08:00
}
2024-12-09 10:48:14 +08:00
historyItemComponent.TextPro.text = gameEscape.gameNo + "<22><>"; // <20>ں<EFBFBD>
//historyItemComponent.image.sprite = item.sprite; // <20><><EFBFBD><EFBFBD>ͼƬ
// <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><E0B1A3> 10 <20><>ʵ<EFBFBD><CAB5>
if (ItemList.Count >= 10)
{
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>
}
// <20><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>б<EFBFBD>
ItemList.Add(newHistoryItem);
}
}
public string AddName(int roomId)
{
string text="";
switch (roomId)
{
case 1:
text = "<22>Ϲ<EFBFBD><CFB9><EFBFBD>";
break;
case 2:
text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
break;
case 3:
text = "<22><><EFBFBD>־<EFBFBD>";
break;
case 4:
text = "<22>ƶ<EFBFBD><C6B6><EFBFBD>";
break;
case 5:
text = "<22><>Ц<EFBFBD><D0A6>";
break;
case 6:
text = "<22><>Ȥ<EFBFBD><C8A4>";
break;
2024-11-20 02:41:39 +08:00
}
2024-12-09 10:48:14 +08:00
return text;
2024-11-20 02:41:39 +08:00
}
2024-11-25 17:16:41 +08:00
2024-12-09 10:48:14 +08:00
2024-12-09 23:50:20 +08:00
public string AddRaName(int roomId)
{
string text = "";
switch (roomId)
{
case 1:
text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
break;
case 2:
text = <><D6A9><EFBFBD><EFBFBD>";
break;
case 3:
text = "<22><>Һ<EFBFBD><D2BA>";
break;
case 4:
text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
break;
case 5:
text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
break;
case 6:
text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
break;
case 7:
text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
break;
case 8:
text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
break;
}
return text;
}
public void SetRaKillHouse(List<GameKnightModelRecord> gameKnightModelList) // <20><>¼<EFBFBD><C2BC> 10 <20>α<EFBFBD><CEB1><EFBFBD><EFBFBD><EFBFBD>¼
{
foreach (GameKnightModelRecord gameKnightMode in gameKnightModelList)
{
if (gameKnightMode.horseNoAll!="")
{
string[] parts = gameKnightMode.horseNoAll.Split(","); // <20><><EFBFBD><EFBFBD> ',' <20>ָ<EFBFBD><D6B8>ַ<EFBFBD><D6B7><EFBFBD>
// ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>µĶ<C2B5><C4B6><EFBFBD>
GameObject newHistoryItem = Instantiate(historyItemPre, ItemPreGrid);
// <20><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
HistoryItem historyItemComponent = newHistoryItem.GetComponent<HistoryItem>();
int index = 0;
foreach (string RemainNo in parts)
{
if (index==1)//#A3FBFF //#D7FFA0 //#FFF9A3 //#FEED9F
{
historyItemComponent.nameTextPro.text += "<color=#D7FFA0>" + AddRaName(int.Parse(RemainNo)) + "</color>"; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
else if (index==2)
{
historyItemComponent.nameTextPro.text += "<color=#A3FBFF>" + AddRaName(int.Parse(RemainNo)) + "</color>"; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
else if (index==3)
{
historyItemComponent.nameTextPro.text += AddRaName(int.Parse(RemainNo)); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
else
{
historyItemComponent.nameTextPro.text += "<color=#FEED9F>" + AddRaName(int.Parse(RemainNo)) + "</color>"; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
index++;
}
historyItemComponent.TextPro.text = gameKnightMode.gameNo + "<22><>"; // <20>ں<EFBFBD>
//historyItemComponent.image.sprite = item.sprite; // <20><><EFBFBD><EFBFBD>ͼƬ
// <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><E0B1A3> 10 <20><>ʵ<EFBFBD><CAB5>
if (ItemList.Count >= 10)
{
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>
}
// <20><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>б<EFBFBD>
ItemList.Add(newHistoryItem);
}
}
}
2024-11-20 02:41:39 +08:00
}