private bool IsPersonalBest(int trackIndex, int score) { string key = string.Format("cake_race_track_{0}_pb_replay", trackIndex); int num = 0; if (GameProgress.HasKey(key, GameProgress.Location.Local, null)) { CakeRaceReplay replay = new CakeRaceReplay(GameProgress.GetString(key, string.Empty, GameProgress.Location.Local, null)); num = CakeRaceReplay.TotalScore(replay); } return(num < score); }
public void SetInfo(int track, CakeRaceReplay replay) { if (replay == null || !replay.IsValid) { this.SetInfo(track, 0, 0, false); return; } int score = CakeRaceReplay.TotalScore(replay); int num = replay.GetCollectedCakeCount(); if (replay.GetCakeCollectTime(-1) >= 0) { num--; } this.SetInfo(track, score, num, replay.HasKingsFavoritePart); }
private void SetScore(CakeRaceReplay replay) { if (replay == null) { for (int i = 0; i < this.cakes.Length; i++) { this.cakes[i].SetActive(false); } this.score.text = "-"; this.kingsFavorite.SetActive(false); } else { for (int j = 0; j < this.cakes.Length; j++) { this.cakes[j].SetActive(replay.CakesCollected > j); } this.score.text = string.Format("{0:N0}", CakeRaceReplay.TotalScore(replay)); this.kingsFavorite.SetActive(replay.HasKingsFavoritePart); } }
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)); }
private void EndRace(int cakeIndex, bool waitToExplode = true) { EventManager.Disconnect(new EventManager.OnEvent <TimeBombExplodeEvent>(this.OnTimeBombExplode)); if (this.IsRaceOn && this.levelManager.gameState != LevelManager.GameState.CakeRaceCompleted) { int collectTime = this.RaceTimeLeftInHundrethOfSeconds(); CakeRaceMode.CurrentReplay.SetCollectedCake(cakeIndex, collectTime); this.AddScore(CakeRaceReplay.CalculateCakeScore(cakeIndex < 0, collectTime, Singleton <PlayerProgress> .Instance.Level, this.HasKingsFavoritePart())); this.IsRaceOn = false; this.OpponentScore = 0; if (CakeRaceMode.OpponentReplay != null) { this.OpponentScore = CakeRaceReplay.TotalScore(CakeRaceMode.OpponentReplay); } PlayerProgressBar.Instance.DelayUpdate(); this.gainedXP = Singleton <PlayerProgress> .Instance.AddExperience((!this.LocalPlayerIsWinner)?PlayerProgress.ExperienceType.LoseCakeRace : PlayerProgress.ExperienceType.WinCakeRace); int num = GameProgress.GetInt("cake_race_total_wins", 0, GameProgress.Location.Local, null); if (!CakeRaceMode.IsPreviewMode && this.LocalPlayerIsWinner) { this.RewardCrate(num); Singleton <PlayFabManager> .Instance.Leaderboard.AddScore(PlayFabLeaderboard.Leaderboard.CakeRaceWins, 1); CakeRaceMenu.WinCount++; } else { CakeRaceMode.CurrentRewardCrate = LootCrateType.None; } int trackIndex = CakeRaceMenu.GetTrackIndex(CakeRaceMode.cakeRaceInfo.Value.UniqueIdentifier, false); if (this.IsPersonalBest(trackIndex, this.CurrentScore) && trackIndex >= 0 && trackIndex < 7) { string key = string.Format("replay_track_{0}", trackIndex); string text = CakeRaceMode.CurrentReplay.TrimmedString(); Singleton <PlayFabManager> .Instance.UpdateUserData(new Dictionary <string, string> { { key, text } }, UserDataPermission.Public); this.SavePersonalBest(trackIndex, text); this.ReportCupScore(GameProgress.GetInt("cake_race_current_cup", (int)PlayFabLeaderboard.LowestCup(), GameProgress.Location.Local, null)); } CoroutineRunner.Instance.StartCoroutine(this.EndingSequence(waitToExplode)); int num2 = GameProgress.GetInt("cake_race_total_losses", 0, GameProgress.Location.Local, null); string currentSeasonID = CakeRaceMode.GetCurrentSeasonID(); string key2 = string.Format("Season_{0}_wins", currentSeasonID); string key3 = string.Format("Season_{0}_losses", currentSeasonID); int num3 = GameProgress.GetInt(key2, 0, GameProgress.Location.Local, null); int num4 = GameProgress.GetInt(key3, 0, GameProgress.Location.Local, null); if (this.LocalPlayerIsWinner) { GameProgress.SetInt("cake_race_total_wins", ++num, GameProgress.Location.Local); GameProgress.SetInt(key2, ++num3, GameProgress.Location.Local); } else { GameProgress.SetInt("cake_race_total_losses", ++num2, GameProgress.Location.Local); GameProgress.SetInt(key3, ++num4, GameProgress.Location.Local); } } }