Пример #1
0
    private IEnumerator AnimateRank(Upload upload, int stepCount)
    {
        int          calculatedRank    = -1;
        Score        previousBestScore = null;
        int          previousBestRank  = -1;
        bool         isRankLoaded      = false;
        List <Score> leaderboard       = upload.Leaderboards;

        GameJolt.API.Objects.User currentUser = GameJolt.API.Manager.Instance.CurrentUser;

        bool isUserAuthor = (currentUser.ID == upload.AuthorID);

        GameJolt.API.Misc.GetTime(dateTime => {
            isRankLoaded = true;
            upload.AddToLeaderboard(currentUser, stepCount, dateTime, out calculatedRank, out previousBestScore, out previousBestRank, isSuccess => {
                isRankLoaded = true;
            });
        });
        yield return(new WaitUntil(() => isRankLoaded));

        yield return(Util.AnimateScore(rank, 0, calculatedRank, 0.35f, scoreSound));

        if (previousBestScore != null)
        {
            pastStepsLabel.gameObject.SetActive(true);
            pastStepsLabel.color = Color.yellow;
            pastStepsLabel.text  = string.Format("Old steps: {0}", previousBestScore.Steps);
            pastRankingLabel.gameObject.SetActive(true);
            pastRankingLabel.color = Color.yellow;
            pastRankingLabel.text  = string.Format("Old rank: {0}", previousBestRank);
        }
    }
Пример #2
0
    private IEnumerator AnimateRank(int stepCount)
    {
        int   calculatedRank    = -1;
        Score previousBestScore = null;
        int   previousBestRank  = -1;
        bool  isRankLoaded      = false;

        GameJolt.API.Misc.GetTime(dateTime => {
            if (scoreIDOverride == 0)
            {
                Upload upload            = LevelInfo.Instance.Upload;
                List <Score> leaderboard = upload.Leaderboards;
                GameJolt.API.Objects.User currentUser = GameJolt.API.Manager.Instance.CurrentUser;

                bool isUserAuthor = (currentUser.ID == upload.AuthorID);
                upload.AddToLeaderboard(currentUser, stepCount, dateTime, out calculatedRank, out previousBestScore, out previousBestRank, isSuccess => {
                    isRankLoaded = true;
                });
            }
            else
            {
                GameJolt.API.Scores.GetRank(stepCount, scoreIDOverride, rank => {
                    Debug.Log("Rank load successful: " + rank);
                    calculatedRank = rank - 1;
                    GameJolt.API.Scores.Add(stepCount, stepCount.ToString(), scoreIDOverride);
                    isRankLoaded = true;
                });
            }
        });
        yield return(new WaitUntil(() => isRankLoaded));

        yield return(Util.AnimateScore(rank, 0, calculatedRank, 0.35f, scoreSound));

        if (previousBestScore != null)
        {
            pastStepsLabel.gameObject.SetActive(true);
            pastStepsLabel.color = Color.yellow;
            pastStepsLabel.text  = string.Format("Old steps: {0}", previousBestScore.Steps);
            pastRankingLabel.gameObject.SetActive(true);
            pastRankingLabel.color = Color.yellow;
            pastRankingLabel.text  = string.Format("Old rank: {0}", previousBestRank);
        }
    }