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

minden fasza

parent f5483d64
Branches
No related tags found
No related merge requests found
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment