// Méthode de tri du tableau des scores public void triLeaderboard(string type) { Transform g; var loadedData = JSON.Parse(File.ReadAllText(filePath)); if (loadedData["history"].Count != 0) { //Debug.Log("Tri par " + type); for (int i = 0; i < loadedData["history"].Count; i++) { history[i, 0] = loadedData["history"][i][0]; history[i, 1] = loadedData["history"][i][1]; history[i, 2] = loadedData["history"][i][2]; } Array2DSort comparer = null; switch (type) { case "difficulty": g = GameObject.Find("diff").transform.GetChild(0).transform; GameObject.Find("time").transform.GetChild(0).transform.rotation = new Quaternion(0, 0, 0, 0); comparer = new Array2DSort(history, 1); comparer = new Array2DSort(history, 0); break; case "timer": g = GameObject.Find("time").transform.GetChild(0).transform; GameObject.Find("diff").transform.GetChild(0).transform.rotation = new Quaternion(0, 0, 0, 0); comparer = new Array2DSort(history, 1); comparer = new Array2DSort(history, 2); break; default: g = null; break; } g.rotation = Quaternion.Euler(0, 0, 180); string[,] sortedData = comparer.ToSortedArray(); //Tri for (int i = 0; i < loadedData["history"].Count; i++) { history[i, 0] = sortedData[i, 0]; history[i, 1] = sortedData[i, 1]; history[i, 2] = sortedData[i, 2]; } updateLeaderboard(); } }
// Méthode de tri du tableau des scores public void triLeaderboard(string type) { Transform g; var loadedDataS = JSON.Parse(File.ReadAllText(filePathSudoku)); var loadedDataB = JSON.Parse(File.ReadAllText(filePathBingo)); var loadedDataP = JSON.Parse(File.ReadAllText(filePathPoker)); if (taille != 0) { for (int i = 0; i < taille; i++) { GameObject boardTab = GameObject.Find("board" + (i + 1)); history[i, 0] = boardTab.transform.GetChild(5).GetComponent <TextMeshProUGUI>().text; history[i, 1] = boardTab.transform.GetChild(6).GetComponent <TextMeshProUGUI>().text; } Array2DSort comparer = null; switch (type) { case "name": g = GameObject.Find("nomJoueur").transform.GetChild(0).transform; GameObject.Find("score").transform.GetChild(0).transform.rotation = new Quaternion(0, 0, 0, 0); comparer = new Array2DSort(history, 0); break; case "score": g = GameObject.Find("score").transform.GetChild(0).transform; GameObject.Find("nomJoueur").transform.GetChild(0).transform.rotation = new Quaternion(0, 0, 0, 0); comparer = new Array2DSort(history, 1); break; default: g = null; break; } g.rotation = Quaternion.Euler(0, 0, 180); string[,] sortedData = comparer.ToSortedArray(); //Tri for (int i = 0; i < taille; i++) { history[i, 0] = sortedData[i, 0]; history[i, 1] = sortedData[i, 1]; } updateLeaderboard(); } }