Skip to content
Snippets Groups Projects
Commit bb2fb579 authored by benxidosz's avatar benxidosz
Browse files

minden fasza

parent f5483d64
No related branches found
No related tags found
No related merge requests found
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Security.Cryptography;
using PlayFab; using PlayFab;
using PlayFab.ClientModels; using PlayFab.ClientModels;
using UnityEngine; using UnityEngine;
...@@ -13,6 +15,7 @@ public class PlayFabGetLeaderboard : MonoBehaviour { ...@@ -13,6 +15,7 @@ public class PlayFabGetLeaderboard : MonoBehaviour {
[SerializeField] private GameObject rowPrefab; [SerializeField] private GameObject rowPrefab;
public bool loggedIn = false; public bool loggedIn = false;
private bool leaderboardGotten = false; private bool leaderboardGotten = false;
private bool myDataGotten = false;
private int datasRecived = 0; private int datasRecived = 0;
private string LocalPlayer_PlayFabId = "NotSet"; private string LocalPlayer_PlayFabId = "NotSet";
private Dictionary<string, Dictionary<string, string>> playerList; private Dictionary<string, Dictionary<string, string>> playerList;
...@@ -74,13 +77,16 @@ public class PlayFabGetLeaderboard : MonoBehaviour { ...@@ -74,13 +77,16 @@ public class PlayFabGetLeaderboard : MonoBehaviour {
leaderboardGotten = false; leaderboardGotten = false;
var request = new GetLeaderboardRequest { var request = new GetLeaderboardRequest {
StatisticName = "Score", StatisticName = "Score",
StartPosition = 0 MaxResultsCount = 100
}; };
PlayFabClientAPI.GetLeaderboard(request, PlayFabClientAPI.GetLeaderboard(request,
result => { result => {
foreach (var item in result.Leaderboard) { foreach (var item in result.Leaderboard) {
playerList.Add(item.PlayFabId, new Dictionary<string, string>()); playerList.Add(item.PlayFabId, new Dictionary<string, string>());
playerList[item.PlayFabId].Add("Score", item.StatValue.ToString()); 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; leaderboardGotten = true;
...@@ -132,21 +138,15 @@ public class PlayFabGetLeaderboard : MonoBehaviour { ...@@ -132,21 +138,15 @@ public class PlayFabGetLeaderboard : MonoBehaviour {
hasPlayer = true; hasPlayer = true;
var datas = player.Value; var datas = player.Value;
AppendTableRow(datas["Name"], datas["Color"], datas["Score"]); AppendTableRow(datas["Rank"], datas["Name"], datas["Color"], datas["Score"]);
i++; 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); GameObject row = Instantiate(rowPrefab, table);
Text[] texts = row.GetComponentsInChildren<Text>(); Text[] texts = row.GetComponentsInChildren<Text>();
Image image = row.GetComponentInChildren<Image>(); Image image = row.GetComponentInChildren<Image>();
texts[0].text = playerName; texts[0].text = $"{rank}. {playerName}";
texts[1].text = score; texts[1].text = score;
Color tmpColor = Color.magenta; Color tmpColor = Color.magenta;
if ("red".Equals(color)) { if ("red".Equals(color)) {
...@@ -163,7 +163,4 @@ public class PlayFabGetLeaderboard : MonoBehaviour { ...@@ -163,7 +163,4 @@ public class PlayFabGetLeaderboard : MonoBehaviour {
image.color = tmpColor; image.color = tmpColor;
} }
public void SendPlayerData() {
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment