76 lines
2.2 KiB
C#
76 lines
2.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class HistoryPanel : BasePanel
|
|
{
|
|
public Button returnBtn;
|
|
public List<HistoryItem> KillTimesList;//100次击杀统计
|
|
public GameObject historyItemPre;//物品预制体
|
|
public Transform ItemPreGrid;//预制体生成后的父物体
|
|
public List<GameObject> ItemList;
|
|
public override void Start()
|
|
{
|
|
base.Start();
|
|
returnBtn.onClick.AddListener(OnClickReBtn);
|
|
}
|
|
|
|
public void OnClickReBtn()
|
|
{
|
|
HidePanel();
|
|
}
|
|
|
|
public void SetKilledText(gameEscapeRoomKillCountResponseVo gameKill)//近100次被杀记录的文本修改方法
|
|
{
|
|
for (int i=0;i<KillTimesList.Count;i++)
|
|
{
|
|
|
|
if (KillTimesList[i].roomNo == gameKill.roomNo)
|
|
{
|
|
KillTimesList[i].TextPro.text = gameKill.kill+"次";//给次数值
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public void SetKillHouse(gameEscapeModel gameEscapeModelList)//记录近10次被击杀的房间
|
|
{
|
|
string[] parts = gameEscapeModelList.roomNoKill.Split(","); // 根据 ',' 分割字符串d
|
|
|
|
Debug.Log("jiijojjiijjiijijij" + gameEscapeModelList.roomNoKill+"---------------");
|
|
foreach (string part in parts)
|
|
{
|
|
foreach (HistoryItem item in KillTimesList)
|
|
{
|
|
if (item.roomNo==int.Parse(part))
|
|
{
|
|
historyItemPre.GetComponent<HistoryItem>().nameTextPro.text = item.nameTextPro.text;//房间名字
|
|
historyItemPre.GetComponent<HistoryItem>().TextPro.text=item.TextPro.text;//被杀次数
|
|
historyItemPre.GetComponent<HistoryItem>().image.sprite=item.sprite;//背景图片
|
|
|
|
if (ItemList.Count>10)
|
|
{
|
|
for (int i=0;i<10;i++)
|
|
{
|
|
Destroy(ItemList[i]);
|
|
ItemList.Remove(ItemList[i]);
|
|
}
|
|
|
|
}
|
|
ItemList.Add(Instantiate(historyItemPre, ItemPreGrid));
|
|
//break;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
}
|