Esempio n. 1
0
    private void ReportCupScore(int cupIndex)
    {
        int num = 0;

        for (int i = 0; i < 7; i++)
        {
            string text = string.Format("cake_race_track_{0}_pb_replay", i);
            if (GameProgress.HasKey(text, GameProgress.Location.Local, null))
            {
                CakeRaceReplay cakeRaceReplay = new CakeRaceReplay(GameProgress.GetString(text, string.Empty, GameProgress.Location.Local, null));
                if (cakeRaceReplay.IsValid)
                {
                    int num2 = CakeRaceReplay.TotalScore(cakeRaceReplay);
                    num += num2;
                    UnityEngine.Debug.LogWarning("[CakeRaceMode] Track (" + text + ") score " + num2.ToString());
                }
            }
        }
        PlayFabLeaderboard.Leaderboard board = (PlayFabLeaderboard.Leaderboard)cupIndex;
        UnityEngine.Debug.LogWarning("[CakeRaceMode] ReportCupScore [" + board.ToString() + "] " + num.ToString());
        Singleton <PlayFabManager> .Instance.Leaderboard.AddScore(board, num, new Action <UpdatePlayerStatisticsResult>(this.OnCupScoreReported), new Action <PlayFabError>(this.OnCupScoreError));
    }
Esempio n. 2
0
    private void OnCakeRaceWeekFetched(string week, string daysLeft)
    {
        if (!CakeRaceMenu.IsCakeRaceMenuOpen)
        {
            return;
        }
        this.fetchingWeeklyTrackData = false;
        int num = GameProgress.GetInt("cake_race_current_cup", (int)PlayFabLeaderboard.LowestCup(), GameProgress.Location.Local, null);
        int num2;

        if (int.TryParse(week, out num2))
        {
            int num3 = CakeRaceMenu.CurrentCakeRaceWeek();
            GameProgress.SetInt("cake_race_current_week", num2, GameProgress.Location.Local);
            if (!CakeRaceMenu.IsTutorial && num3 != num2)
            {
                PlayFabLeaderboard.Leaderboard currentLeaderboardCup = CakeRaceMenu.GetCurrentLeaderboardCup();
                Singleton <CakeRaceKingsFavorite> .Instance.ClearCurrentFavorite();

                CakeRaceMode.ClearPersonalBestData();
                CakeRaceMenu.ClearCloudTrackData();
                int cupIndexFromPlayerLevel = CakeRaceMenu.GetCupIndexFromPlayerLevel();
                if (num != cupIndexFromPlayerLevel)
                {
                    num = cupIndexFromPlayerLevel;
                    GameProgress.SetInt("cake_race_current_cup", num, GameProgress.Location.Local);
                    GameProgress.SetBool("cake_race_show_cup_animation", true, GameProgress.Location.Local);
                }
                if (GameProgress.HasKey("cake_race_current_cup", GameProgress.Location.Local, null))
                {
                    this.RewardCupPlayer(currentLeaderboardCup);
                }
                else
                {
                    GameProgress.SetInt("cake_race_current_cup", num, GameProgress.Location.Local);
                    base.StartCoroutine(this.WaitPopUpAndShowCupEndAnimation());
                }
            }
        }
        else
        {
            num2 = 0;
        }
        string str = "[CakeRaceMenu] current cup is ";

        PlayFabLeaderboard.Leaderboard leaderboard = (PlayFabLeaderboard.Leaderboard)num;
        UnityEngine.Debug.LogWarning(str + leaderboard.ToString());
        int num4 = 0;

        if (Singleton <GameConfigurationManager> .Instance.HasValue("cake_race", "week_offset"))
        {
            num4 = Singleton <GameConfigurationManager> .Instance.GetValue <int>("cake_race", "week_offset");
        }
        CakeRaceMenu.CurrentSeasonIndex = Mathf.Clamp(num2 + num4, 0, int.MaxValue) % CakeRaceMenu.WeeklyTrackIdentifiers.Length;
        if (!CakeRaceMenu.AllSeasonTracks.ContainsKey(CakeRaceMenu.CurrentSeasonIndex))
        {
            CakeRaceMenu.CurrentSeasonIndex = 0;
        }
        if (this.HasWeeklyData())
        {
            this.SetInfoLabel("Ready to go");
        }
        else
        {
            this.SetInfoLabel("Error fetching tracks");
        }
        this.UpdateDaysLeft();
        if (!this.isRewardingPlayer)
        {
            this.TryToUnlockCakeRaceLockScreen();
        }
    }