83 lines
2.3 KiB
C#
83 lines
2.3 KiB
C#
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
namespace Script.UI
|
|||
|
{
|
|||
|
public class CulturePanel : PanelBase
|
|||
|
{
|
|||
|
public GameObject item;
|
|||
|
public Button btn_Close;
|
|||
|
|
|||
|
public override void Init()
|
|||
|
{
|
|||
|
base.Init();
|
|||
|
btn_Close.onClick.AddListener(ClickClose);
|
|||
|
}
|
|||
|
|
|||
|
public override void Dispose()
|
|||
|
{
|
|||
|
base.Dispose();
|
|||
|
btn_Close.onClick.RemoveListener(ClickClose);
|
|||
|
}
|
|||
|
|
|||
|
public override void Open()
|
|||
|
{
|
|||
|
base.Open();
|
|||
|
InitItem();
|
|||
|
}
|
|||
|
|
|||
|
private void ClickClose()
|
|||
|
{
|
|||
|
UIManager.Instance.OpenPanel(PanelType.Home);
|
|||
|
Close();
|
|||
|
}
|
|||
|
|
|||
|
void InitItem()
|
|||
|
{
|
|||
|
List<SummaryInfo> cache = new List<SummaryInfo>(GlobalManager.Instance.list);
|
|||
|
|
|||
|
foreach (var summaryInfo in cache)
|
|||
|
{
|
|||
|
var cultrueDataInfo = ExcelManager.Instance.GetCultrueInfo;
|
|||
|
summaryInfo.culture = cultrueDataInfo.cultureName;
|
|||
|
}
|
|||
|
|
|||
|
// 排个序
|
|||
|
// var list = cache.OrderBy(t => t.id).ToList();
|
|||
|
var list = cache.OrderBy(t => t.id).ToList();
|
|||
|
// cache.Sort((a, b) => a.id.CompareTo(b.id));
|
|||
|
|
|||
|
StringBuilder sb = new StringBuilder();
|
|||
|
|
|||
|
foreach (var summaryInfo in cache)
|
|||
|
{
|
|||
|
item.SetActive(false);
|
|||
|
GenItem(summaryInfo.id.ToString(), summaryInfo.culture);
|
|||
|
sb.AppendLine($"选手ID:{summaryInfo.id}");
|
|||
|
sb.AppendLine($"选手文化元素:{summaryInfo.culture}");
|
|||
|
sb.AppendLine($"\n");
|
|||
|
}
|
|||
|
|
|||
|
FileManager.Instance.SavePlayerTeamData(sb.ToString());
|
|||
|
}
|
|||
|
|
|||
|
// void Mao(ref List<string>)
|
|||
|
// {
|
|||
|
//
|
|||
|
// }
|
|||
|
|
|||
|
private void GenItem(string id, string culture)
|
|||
|
{
|
|||
|
var go = GameObject.Instantiate(item, item.transform.parent);
|
|||
|
go.name = id;
|
|||
|
var txt_ID = go.transform.Find("txt_ID").GetComponent<Text>();
|
|||
|
var txt_Culture = go.transform.Find("txt_Culture").GetComponent<Text>();
|
|||
|
txt_ID.text = id;
|
|||
|
txt_Culture.text = culture;
|
|||
|
go.SetActive(true);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|