diff --git a/Assets/Scripts/PlayFabConn/PlayFabGetLeaderboard.cs b/Assets/Scripts/PlayFabConn/PlayFabGetLeaderboard.cs index ffcdcdd4ae8c41d92e54e851d2fd680a0ee31cb1..ad39f188bfa4dfa0d7261ea55d4ce2be3e545d41 100644 --- a/Assets/Scripts/PlayFabConn/PlayFabGetLeaderboard.cs +++ b/Assets/Scripts/PlayFabConn/PlayFabGetLeaderboard.cs @@ -1,5 +1,7 @@ +using System; using System.Collections; using System.Collections.Generic; +using System.Security.Cryptography; using PlayFab; using PlayFab.ClientModels; using UnityEngine; @@ -13,6 +15,7 @@ public class PlayFabGetLeaderboard : MonoBehaviour { [SerializeField] private GameObject rowPrefab; public bool loggedIn = false; private bool leaderboardGotten = false; + private bool myDataGotten = false; private int datasRecived = 0; private string LocalPlayer_PlayFabId = "NotSet"; private Dictionary<string, Dictionary<string, string>> playerList; @@ -74,13 +77,16 @@ public class PlayFabGetLeaderboard : MonoBehaviour { leaderboardGotten = false; var request = new GetLeaderboardRequest { StatisticName = "Score", - StartPosition = 0 + MaxResultsCount = 100 }; PlayFabClientAPI.GetLeaderboard(request, result => { foreach (var item in result.Leaderboard) { playerList.Add(item.PlayFabId, new Dictionary<string, string>()); playerList[item.PlayFabId].Add("Score", item.StatValue.ToString()); + playerList[item.PlayFabId].Add("Rank", (item.Position + 1).ToString()); + if (item.PlayFabId.Equals(LocalPlayer_PlayFabId)) + Debug.Log("Bastard"); } leaderboardGotten = true; @@ -132,21 +138,15 @@ public class PlayFabGetLeaderboard : MonoBehaviour { hasPlayer = true; var datas = player.Value; - AppendTableRow(datas["Name"], datas["Color"], datas["Score"]); + AppendTableRow(datas["Rank"], datas["Name"], datas["Color"], datas["Score"]); i++; } - - if (!hasPlayer) { - var datas = playerList[LocalPlayer_PlayFabId]; - AppendTableRow(datas["Name"], datas["Color"], datas["Score"]); - } - } - void AppendTableRow(string playerName, string color, string score) { + void AppendTableRow(string rank, string playerName, string color, string score) { GameObject row = Instantiate(rowPrefab, table); Text[] texts = row.GetComponentsInChildren<Text>(); Image image = row.GetComponentInChildren<Image>(); - texts[0].text = playerName; + texts[0].text = $"{rank}. {playerName}"; texts[1].text = score; Color tmpColor = Color.magenta; if ("red".Equals(color)) { @@ -163,7 +163,4 @@ public class PlayFabGetLeaderboard : MonoBehaviour { image.color = tmpColor; } - public void SendPlayerData() { - - } } \ No newline at end of file