Ejemplo n.º 1
0
    public void Initialize(PlayerLeaderboardEntry entry, bool isMyself)
    {
        rankText.text  = (entry.Position + 1).ToString();
        nameText.text  = nameInputField.text = entry.DisplayName;
        scoreText.text = string.Format(scoreFormat, entry.StatValue);
        if (entry.StatValue < 0)
        {
            scoreText.color = minusScoreColor;
        }

        nameText.gameObject.SetActive(false);
        inputNameButton.gameObject.SetActive(false);
        nameInputField.gameObject.SetActive(false);
        nameInputField.text = entry.DisplayName;
        updateNameButton.gameObject.SetActive(false);
        updateNameButton.interactable = false;
        if (isMyself)
        {
            baseImage.color = mySelfBaseColor;
            if (string.IsNullOrEmpty(nameText.text))
            {
                nameInputField.gameObject.SetActive(true);
                updateNameButton.gameObject.SetActive(true);
            }
            else
            {
                nameText.gameObject.SetActive(true);
                inputNameButton.gameObject.SetActive(true);
            }
        }
        else
        {
            nameText.gameObject.SetActive(true);
        }
    }
Ejemplo n.º 2
0
    public void GetLeaderBoard()
    {
        PlayerStatiticsName = inputPlayerStatitics.text;

        GetLeaderboardRequest rq = new GetLeaderboardRequest()
        {
            StartPosition = 1,
            StatisticName = PlayerStatiticsName
        };

        PlayFabClientAPI.GetLeaderboard(rq, (result) =>
        {
            result.Version = 0;

            for (int i = 0; i < result.Leaderboard.Count; i++)
            {
                PlayerLeaderboardEntry entry = result.Leaderboard[i];

                LeaderboardResult.text = entry.Position + " " + entry.DisplayName + " " + entry.StatValue + "\n";
                notify.text            = "Get LeaderBoard Success!";
            }
        },

                                        (error) =>
        {
            notify.text = error.ErrorMessage;
        });
    }
        private IEnumerator AddToTopCoroutine()
        {
            if (this.coroutineRunning)
            {
                yield break;
            }

            this.coroutineRunning   = true;
            this.ScrollRect.enabled = false;

            if (this.entries.Count > 0)
            {
                PlayerLeaderboardEntry firstEntry = this.entries[0];

                // Making sure we're not already at the top
                if (firstEntry.Position != 0)
                {
                    int position = Mathf.Max(firstEntry.Position - this.maxResultsCount - 1, 0);

                    yield return(this.RefreshLeaderboardCoroutine(position));
                }
            }

            this.coroutineRunning   = false;
            this.ScrollRect.enabled = true;
            this.DisableLoadingIndicators();
        }
Ejemplo n.º 4
0
    private void ShowRankingContent(List <PlayerLeaderboardEntry> rankings, PlayerLeaderboardEntry myPlayerRanking)
    {
        if (rankings == null)
        {
            return;
        }

        loadingRankingsText.gameObject.SetActive(false);
        rankingsShowTween = Go.to(rankingContentCanvasGroup, 0.4f, new GoTweenConfig().floatProp("alpha", 1f));

        for (int i = 0; i < playerRankingViews.Count; i++)
        {
            if (i < rankings.Count)
            {
                playerRankingViews[i].gameObject.SetActive(true);
                playerRankingViews[i].Refresh(rankings[i]);
            }
            else
            {
                playerRankingViews[i].gameObject.SetActive(false);
            }
        }

        myPlayerRankingView.Refresh(myPlayerRanking, true);

        var h = 0f;

        if (rankings.Count > 0)
        {
            h = playerRankingViews[0].Height * rankings.Count + rankingViewsLayoutGroup.spacing * (rankings.Count - 1);
        }
        rankingViewsContainer.sizeDelta = new Vector2(rankingViewsContainer.sizeDelta.x, h);
        rankingScrollRect.verticalNormalizedPosition = 1;
    }
