public int sortScore(RankingListData a, RankingListData b) { int res = 0; for (int i = 0; i < 4;) { int scoreA = a.m_list[i]; int scoreB = b.m_list[i]; if (i != 2) //deathCount { res = sortScore(scoreA, scoreB, true); } else { res = sortScore(scoreA, scoreB, false); } if (res != 0) { return(res); } else { ++i; } } return(res); }
public void ShowRankingList() { int forCount = 4; List <RankingListData> list = new List <RankingListData>(); for (int i = 0; i < forCount; ++i) { if (RLplayerName[i] != null) { RLplayerName[i].text = playerName[i].text; } List <int> tempList = new List <int>(); if (RLteamScore[i] != null) { RLteamScore[i].text = teamScore[i].text; tempList.Add(int.Parse(RLteamScore[i].text)); } if (RLkillCount[i] != null) { int killCount = GameManager.GetInstance().killCount[i]; RLkillCount[i].text = killCount.ToString(); tempList.Add(killCount); } if (RLdeathCount[i] != null) { int deathCount = GameManager.GetInstance().deathCount[i]; RLdeathCount[i].text = deathCount.ToString(); tempList.Add(deathCount); } if (RLitemCount[i] != null) { int itemCount = GameManager.GetInstance().ItemCount[i]; RLitemCount[i].text = itemCount.ToString(); tempList.Add(itemCount); } RankingListData data = new RankingListData(RLteamScore[i].transform.parent.gameObject, tempList); list.Add(data); } list.Sort(sortScore); for (int i = 0; i < list.Count; ++i) { list[i].m_obj.transform.SetAsFirstSibling(); } gameRankingList.SetActive(true); }