public void LoadTopScores(UM_Leaderboard leaderboard, int maxResults, UM_TimeSpan timeSpan = UM_TimeSpan.ALL_TIME, UM_CollectionType collection = UM_CollectionType.GLOBAL)
    {
        if (leaderboard == null)
        {
            return;
        }

        switch (Application.platform)
        {
        case RuntimePlatform.IPhonePlayer:
            GameCenterManager.LoadScore(leaderboard.IOSId, 1, maxResults, timeSpan.Get_GK_TimeSpan(), collection.Get_GK_CollectionType());
            break;

        case RuntimePlatform.Android:
            if (UltimateMobileSettings.Instance.PlatformEngine == UM_PlatformDependencies.Amazon)
            {
                SA_AmazonGameCircleManager.Instance.LoadTopScores(leaderboard.AmazonId, timeSpan.Get_GC_TimeSpan());
            }
            else
            {
                GooglePlayManager.Instance.LoadTopScores(leaderboard.AndroidId, timeSpan.Get_GP_TimeSpan(), collection.Get_GP_CollectionType(), maxResults);
            }
            break;
        }
    }
    public void LoadPlayerCenteredScores(UM_Leaderboard leaderboard, int maxResults, UM_TimeSpan timeSpan = UM_TimeSpan.ALL_TIME, UM_CollectionType collection = UM_CollectionType.GLOBAL)
    {
        if (leaderboard == null)
        {
            return;
        }

        switch (Application.platform)
        {
        case RuntimePlatform.IPhonePlayer:

            UM_Score score = GetCurrentPlayerScore(leaderboard, timeSpan, collection);
            int      rank  = 0;
            if (score != null)
            {
                rank = score.Rank;
            }

            int startIndex = Math.Max(1, rank - maxResults / 2);
            int endIndex   = startIndex + maxResults - 1;
            GameCenterManager.LoadScore(leaderboard.IOSId, startIndex, endIndex, timeSpan.Get_GK_TimeSpan(), collection.Get_GK_CollectionType());
            break;

        case RuntimePlatform.Android:
            if (UltimateMobileSettings.Instance.PlatformEngine == UM_PlatformDependencies.Amazon)
            {
                //Just do nothing for Amazon
            }
            else
            {
                GooglePlayManager.Instance.LoadPlayerCenteredScores(leaderboard.AndroidId, timeSpan.Get_GP_TimeSpan(), collection.Get_GP_CollectionType(), maxResults);
            }
            break;
        }
    }
    public void LoadPlayerCenteredScores(UM_Leaderboard leaderboard, int maxResults, UM_TimeSpan timeSpan = UM_TimeSpan.ALL_TIME, UM_CollectionType collection = UM_CollectionType.GLOBAL)
    {
        if (leaderboard == null)
        {
            return;
        }

        switch (Application.platform)
        {
        case RuntimePlatform.IPhonePlayer:

            UM_Score score = GetCurrentPlayerScore(leaderboard, timeSpan, collection);
            int      rank  = 0;
            if (score != null)
            {
                rank = score.Rank;
            }

            int startIndex = Math.Max(0, rank - maxResults / 2);
            GameCenterManager.LoadScore(leaderboard.IOSId, startIndex, maxResults, timeSpan.Get_GK_TimeSpan(), collection.Get_GK_CollectionType());



            break;

        case RuntimePlatform.Android:
            GooglePlayManager.Instance.LoadPlayerCenteredScores(leaderboard.AndroidId, timeSpan.Get_GP_TimeSpan(), collection.Get_GP_CollectionType(), maxResults);
            break;
        }
    }
    public void LoadTopScores(UM_Leaderboard leaderboard, int maxResults, UM_TimeSpan timeSpan = UM_TimeSpan.ALL_TIME, UM_CollectionType collection = UM_CollectionType.GLOBAL)
    {
        if (leaderboard == null)
        {
            return;
        }

        switch (Application.platform)
        {
        case RuntimePlatform.IPhonePlayer:
            GameCenterManager.LoadScore(leaderboard.IOSId, 1, maxResults, timeSpan.Get_GK_TimeSpan(), collection.Get_GK_CollectionType());
            break;

        case RuntimePlatform.Android:
            GooglePlayManager.Instance.LoadTopScores(leaderboard.AndroidId, timeSpan.Get_GP_TimeSpan(), collection.Get_GP_CollectionType(), maxResults);
            break;
        }
    }
Пример #5
0
    void OnGUI()
    {
        GUI.Label(new Rect(10, 20, 400, 40), "Custom Leaderboard GUI Example", headerStyle);

        if (GUI.Button(new Rect(400, 10, 150, 50), "Load Friends Scores"))
        {
            GameCenterManager.LoadScore(leaderboardId, 1, 10, GK_TimeSpan.ALL_TIME, GK_CollectionType.FRIENDS);
        }

        if (GUI.Button(new Rect(600, 10, 150, 50), "Load Global Scores"))
        {
            GameCenterManager.LoadScore(leaderboardId, 50, 150, GK_TimeSpan.ALL_TIME, GK_CollectionType.GLOBAL);
        }

        Color defaultColor = GUI.color;

        if (displayCollection == GK_CollectionType.GLOBAL)
        {
            GUI.color = Color.green;
        }
        if (GUI.Button(new Rect(800, 10, 170, 50), "Displaying Global Scores"))
        {
            displayCollection = GK_CollectionType.GLOBAL;
        }
        GUI.color = defaultColor;



        if (displayCollection == GK_CollectionType.FRIENDS)
        {
            GUI.color = Color.green;
        }
        if (GUI.Button(new Rect(800, 70, 170, 50), "Displaying Friends Scores"))
        {
            displayCollection = GK_CollectionType.FRIENDS;
        }
        GUI.color = defaultColor;

        GUI.Label(new Rect(10, 90, 100, 40), "rank", boardStyle);
        GUI.Label(new Rect(100, 90, 100, 40), "score", boardStyle);
        GUI.Label(new Rect(200, 90, 100, 40), "playerId", boardStyle);
        GUI.Label(new Rect(400, 90, 100, 40), "name ", boardStyle);
        GUI.Label(new Rect(550, 90, 100, 40), "avatar ", boardStyle);

        if (loadedLeaderboard != null)
        {
            for (int i = 1; i < 10; i++)
            {
                GK_Score score = loadedLeaderboard.GetScore(i, GK_TimeSpan.ALL_TIME, displayCollection);
                if (score != null)
                {
                    GUI.Label(new Rect(10, 90 + 70 * i, 100, 40), i.ToString(), boardStyle);
                    GUI.Label(new Rect(100, 90 + 70 * i, 100, 40), score.GetLongScore().ToString(), boardStyle);
                    GUI.Label(new Rect(200, 90 + 70 * i, 100, 40), score.playerId, boardStyle);


                    GK_Player player = GameCenterManager.GetPlayerById(score.playerId);
                    if (player != null)
                    {
                        GUI.Label(new Rect(400, 90 + 70 * i, 100, 40), player.Alias, boardStyle);
                        if (player.SmallPhoto != null)
                        {
                            GUI.DrawTexture(new Rect(550, 75 + 70 * i, 50, 50), player.SmallPhoto);
                        }
                        else
                        {
                            GUI.Label(new Rect(550, 90 + 70 * i, 100, 40), "no photo ", boardStyle);
                        }
                    }

                    if (GUI.Button(new Rect(650, 90 + 70 * i, 100, 30), "Challenge"))
                    {
                        GameCenterManager.IssueLeaderboardChallenge(leaderboardId, "Your message here", score.playerId);
                    }
                }
            }
        }
    }