Ejemplo n.º 5
0
    private void UpdateLeaderboardTable()
    {
        //set initial data in Player Score entry. Set here first in case it is not found in the leaderboard
        if (playerScoreEntry != null)
        {
            playerScoreEntry.SetScore(
                "--",
                FixUserName(playerProfile),
                "--");
        }

        PlayFabClientAPI.GetLeaderboard
        (
            new GetLeaderboardRequest {
            StartPosition = 0, MaxResultsCount = highscoreEntryNumber, StatisticName = statisticName
        },
            result =>
        {
            //Debug.Log("Updated leaderboard for: " + statisticName);
            for (int i = 0; i < entries.Count; i++)
            {
                if (i < result.Leaderboard.Count)
                {
                    PlayerLeaderboardEntry data = result.Leaderboard[i];

                    //set entry
                    entries[i].SetScore(
                        (data.Position + 1) + ".",
                        FixUserName(data.Profile),
                        data.StatValue.ToString());

                    //assign player values based on leaderboard if found
                    if (result.Leaderboard[i].PlayFabId == playerProfile.PlayerId)
                    {
                        playerScoreEntry.rankText.text = i + 1 + "";
                        playerScoreEntry.SetScore(
                            (data.Position + 1) + ".",
                            FixUserName(playerProfile),
                            data.StatValue.ToString());
                    }
                }
                //set as empty entry
                else
                {
                    entries[i].SetScore(
                        (i + 1) + ".",
                        "--|--",
                        "--");
                }
            }
        },
            error =>
        {
            Debug.Log("Error getting High Scores");
            Debug.Log(error.GenerateErrorReport());
        }

        );
    }
 private void OnGetLeaderboard(GetLeaderboardResult result)
 {
     _leaderboardView.Clear();
     for (int i = 0; i < result.Leaderboard.Count; i++)
     {
         PlayerLeaderboardEntry entry = result.Leaderboard[i];
         int             position     = entry.Position + 1;
         LeaderboardItem item         = new LeaderboardItem(position, entry.DisplayName, entry.StatValue);
         _leaderboardView.AddItem(item);
     }
 }
Ejemplo n.º 7
0
    public void Initialize(PlayerLeaderboardEntry entry)
    {
        var isMyEntry = (PlayFabLoginManagerSingleton.Instance.PlayFabId == entry.PlayFabId);

        defaultBackground.SetActive(!isMyEntry);
        playerBackground.SetActive(isMyEntry);

        rank.text       = (entry.Position + 1).ToString();
        playerName.text = entry.DisplayName;
        score.text      = entry.StatValue.ToString();
    }
Ejemplo n.º 8
0
    public static void GetRankings(int index, Action <List <PlayerLeaderboardEntry>, PlayerLeaderboardEntry> callback)
    {
        // Reset the list
        topPlayersList     = null;
        localPlayerRanking = null;

        var request = new GetLeaderboardRequest
        {
            StatisticName   = PlayerData.HighScoreKey,
            StartPosition   = 0,
            MaxResultsCount = 100
        };

        PlayFabClientAPI.GetLeaderboard(request,
                                        result =>
        {
            topPlayersList = result.Leaderboard;
            if (topPlayersList != null && localPlayerRanking != null)
            {
                callback(topPlayersList, localPlayerRanking);
            }
        },
                                        error =>
        {
            Debug.LogWarning("Something went wrong with GetRankings :(");
            Debug.LogError(error.GenerateErrorReport());
        }
                                        );

        var localPlayerRequest = new GetLeaderboardAroundPlayerRequest
        {
            StatisticName   = PlayerData.HighScoreKey,
            MaxResultsCount = 1,
        };

        PlayFabClientAPI.GetLeaderboardAroundPlayer(localPlayerRequest,
                                                    result =>
        {
            localPlayerRanking = result.Leaderboard[0];
            if (topPlayersList != null && localPlayerRanking != null)
            {
                callback(topPlayersList, localPlayerRanking);
            }
        },
                                                    error =>
        {
            Debug.LogWarning("Something went wrong with GetRankings local player :(");
            Debug.LogError(error.GenerateErrorReport());
        }
                                                    );
    }
