public int GetAchievementProgressInSteps(UM_Achievement achievement)
    {
        if (achievement == null)
        {
            Debug.LogError("Achievement is null. No progress can be retrieved.");
            return(0);
        }

        switch (Application.platform)
        {
        case RuntimePlatform.IPhonePlayer:
            float percentage = GameCenterManager.GetAchievementProgress(achievement.IOSId);
            return(Mathf.CeilToInt(((float)achievement.Steps / 100f) * percentage));

        case RuntimePlatform.Android:
            GPAchievement a = GooglePlayManager.Instance.GetAchievement(achievement.AndroidId);
            if (a != null)
            {
                if (a.Type == GPAchievementType.TYPE_INCREMENTAL)
                {
                    return(a.CurrentSteps);
                }
                else
                {
                    return((a.State == GPAchievementState.STATE_UNLOCKED) ? 1 : 0);
                }
            }
            break;
        }

        return(0);
    }
    public float GetAchievementProgress(UM_Achievement achievement)
    {
        if (achievement == null)
        {
            return(0f);
        }

        switch (Application.platform)
        {
        case RuntimePlatform.IPhonePlayer:
            return(GameCenterManager.GetAchievementProgress(achievement.IOSId));

        case RuntimePlatform.Android:
            if (UltimateMobileSettings.Instance.PlatformEngine == UM_PlatformDependencies.Amazon)
            {
                GC_Achievement ach = SA_AmazonGameCircleManager.Instance.GetAchievement(achievement.AmazonId);
                if (ach != null)
                {
                    return(ach.Progress);
                }
            }
            else
            {
                GPAchievement a = GooglePlayManager.Instance.GetAchievement(achievement.AndroidId);
                if (a != null)
                {
                    if (a.Type == GPAchievementType.TYPE_INCREMENTAL)
                    {
                        return(((float)a.CurrentSteps / a.TotalSteps) * 100f);
                    }
                    else
                    {
                        if (a.State == GPAchievementState.STATE_UNLOCKED)
                        {
                            return(100f);
                        }
                        else
                        {
                            return(0f);
                        }
                    }
                }
            }
            break;
        }

        return(0f);
    }
    public int GetAchievementProgressInSteps(UM_Achievement achievement)
    {
        if (achievement == null)
        {
            Debug.LogError("Achievement is null. No progress can be retrieved.");
            return(0);
        }

        switch (Application.platform)
        {
        case RuntimePlatform.IPhonePlayer:
            float percentage = GameCenterManager.GetAchievementProgress(achievement.IOSId);
            return(Mathf.CeilToInt(((float)achievement.Steps / 100f) * percentage));

        case RuntimePlatform.Android:
            if (UltimateMobileSettings.Instance.PlatformEngine == UM_PlatformDependencies.Amazon)
            {
                GC_Achievement ac = SA_AmazonGameCircleManager.Instance.GetAchievement(achievement.AmazonId);
                if (ac != null)
                {
                    return(Mathf.CeilToInt(((float)achievement.Steps / 100f) * ac.Progress));
                }
            }
            else
            {
                GPAchievement a = GooglePlayManager.Instance.GetAchievement(achievement.AndroidId);
                if (a != null)
                {
                    if (a.Type == GPAchievementType.TYPE_INCREMENTAL)
                    {
                        return(a.CurrentSteps);
                    }
                    else
                    {
                        return((a.State == GPAchievementState.STATE_UNLOCKED) ? 1 : 0);
                    }
                }
            }
            break;
        }

        return(0);
    }
Beispiel #4
0
    public float GetAchievementProgress(UM_Achievement achievement)
    {
        if (achievement == null)
        {
            return(0f);
        }

        switch (Application.platform)
        {
        case RuntimePlatform.IPhonePlayer:
            return(GameCenterManager.GetAchievementProgress(achievement.IOSId));

        case RuntimePlatform.Android:

            GPAchievement a = GooglePlayManager.instance.GetAchievement(achievement.AndroidId);
            if (a != null)
            {
                if (a.type == GPAchievementType.TYPE_INCREMENTAL)
                {
                    return((a.currentSteps / a.totalSteps) * 100f);
                }
                else
                {
                    if (a.state == GPAchievementState.STATE_UNLOCKED)
                    {
                        return(100f);
                    }
                    else
                    {
                        return(0f);
                    }
                }
            }
            break;
        }

        return(0f);
    }
Beispiel #5
0
    //--------------------------------------
    //  PUBLIC METHODS
    //--------------------------------------

    void OnGUI()
    {
        UpdateToStartPos();

        if (GameCenterManager.Player != null)
        {
            GUI.Label(new Rect(100, 10, Screen.width, 40), "ID: " + GameCenterManager.Player.Id);
            GUI.Label(new Rect(100, 20, Screen.width, 40), "Name: " + GameCenterManager.Player.DisplayName);
            GUI.Label(new Rect(100, 30, Screen.width, 40), "Alias: " + GameCenterManager.Player.Alias);


            //avatar loading will take a while after the user is connectd
            //so we will draw it only after instantiation to avoid null pointer check
            //if you whant to know exaxtly when the avatar is loaded, you can subscribe on
            //GameCenterManager.OnUserInfoLoaded action
            //and checl for a spesific user ID
            if (GameCenterManager.Player.SmallPhoto != null)
            {
                GUI.DrawTexture(new Rect(10, 10, 75, 75), GameCenterManager.Player.SmallPhoto);
            }
        }

        StartY += YLableStep;
        StartY += YLableStep;
        StartY += YLableStep;


        GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Game Center Leaderboards", style);


        StartY += YLableStep;

        if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Show Leaderboards"))
        {
            GameCenterManager.ShowLeaderboards();
        }

        StartX += XButtonStep;
        if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Load Sets Info"))
        {
            GameCenterManager.OnLeaderboardSetsInfoLoaded += OnLeaderboardSetsInfoLoaded;
            GameCenterManager.LoadLeaderboardSetInfo();
        }

        StartX  = XStartPos;
        StartY += YButtonStep;
        if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Show Leaderboard 1"))
        {
            GameCenterManager.ShowLeaderboard(leaderBoardId_1);
        }

        StartX += XButtonStep;
        if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Report Score LB 1"))
        {
            hiScore++;
            GameCenterManager.ReportScore(hiScore, leaderBoardId_1);
        }

        StartX += XButtonStep;
        if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Get Score LB 1"))
        {
            GameCenterManager.LoadLeaderboardInfo(leaderBoardId_1);
        }


        StartX  = XStartPos;
        StartY += YButtonStep;

        StartY += YLableStep;
        GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Leaderboard #2, user best score: " + LB2BestScores.ToString(), style);


        StartY += YLableStep;
        if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Show Leader Board2"))
        {
            GameCenterManager.ShowLeaderboard(leaderBoardId_2);
        }


        StartX += XButtonStep;
        if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Show Leaderboard 2 Today"))
        {
            GameCenterManager.ShowLeaderboard(leaderBoardId_2, GK_TimeSpan.TODAY);
        }

        StartX += XButtonStep;
        if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Report Score LB2"))
        {
            hiScore++;

            GameCenterManager.OnScoreSubmitted += OnScoreSubmitted;
            GameCenterManager.ReportScore(hiScore, leaderBoardId_2);
        }


        StartX += XButtonStep;
        if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Get Score LB 2"))
        {
            GameCenterManager.LoadLeaderboardInfo(leaderBoardId_2);
        }


        StartX += XButtonStep;
        if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Send Challenge"))
        {
            GameCenterManager.IssueLeaderboardChallenge(leaderBoardId_2, "Here's a tiny challenge for you");
        }



        StartX  = XStartPos;
        StartY += YButtonStep;
        StartY += YLableStep;
        GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Game Center Achievements", style);

        StartY += YLableStep;
        if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Show Achievements"))
        {
            GameCenterManager.ShowAchievements();
        }

        StartX += XButtonStep;
        if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Reset Achievements"))
        {
            GameCenterManager.ResetAchievements();
        }

        StartX += XButtonStep;
        if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Submit Achievements1"))
        {
            GameCenterManager.SubmitAchievement(GameCenterManager.GetAchievementProgress(TEST_ACHIEVEMENT_1_ID) + 2.432f, TEST_ACHIEVEMENT_1_ID);
        }

        StartX += XButtonStep;
        if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Submit Achievements2"))
        {
            GameCenterManager.SubmitAchievement(88.66f, TEST_ACHIEVEMENT_2_ID, false);
        }

        StartX += XButtonStep;
        if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Send Challenge"))
        {
            GameCenterManager.IssueAchievementChallenge(TEST_ACHIEVEMENT_1_ID, "Here's a tiny challenge for you");
        }



        StartX  = XStartPos;
        StartY += YButtonStep;
        StartY += YLableStep;
        GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "More", style);

        StartY += YLableStep;
        if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Retrieve Signature"))
        {
            GameCenterManager.RetrievePlayerSignature();
            GameCenterManager.OnPlayerSignatureRetrieveResult += OnPlayerSignatureRetrieveResult;
        }
    }
 public void SubmitAchievement()
 {
     Debug.Log("SubmitAchievement");
     GameCenterManager.SubmitAchievement(GameCenterManager.GetAchievementProgress(TEST_ACHIEVEMENT_1_ID) + 2.432f, TEST_ACHIEVEMENT_1_ID);
 }