Ejemplo n.º 1
0
    public UM_Score(GK_Score gkScore, GPScore gpScore, GC_Score gcScore)
    {
        _GK_Score = gkScore;
        _GP_Score = gpScore;
        _GC_Score = gcScore;
        if (IsValid)
        {
            switch (Application.platform)
            {
            case RuntimePlatform.Android:
                if (UltimateMobileSettings.Instance.PlatformEngine == UM_PlatformDependencies.Amazon)
                {
                    GC_Player gc_player = SA_AmazonGameCircleManager.Instance.GetPlayerById(_GC_Score.PlayerId);
                    player = new UM_Player(null, null, gc_player);
                }
                else
                {
                    GooglePlayerTemplate gp_player = GooglePlayManager.Instance.GetPlayerById(_GP_Score.PlayerId);
                    player = new UM_Player(null, gp_player, null);
                }
                break;

            case RuntimePlatform.IPhonePlayer:
                GK_Player gk_player = GameCenterManager.GetPlayerById(_GK_Score.PlayerId);
                player = new UM_Player(gk_player, null, null);
                break;
            }
        }
    }
Ejemplo n.º 2
0
    public void UpdateScore(GC_Score newScore)
    {
        Dictionary <int, GC_Score> collection;

        switch (newScore.TimeSpan)
        {
        case GC_ScoreTimeSpan.ALL_TIME:
            collection = _AllTimeCollection;
            break;

        case GC_ScoreTimeSpan.WEEK:
            collection = _WeekCollection;
            break;

        case GC_ScoreTimeSpan.TODAY:
            collection = _TodayCollection;
            break;

        default:
            collection = _AllTimeCollection;
            break;
        }

        if (collection.ContainsKey(newScore.Rank))
        {
            collection[newScore.Rank] = newScore;
        }
        else
        {
            collection.Add(newScore.Rank, newScore);
        }
    }
Ejemplo n.º 3
0
    public void UpdateCurrentPlayerScore(GC_Score newScore)
    {
        GC_Score score = GetCurrentPlayerScore(newScore.TimeSpan);

        if (score != null)
        {
            _CurrentPlayerScores.Remove(score);
        }
        _CurrentPlayerScores.Add(newScore);
        _CurrentPlayerScoreLoaded = true;

        Debug.Log(string.Format("[Current Player Score Updated] {0}|{1}|{2}", newScore.PlayerId, newScore.Rank, newScore.Score));
    }
Ejemplo n.º 4
0
    public UM_Score GetScore(int rank, UM_TimeSpan scope, UM_CollectionType collection)
    {
        UM_Score umScore = null;

        if (IsValid)
        {
            switch (Application.platform)
            {
            case RuntimePlatform.Android:
                if (UltimateMobileSettings.Instance.PlatformEngine.Equals(UM_PlatformDependencies.Android))
                {
                    GPScore gp = gp_Leaderboard.GetScore(rank, scope.Get_GP_TimeSpan(), collection.Get_GP_CollectionType());
                    if (gp != null)
                    {
                        umScore = new UM_Score(null, gp, null);
                    }
                }
                else
                {
                    GC_Score gc = gc_Leaderboard.GetScore(rank, scope.Get_GC_TimeSpan());
                    if (gc != null)
                    {
                        umScore = new UM_Score(null, null, gc);
                    }
                }
                break;

            case RuntimePlatform.IPhonePlayer:
                GK_Score gk = gk_Leaderboard.GetScore(rank, scope.Get_GK_TimeSpan(), collection.Get_GK_CollectionType());
                if (gk != null)
                {
                    umScore = new UM_Score(gk, null, null);
                }
                break;
            }
        }

        return(umScore);
    }
Ejemplo n.º 5
0
    private void OnTopScoresLoaded(AGSRequestScoresResponse response)
    {
        AMN_ScoresLoadedResult result = null;

        if (response.IsError())
        {
            Debug.Log("[OnTopScoresLoaded] error " + response.error);
            result = new AMN_ScoresLoadedResult(response.leaderboardId, response.error);
        }
        else
        {
            Debug.Log("[OnTopScoresLoaded] " + response.scores.Count + " scores loaded");
            GC_Leaderboard lb = GetLeaderboard(response.leaderboardId);
            if (lb != null)
            {
                foreach (AGSScore score in response.scores)
                {
                    Debug.Log(string.Format("[OnTopScoresLoaded] AGSScore {0}|{1}|{2}|{3}|{4}",
                                            score.player.playerId,
                                            response.leaderboardId,
                                            score.rank,
                                            score.scoreValue,
                                            response.scope.GetGCTimeSpan().ToString()));

                    GC_Player player = new GC_Player(score.player);
                    AddPlayer(player);

                    GC_Score s = new GC_Score(score.player.playerId, response.leaderboardId, score.rank, score.scoreValue, response.scope.GetGCTimeSpan());
                    lb.UpdateScore(s);
                }
            }
            result = new AMN_ScoresLoadedResult(lb);
        }

        OnScoresLoaded(result);
    }
Ejemplo n.º 6
0
    private void OnLocalPlayerScoresLoaded(AGSRequestScoreResponse response)
    {
        AMN_LocalPlayerScoreLoadedResult result = null;

        if (response.IsError())
        {
            Debug.Log("[OnLocalPlayerScoresLoaded] error " + response.error);
            result = new AMN_LocalPlayerScoreLoadedResult(response.leaderboardId, response.scope.GetGCTimeSpan(), response.error);
        }
        else
        {
            Debug.Log("[OnLocalPlayerScoresLoaded] success " + response.rank + " " + response.score);
            result = new AMN_LocalPlayerScoreLoadedResult(response.leaderboardId, response.scope.GetGCTimeSpan(), response.rank, response.score);

            GC_Leaderboard leaderboard = GetLeaderboard(response.leaderboardId);
            if (leaderboard != null)
            {
                GC_Score score = new GC_Score(SA_AmazonGameCircleManager.Instance.Player.PlayerId, response.leaderboardId, response.rank, response.score, response.scope.GetGCTimeSpan());
                leaderboard.UpdateCurrentPlayerScore(score);
            }
        }

        OnLocalPlayerScoreLoaded(result);
    }