Ejemplo n.º 9
0
    public void Populate(PlayerLeaderboardEntry myInfo)
    {
        positionTxt.text = (myInfo.Position + 1).ToString();
        nameTxt.text     = myInfo.DisplayName;
        killsTxt.text    = myInfo.StatValue + " kills";

        GetUserDataRequest request = new GetUserDataRequest();

        request.PlayFabId = myInfo.PlayFabId;
        request.Keys      = new List <string>();
        request.Keys.Add(GameConstants.facebookPictureKey);

        PlayFabClientAPI.GetUserData(request, OnPlayerInfoLoaded, OnPlayerInfoLoadError);
    }
    /// <summary>
    /// populates with player display name and score value
    /// </summary>
    /// <param name="result"></param>
    private void OnGetLeaderBoard(GetLeaderboardResult result)
    {
        leaderboardPanel.SetActive(true);
        mainMenuItems.SetActive(false);

        for (int i = 0; i < 100; i++)
        {
            if (i < result.Leaderboard.Count)
            {
                PlayerLeaderboardEntry player = result.Leaderboard[i];


                GameObject         tempListing        = Instantiate(listingPrefab, listingContainer);
                LeaderboardListing leaderboardListing = tempListing.GetComponent <LeaderboardListing>();
                LeaderboardListing playerStatsListing = playerLeaderboardListing.GetComponent <LeaderboardListing>();

                if (player.DisplayName == null)
                {
                    Destroy(tempListing);
                    debugReporter.text = debugReporter.text + "\n" + "Null player name destroyed";
                }
                else
                {
                    if (player.PlayFabId == Auth.playFabId)
                    {
                        playerStatsListing.playerName.text  = player.DisplayName.ToString();
                        playerStatsListing.playerScore.text = player.StatValue.ToString();
                        playerStatsListing.playerRank.text  = (player.Position + 1).ToString();

                        leaderboardListing.playerName.text  = player.DisplayName.ToString();
                        leaderboardListing.playerScore.text = player.StatValue.ToString();
                        leaderboardListing.playerRank.text  = (player.Position + 1).ToString();

                        leaderboardListing.playerName.font  = currentUserDisplayFont;
                        leaderboardListing.playerScore.font = currentUserDisplayFont;
                        leaderboardListing.playerRank.font  = currentUserDisplayFont;
                    }
                    else
                    {
                        leaderboardListing.playerName.text  = player.DisplayName.ToString();
                        leaderboardListing.playerScore.text = player.StatValue.ToString();
                        leaderboardListing.playerRank.text  = (player.Position + 1).ToString();
                    }
                }
            }
        }

        loadingAnimation.SetActive(false);
    }
Ejemplo n.º 11
0
        public static RankingUser CreateFromPlayerLeaderboardEntry(PlayerLeaderboardEntry entry)
        {
            var friendUser = new RankingUser
            {
                PlayFabId         = entry.PlayFabId,
                Name              = entry.DisplayName,
                Position          = entry.Position + 1, // ポジションは順位を表すが 0 始まりなので +1 しておく
                StatValue         = entry.StatValue,
                Level             = entry.Profile.Statistics?.FirstOrDefault(x => x.Name == "Level")?.Value ?? 1,
                LastLoginDateTime = entry.Profile.LastLogin ?? DateTime.Now,
                CharacterId       = $"character-{string.Format("{0:D8}", entry.Profile.Statistics?.FirstOrDefault(x => x.Name == "CharacterId")?.Value ?? 1)}",
                CharacterLevel    = entry.Profile.Statistics?.FirstOrDefault(x => x.Name == "CharacterLevel")?.Value ?? 1
            };

            return(friendUser);
        }
        private IEnumerator AddToBottomCoroutine()
        {
            if (this.coroutineRunning)
            {
                yield break;
            }

            this.coroutineRunning   = true;
            this.ScrollRect.enabled = false;

            if (this.entries.Count > 0)
            {
                PlayerLeaderboardEntry lastEntry = this.entries[this.entries.Count - 1];
                yield return(this.RefreshLeaderboardCoroutine(lastEntry.Position + 1));
            }

            this.coroutineRunning   = false;
            this.ScrollRect.enabled = true;
            this.DisableLoadingIndicators();
        }
Ejemplo n.º 13
0
    public void Refresh(PlayerLeaderboardEntry playerRanking, bool isHeader = false)
    {
        if (playerRanking == null)
        {
            playerNameText.text  = "?. Unknown";
            playerScoreText.text = "?";
            backImage.color      = normalColor;
            return;
        }

        var name = playerRanking.DisplayName ?? playerRanking.PlayFabId;

        playerNameText.text  = (playerRanking.Position + 1) + ". " + name;
        playerScoreText.text = playerRanking.StatValue.ToString();

        playerScoreText.gameObject.SetActive(!isHeader);
        editPlayerButton.gameObject.SetActive(isHeader);

        backImage.color = playerRanking.PlayFabId == PlayerData.PlayFabId ? localPlayerColor : normalColor;
    }
Ejemplo n.º 14
0
    // NetMgr playfab 유저리스트에서 비교
    void GetLeaderboard(string myID)
    {
        // -비우기   로그인 다시할때 필요
        PlayFabUserList.Clear();

        // 1000명까지 가능
        for (int i = 0; i < 10; i++)
        {
            var request = new GetLeaderboardRequest
            {
                StartPosition      = i * 100,
                StatisticName      = "IDInfo",
                MaxResultsCount    = 100,
                ProfileConstraints = new PlayerProfileViewConstraints()
                {
                    ShowDisplayName = true
                }
            };

            //호출결과를 리더보드에 넣
            PlayFabClientAPI.GetLeaderboard(request, (result) =>
            {
                if (result.Leaderboard.Count == 0)
                {
                    return;
                }
                for (int j = 0; j < result.Leaderboard.Count; j++)
                {
                    // -채우기 ( 플레이어 리더보드 엔트리 )
                    PlayFabUserList.Add(result.Leaderboard[j]);
                    if (result.Leaderboard[j].PlayFabId == myID)
                    {
                        MyPlayFabInfo = result.Leaderboard[j];
                    }
                }
            },
                                            (error) => { });
        }
    }
    /// <summary>
    /// Also displays the player in the end if player is not found in top 100
    /// </summary>
    /// <param name="result"></param>
    private void OnGetLeaderBoardAroundPlayer(GetLeaderboardAroundPlayerResult result)
    {
        debugReporter.text = debugReporter.text + "\n" + "OnGetLeaderBoardAroundPlayer() : Success leaderboard retrieve";

        PlayerLeaderboardEntry player = new PlayerLeaderboardEntry();

        for (int i = 0; i < result.Leaderboard.Count; i++)
        {
            if (Auth.playFabId == result.Leaderboard[i].PlayFabId.ToString())
            {
                player = result.Leaderboard[i];
                PlayerPrefs.SetInt(PlayerPrefsStrings.playerAccountHighscore, player.StatValue);
            }
        }

        LeaderboardListing playerStatsListing = playerLeaderboardListing.GetComponent <LeaderboardListing>();

        playerStatsListing.playerName.text  = player.DisplayName.ToString();
        playerStatsListing.playerScore.text = player.StatValue.ToString();
        playerStatsListing.playerRank.text  = (player.Position + 1).ToString();

        loadingAnimation.SetActive(false);
    }
Ejemplo n.º 16
0
 string GetDisplayName(PlayerLeaderboardEntry boardEntry)
 => string.IsNullOrWhiteSpace(boardEntry.DisplayName) ? "(no name)" : boardEntry.DisplayName;
 protected abstract void ShowLeaderboardEntry(T item, PlayerLeaderboardEntry entry, bool isCurrentPlayer);
        private void ShowItem(T item, int index)
        {
            PlayerLeaderboardEntry entry = this.entries[index];

            this.ShowLeaderboardEntry(item, entry, entry.PlayFabId == PlayFab.PlayFabManager.Instance.User.PlayFabId);
        }
Ejemplo n.º 19
0
        private void ShowItem(T item, int index)
        {
            PlayerLeaderboardEntry entry = entries[index];

            ShowLeaderboardEntry(item, entry, entry.PlayFabId == PF.User.PlayFabId);
        }