using System.Collections; using System.Collections.Generic; using System.Linq; using LitJson; using NaughtyAttributes; using TMPro; using UnityEngine; public class SettlePanel : MonoBehaviour { public GameObject settlePre; public TextMeshProUGUI text; /// /// 预制体父节点 /// public GameObject Node; public static void Show() { WorldUIManager.Ins.Cover("UI/SettlePanel", false); } public void Start() { // Dictionary tempDictionary = JsonMapper.ToObject>(GameManager.Ins.settleData); // // text.color = Color.yellow; // text.text = "完成"; // // // 创建最终的字典,将 string 转换为 int // Dictionary playerDictionary = new Dictionary(); // foreach (var entry in tempDictionary) // { // // 将键转换为 int // int key = int.Parse(entry.Key); // playerDictionary[key] = entry.Value; // } // var sortedPlayerDictionary = playerDictionary.OrderByDescending(pair => pair.Value.Score) // .ToDictionary(pair => pair.Key, pair => pair.Value); // // 打印排序后的结果 // // int ranking = 0; // foreach (SettleInfo info in sortedPlayerDictionary.Values) // { // bool isShow; // ranking++; // isShow = GameLocal.Ins.self.index == info.playerName ? true : false; // CreateSettleItem("玩家" + info.playerName.ToString(), info.Score, ranking, info.Title, isShow); // // } } public void CreateSettleItem(string playerName, int Score, int Ranking, string Title, bool isShow) { GameObject item = Instantiate(settlePre, Node.transform); item.GetComponent().Init(playerName, Score, Ranking, Title, isShow); } }