private void UpdatePlayerInfo(Dictionary <string, UserDataRecord> replayData) { if (replayData == null) { this.ChangeView(LeaderboardDialog.LeaderboardView.List, string.Empty); return; } for (int i = 0; i < this.playerInfo.CakeRaceReplayCount; i++) { string text = string.Format("replay_track_{0}", i); if (replayData.ContainsKey(text)) { CakeRaceReplay cakeRaceReplay = new CakeRaceReplay(replayData[text].Value); UnityEngine.Debug.LogWarning(string.Concat(new string[] { "[UpdatePlayerInfo] replay [", text, "][", replayData[text].Value, "]" })); this.playerInfo.UpdateReplayEntry(i, (!CakeRaceMenu.IsWeeklyTrack(i, cakeRaceReplay.UniqueIdentifier, true)) ? null : cakeRaceReplay); } else { this.playerInfo.UpdateReplayEntry(i, null); } } this.ChangeView(LeaderboardDialog.LeaderboardView.PlayerInfo, string.Empty); }
public void ShowPlayerInfo(string playerName, int playerScore, int playerRank, string playfabID) { string[] array = playerName.Split(new char[] { '|' }); this.ChangeView(LeaderboardDialog.LeaderboardView.Loading, array[0]); this.loadingView = LeaderboardDialog.LeaderboardView.PlayerInfo; this.playerInfo.SetRankScoreInfo(playerRank + 1, playerScore, playfabID.Equals(HatchManager.CurrentPlayer.PlayFabID)); this.playerInfo.SetRewards(CakeRaceMenu.GetSeasonCrateReward((int)CakeRaceMenu.GetCurrentLeaderboardCup(), playerRank + 1), CakeRaceMenu.GetSeasonSnoutCoinReward((int)CakeRaceMenu.GetCurrentLeaderboardCup(), playerRank + 1)); Singleton <PlayFabManager> .Instance.Users.GetUserReplays(playfabID, new Action <GetUserDataResult>(this.OnPlayerInfoResult), new Action <PlayFabError>(this.OnPlayerInfoError)); }
private void UpdateCupIcon() { int num = -1; if (!CakeRaceMenu.IsTutorial) { num = CakeRaceMenu.GetCurrentLeaderboardCup() - PlayFabLeaderboard.Leaderboard.CakeRaceCupF; } for (int i = 0; i < this.cupIcons.Length; i++) { this.cupIcons[i].SetActive(num == i); } }
private void OnEnable() { this.Init(null); if (this.leaderboardDialog != null && this.leaderboardDialog.ShowingCupAnimation) { return; } int currentLeaderboardCup = (int)CakeRaceMenu.GetCurrentLeaderboardCup(); for (int i = 1; i <= this.cups.Length; i++) { this.EnableCup((PlayFabLeaderboard.Leaderboard)i, i == currentLeaderboardCup); } }
private static string GetBoardName(Leaderboard board, bool previousSeason = false) { if ((!previousSeason && CakeRaceMenu.CurrentCakeRaceWeek() % 2 != 0) || (previousSeason && CakeRaceMenu.CurrentCakeRaceWeek() % 2 == 0)) { switch (board) { case PlayFabLeaderboard.Leaderboard.CakeRaceCupF: case PlayFabLeaderboard.Leaderboard.CakeRaceCupE: case PlayFabLeaderboard.Leaderboard.CakeRaceCupD: case PlayFabLeaderboard.Leaderboard.CakeRaceCupC: case PlayFabLeaderboard.Leaderboard.CakeRaceCupB: case PlayFabLeaderboard.Leaderboard.CakeRaceCupA: return(string.Format("{0}2", board.ToString())); } } return(board.ToString()); }
public CakeRaceReplay PersonalBest() { CakeRaceInfo?cakeRaceInfo = CakeRaceMode.cakeRaceInfo; if (cakeRaceInfo == null) { return(null); } int trackIndex = CakeRaceMenu.GetTrackIndex(CakeRaceMode.cakeRaceInfo.Value.UniqueIdentifier, false); string key = string.Format("cake_race_track_{0}_pb_replay", trackIndex); if (GameProgress.HasKey(key, GameProgress.Location.Local, null)) { return(new CakeRaceReplay(GameProgress.GetString(key, string.Empty, GameProgress.Location.Local, null))); } return(null); }
private void OnReplayFetched(string replayJson) { if (!CakeRaceMenu.IsCakeRaceMenuOpen) { return; } if (CakeRaceMenu.UseDefaultReplay || string.IsNullOrEmpty(replayJson)) { this.LoadDefaultReplay(); } else { UnityEngine.Debug.LogWarning("[OnReplayFetched]\n" + replayJson); Singleton <GuiManager> .Instance.enabled = true; CakeRaceReplay cakeRaceReplay = new CakeRaceReplay(replayJson); if (cakeRaceReplay.IsValid) { if (CakeRaceMenu.IsWeeklyTrack(this.currentWeeklyTrackIndex, cakeRaceReplay.UniqueIdentifier, false)) { CakeRaceInfo?cakeRaceInfo; if (WPFMonoBehaviour.gameData.m_cakeRaceData.GetInfo(cakeRaceReplay.UniqueIdentifier, out cakeRaceInfo)) { CakeRaceMode.OpponentReplay = cakeRaceReplay; this.SetInfoLabel("Opponent found"); this.LoadCakeRaceLevel(cakeRaceInfo.Value); } else { this.SetInfoLabel("Opponent replay has unknown level"); this.LoadDefaultReplay(); } } else { this.SetInfoLabel("Opponent replay not from this week"); this.LoadDefaultReplay(); } } else { this.SetInfoLabel("Opponent replay is invalid"); this.LoadDefaultReplay(); } } }
private IEnumerator FetchLeaderboard() { this.ChangeView(LeaderboardDialog.LeaderboardView.Loading, string.Empty); this.loadingView = LeaderboardDialog.LeaderboardView.List; this.currentLeaderboard = null; this.currentPlayerLeaderboard = null; Singleton <PlayFabManager> .Instance.Leaderboard.GetLeaderboard(CakeRaceMenu.GetCurrentLeaderboardCup(), new Action <GetLeaderboardResult>(this.OnTopLeaderboardResult), new Action <PlayFabError>(this.OnLeaderboardError), false, 0, this.topRanks); Singleton <PlayFabManager> .Instance.Leaderboard.GetLeaderboardAroundPlayer(CakeRaceMenu.GetCurrentLeaderboardCup(), new Action <GetLeaderboardAroundPlayerResult>(this.OnPlayerLeaderboardResult), new Action <PlayFabError>(this.OnLeaderboardError), false, 1); while (this.currentLeaderboard == null || this.currentPlayerLeaderboard == null) { yield return(null); } if (this.currentView == LeaderboardDialog.LeaderboardView.Loading && this.loadingView == LeaderboardDialog.LeaderboardView.List) { this.UpdateLeaderboard(this.currentLeaderboard, this.currentPlayerLeaderboard); } yield break; }
private void UpdateLeaderboard(List <PlayerLeaderboardEntry> leaderboard, List <PlayerLeaderboardEntry> player) { if ((this.entryPrefab == null || this.top50Grid == null || this.singleRanks == null) && !this.ShowingCupAnimation) { this.ChangeView(LeaderboardDialog.LeaderboardView.Error, string.Empty); } this.localPlayerRank = ((player.Count <= 0) ? -1 : ((player[0].StatValue <= 0) ? -1 : player[0].Position)); LeaderboardEntry leaderboardEntry = null; for (int i = 0; i < this.topRanks; i++) { int keyFromIndex = this.GetKeyFromIndex(i); if (this.leaderboardEntries.ContainsKey(keyFromIndex)) { if (i < leaderboard.Count) { if (HatchManager.CurrentPlayer.PlayFabID.Equals(leaderboard[i].PlayFabId)) { leaderboardEntry = this.leaderboardEntries[keyFromIndex]; } this.leaderboardEntries[keyFromIndex].SetInfo(leaderboard[i].PlayFabId, leaderboard[i].DisplayName, leaderboard[i].StatValue, leaderboard[i].Position); } else { this.leaderboardEntries[keyFromIndex].SetInfo(string.Empty, "- empty -", 0, i); } this.leaderboardEntries[keyFromIndex].SetRewards(CakeRaceMenu.GetSeasonCrateReward((int)CakeRaceMenu.GetCurrentLeaderboardCup(), i + 1), CakeRaceMenu.GetSeasonSnoutCoinReward((int)CakeRaceMenu.GetCurrentLeaderboardCup(), i + 1)); } } for (int j = 0; j < this.singleRanks.Length; j++) { int indexFromRank = this.GetIndexFromRank(this.singleRanks[j]); if (this.leaderboardEntries.ContainsKey(indexFromRank)) { this.leaderboardEntries[indexFromRank].SetInfo(string.Empty, "- empty -", 0, this.singleRanks[j]); } } for (int k = 0; k < this.singleRanks.Length; k++) { if (this.localPlayerRank <= this.topRanks && this.localPlayerRank >= 0) { break; } int indexFromRank2 = this.GetIndexFromRank(this.singleRanks[k]); int num = this.singleRanks[k] - 1; if (this.leaderboardEntries.ContainsKey(indexFromRank2)) { if (this.localPlayerRank <= num && this.localPlayerRank >= 0) { leaderboardEntry = this.leaderboardEntries[indexFromRank2]; leaderboardEntry.SetInfo(player[0].PlayFabId, player[0].DisplayName, player[0].StatValue, this.localPlayerRank); leaderboardEntry.SetRewards(CakeRaceMenu.GetSeasonCrateReward((int)CakeRaceMenu.GetCurrentLeaderboardCup(), this.localPlayerRank + 1), CakeRaceMenu.GetSeasonSnoutCoinReward((int)CakeRaceMenu.GetCurrentLeaderboardCup(), this.localPlayerRank + 1)); break; } if (num < leaderboard.Count) { this.leaderboardEntries[indexFromRank2].SetInfo(leaderboard[num].PlayFabId, leaderboard[num].DisplayName, leaderboard[num].StatValue, num); this.leaderboardEntries[indexFromRank2].SetRewards(CakeRaceMenu.GetSeasonCrateReward((int)CakeRaceMenu.GetCurrentLeaderboardCup(), num + 1), CakeRaceMenu.GetSeasonSnoutCoinReward((int)CakeRaceMenu.GetCurrentLeaderboardCup(), num + 1)); } } } if (this.localPlayerRank < 0) { int keyFromIndex2 = this.GetKeyFromIndex((leaderboard.Count > 0) ? -1 : 0); leaderboardEntry = this.leaderboardEntries[keyFromIndex2]; leaderboardEntry.SetInfo(HatchManager.CurrentPlayer.PlayFabID, HatchManager.CurrentPlayer.PlayFabDisplayName, 0, -1); leaderboardEntry.SetRewards(LootCrateType.None, 0); } else if (this.localPlayerRank >= this.HighestRankEntry()) { int keyFromIndex3 = this.GetKeyFromIndex(-1); leaderboardEntry = this.leaderboardEntries[keyFromIndex3]; leaderboardEntry.SetInfo(player[0].PlayFabId, player[0].DisplayName, player[0].StatValue, this.localPlayerRank); leaderboardEntry.SetRewards(CakeRaceMenu.GetSeasonCrateReward((int)CakeRaceMenu.GetCurrentLeaderboardCup(), this.localPlayerRank + 1), CakeRaceMenu.GetSeasonSnoutCoinReward((int)CakeRaceMenu.GetCurrentLeaderboardCup(), this.localPlayerRank + 1)); } else { int keyFromIndex4 = this.GetKeyFromIndex(-1); this.leaderboardEntries[keyFromIndex4].SetInfo(string.Empty, "- empty -", 0, -1); } if (!this.ShowingCupAnimation) { this.ChangeView(LeaderboardDialog.LeaderboardView.List, string.Empty); } this.UpdateGridLayout(); this.PositionLeaderboard(leaderboardEntry); }
private string GetCupAndSeasonTitle() { Localizer.LocaleParameters localeParameters = Singleton <Localizer> .Instance.Resolve("LEADERBOARDS_TITLE", null); Localizer.LocaleParameters localeParameters2 = Singleton <Localizer> .Instance.Resolve(string.Format("CUP_{0:00}_NAME", (int)CakeRaceMenu.GetCurrentLeaderboardCup()), null); return(string.Format(localeParameters.translation, localeParameters2.translation, CakeRaceMenu.CurrentCakeRaceWeek())); }
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); } } }
private void OnGUI() { if (!this.skinInitialized) { this.cheatSkin = GUI.skin; float dpi = Screen.dpi; if (dpi > 1f) { this.cheatSkin.label.fontSize = Mathf.FloorToInt(0.1f * dpi + 2f); this.cheatSkin.button.fontSize = Mathf.FloorToInt(0.1f * dpi + 2f); } else { this.cheatSkin.label.fontSize = Mathf.FloorToInt(15f); this.cheatSkin.button.fontSize = Mathf.FloorToInt(15f); } this.cheatSkin.button.wordWrap = true; GUI.skin.verticalScrollbar.fixedWidth = (float)Screen.width * 0.05f; GUI.skin.verticalScrollbarThumb.fixedWidth = (float)Screen.width * 0.05f; this.skinInitialized = true; } this.scrollbarPosition = GUILayout.BeginScrollView(this.scrollbarPosition, new GUILayoutOption[] { GUILayout.Width((float)Screen.width), GUILayout.Height((float)Screen.height - (float)Screen.height * 0.1f) }); this.BeginGrid(); int gameModeIndex = UserSettings.GetInt("game_mode", 0); if (gameModeIndex >= 0 && gameModeIndex < CheatsUtility.gameModeNames.Count) { this.DrawButton("Toggle game mode:\n" + CheatsUtility.gameModeNames[gameModeIndex], delegate { gameModeIndex++; if (gameModeIndex >= CheatsUtility.gameModeNames.Count) { gameModeIndex = 0; } if (gameModeIndex == 0) { UserSettings.DeleteKey("game_mode"); } else { UserSettings.SetInt("game_mode", gameModeIndex); } }); } this.DrawButton("Reset progress", delegate { GameProgress.DeleteAll(); GameProgress.InitializeGameProgressData(); GameProgress.Save(); UserSettings.DeleteAll(); UserSettings.Save(); if (Singleton <DailyChallenge> .IsInstantiated() && Singleton <DailyChallenge> .Instance.Initialized) { Singleton <DailyChallenge> .Instance.ForceNewChallenge(); } }); this.DrawButton("1-star all levels", delegate { foreach (Episode episode in WPFMonoBehaviour.gameData.m_episodeLevels) { for (int i = 0; i < episode.LevelInfos.Count; i++) { this.SetStarsCompletion(episode.LevelInfos[i], 1); } } }); this.DrawButton("3-stars all but one", delegate { foreach (Episode episode in WPFMonoBehaviour.gameData.m_episodeLevels) { int num = UnityEngine.Random.Range(0, episode.LevelInfos.Count - 3); for (int i = 0; i < episode.LevelInfos.Count - 2; i++) { if (i != num) { this.SetStarsCompletion(episode.LevelInfos[i], 3); } } } }); this.DrawButton("3-stars all", delegate { foreach (Episode episode in WPFMonoBehaviour.gameData.m_episodeLevels) { for (int i = 0; i < episode.LevelInfos.Count; i++) { this.SetStarsCompletion(episode.LevelInfos[i], 3); } } }); this.DrawButton("Sandbox all starboxes", delegate { foreach (SandboxLevels.LevelData levelData in WPFMonoBehaviour.gameData.m_sandboxLevels.Levels) { for (int i = 0; i < levelData.m_starBoxCount; i++) { if (i < 10) { GameProgress.AddSandboxStar(levelData.SceneName, "StarBox0" + i, false); } else { GameProgress.AddSandboxStar(levelData.SceneName, "StarBox" + i, false); } } } }); this.DrawButton("Unlimited Sandbox Parts", delegate { IEnumerator enumerator = Enum.GetValues(typeof(BasePart.PartType)).GetEnumerator(); try { while (enumerator.MoveNext()) { object obj = enumerator.Current; BasePart.PartType partType = (BasePart.PartType)obj; if (partType != BasePart.PartType.Unknown && partType != BasePart.PartType.ObsoleteWheel && partType != BasePart.PartType.JetEngine) { int sandboxPartCount = GameProgress.GetSandboxPartCount(partType); GameProgress.AddSandboxParts(partType, 99 - sandboxPartCount, false); } } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } }); if (Application.targetFrameRate == 60) { this.DrawButton("Set low target FPS", delegate { Application.targetFrameRate = 25; }); } else { this.DrawButton("Set default target FPS", delegate { Application.targetFrameRate = 60; }); } this.DrawButton("Unlock all levels", delegate { GameProgress.SetBool("UnlockAllLevels", true, GameProgress.Location.Local); }); this.DrawButton("Restore IAPs", delegate { Singleton <IapManager> .Instance.RestorePurchasedItems(); }); this.DrawButton("Reset IAPs", delegate { GameProgress.SetBool("ResetIAPs", true, GameProgress.Location.Local); }); this.DrawButton("Add 10 Autobuilds", delegate { GameProgress.AddBluePrints(10); }); this.DrawButton("Add Wooden crate", delegate { GameProgress.AddLootcrate(LootCrateType.Wood, 1); }); this.DrawButton("Add Metal crate", delegate { GameProgress.AddLootcrate(LootCrateType.Metal, 1); }); this.DrawButton("Add Golden crate", delegate { GameProgress.AddLootcrate(LootCrateType.Gold, 1); }); this.DrawButton("Add 10 Glue, Magnet, Turbo and NightVision", delegate { GameProgress.AddSuperGlue(10); GameProgress.AddSuperMagnet(10); GameProgress.AddTurboCharge(10); GameProgress.AddNightVision(10); }); this.DrawButton("Unlock all sandboxes", delegate { GameProgress.UnlockButton("EpisodeButtonSandbox"); foreach (SandboxLevels.LevelData levelData in WPFMonoBehaviour.gameData.m_sandboxLevels.Levels) { if (!(levelData.m_identifier == "S-F") && !(levelData.m_identifier == "S-M")) { GameProgress.SetSandboxUnlocked(levelData.m_identifier, true); } } }); this.DrawButton("Unlock Field of Dreams", delegate { GameProgress.SetSandboxUnlocked("S-F", true); }); this.DrawButton("Unlock Little Pig Adventure", delegate { GameProgress.SetSandboxUnlocked("S-M", true); }); this.DrawButton("Unlock iOS Full version", delegate { GameProgress.SetFullVersionUnlocked(true); }); this.DrawButton("Mimic 1.8.0 install version. Game needs to be restarted.", delegate { GameProgress.SetString("InstallVersion", "1.8.0", GameProgress.Location.Local); GameProgress.DeleteKey("LastKnownVersion", GameProgress.Location.Local); }); this.DrawButton("Unlock & 3-star Race Levels except for last", delegate { List <RaceLevels.LevelData> levels = WPFMonoBehaviour.gameData.m_raceLevels.Levels; for (int i = 0; i < levels.Count - 1; i++) { GameProgress.SetInt(levels[i].m_identifier + "_stars", 3, GameProgress.Location.Local); GameProgress.SetBestTime(levels[i].SceneName, 10f); GameProgress.SetRaceLevelUnlocked(levels[i].m_identifier, true); } }); this.DrawButton("Add some desserts", delegate { int count = WPFMonoBehaviour.gameData.m_desserts.Count; int num = UnityEngine.Random.Range(1, count); for (int i = 0; i < num; i++) { string name = WPFMonoBehaviour.gameData.m_desserts[UnityEngine.Random.Range(0, count)].name; GameProgress.AddDesserts(name, UnityEngine.Random.Range(1, 6)); } }); this.DrawButton("Enable basic mechanic", delegate { GameProgress.SetBool("PermanentBlueprint", true, GameProgress.Location.Local); }); this.DrawButton("Test Force Update. You must relaunch the app manually", delegate { GameProgress.SetInt(CheatsUtility.versionStatusCheat, 3, GameProgress.Location.Local); }); this.DrawButton("Test Optional Update. You must relaunch the app manually", delegate { GameProgress.SetInt(CheatsUtility.versionStatusCheat, 1, GameProgress.Location.Local); }); this.DrawButton("Unlock All Free Levels", delegate { GameProgress.SetBool("UnlockAllFreeLevels", true, GameProgress.Location.Local); }); if (Singleton <RewardSystem> .IsInstantiated()) { string text = "Reward Timer Toggle\nReward time / Reset time\n"; switch (Singleton <RewardSystem> .Instance.GetTimerMode()) { case 0: text += "24h / 48h"; break; case 1: text += "15m / 30m"; break; case 2: text += "5m / 15m"; break; case 3: text += "1m / 1m 15s"; break; case 4: text += "5s / 10s"; break; } this.DrawButton(text, delegate { Singleton <RewardSystem> .Instance.ChangeTimerMode(); }); } this.DrawButton("Reset snout intro", delegate { GameProgress.SetInt("show_count_snout_intro", 0, GameProgress.Location.Local); }); this.DrawButton("Add 1000 snout coins", delegate { GameProgress.AddSnoutCoins(1000); }); this.DrawButton("Add 100 scrap", delegate { GameProgress.AddScrap(100); }); this.DrawButton("Unlock all custom parts", delegate { this.UnlockParts(BasePart.PartTier.Common); this.UnlockParts(BasePart.PartTier.Rare); this.UnlockParts(BasePart.PartTier.Epic); this.UnlockParts(BasePart.PartTier.Legendary); }); this.DrawButton("Unlock all Common parts", delegate { this.UnlockParts(BasePart.PartTier.Common); }); this.DrawButton("Unlock all Rare parts", delegate { this.UnlockParts(BasePart.PartTier.Rare); }); this.DrawButton("Unlock all Epic parts", delegate { this.UnlockParts(BasePart.PartTier.Epic); }); this.DrawButton("Unlock all Legendary parts", delegate { this.UnlockParts(BasePart.PartTier.Legendary); }); this.DrawButton("Unlock all craftable items", delegate { this.UnlockParts(BasePart.PartTier.Common, CustomizationManager.PartFlags.Locked | CustomizationManager.PartFlags.Craftable); this.UnlockParts(BasePart.PartTier.Rare, CustomizationManager.PartFlags.Locked | CustomizationManager.PartFlags.Craftable); this.UnlockParts(BasePart.PartTier.Epic, CustomizationManager.PartFlags.Locked | CustomizationManager.PartFlags.Craftable); this.UnlockParts(BasePart.PartTier.Legendary, CustomizationManager.PartFlags.Locked | CustomizationManager.PartFlags.Craftable); }); this.DrawButton("Reset Workshop Tutorial", delegate { GameProgress.DeleteKey("Workshop_Tutorial", GameProgress.Location.Local); }); this.DrawButton("Reset Crate Craze popup", delegate { GameProgress.SetBool("CrateCrazeSale_shown", false, GameProgress.Location.Local); }); bool processPurchases = GameProgress.GetBool("Process_purchases", true, GameProgress.Location.Local, null); this.DrawButton((!processPurchases) ? "Don't process purchases" : "Do process purchases", delegate { GameProgress.SetBool("Process_purchases", !processPurchases, GameProgress.Location.Local); }); this.DrawButton("CRASH CLIENT", delegate { string text2 = null; text2 = text2.ToString(); }); this.DrawButton("Force Garbage Collection", delegate { GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); }); bool fastNotifications = GameProgress.GetBool("fast_notifications", false, GameProgress.Location.Local, null); this.DrawButton((!fastNotifications) ? "Use faster notification schedule" : "Use realtime notification schedule", delegate { GameProgress.SetBool("fast_notifications", !fastNotifications, GameProgress.Location.Local); }); if (GameProgress.HasKey("notification_clicked", GameProgress.Location.Local, null)) { this.DrawButton("Clicked notification:\n" + GameProgress.GetString("notification_clicked", "null", GameProgress.Location.Local, null), null); } this.DrawButton("Clear PlayerPrefs", delegate { PlayerPrefs.DeleteAll(); }); this.DrawButton("Get all but one customizations", delegate { for (int i = 1; i < 4; i++) { List <BasePart> allTierParts = CustomizationManager.GetAllTierParts((BasePart.PartTier)i, CustomizationManager.PartFlags.Locked | CustomizationManager.PartFlags.Craftable | CustomizationManager.PartFlags.Rewardable); for (int j = 0; j < allTierParts.Count - 1; j++) { CustomizationManager.UnlockPart(allTierParts[j], "Cheat"); } } }); this.DrawButton("Reset level to 1", delegate { GameProgress.SetInt("player_level", 1, GameProgress.Location.Local); GameProgress.SetInt("player_experience", 0, GameProgress.Location.Local); GameProgress.SetInt("player_pending_experience", -1, GameProgress.Location.Local); }); this.DrawButton("Set level to 5", delegate { GameProgress.SetInt("player_level", 5, GameProgress.Location.Local); GameProgress.SetInt("player_experience", 0, GameProgress.Location.Local); GameProgress.SetInt("player_pending_experience", -1, GameProgress.Location.Local); }); this.DrawButton("Force local game configuration '" + GameProgress.GetBool("ForceLocalGameConfiguration", false, GameProgress.Location.Local, null) + "' (requires restart)", delegate { }); if (GameProgress.HasKey("cup_advance_cheat", GameProgress.Location.Local, null)) { this.DrawButton(string.Concat(new object[] { "Current cup:\n", CakeRaceMenu.GetCurrentLeaderboardCup().ToString(), "\nNext cup:\n", (PlayFabLeaderboard.Leaderboard)GameProgress.GetInt("cup_advance_cheat", 1, GameProgress.Location.Local, null) }), delegate { }); int rankCheat = GameProgress.GetInt("cup_rank_cheat", 0, GameProgress.Location.Local, null); this.DrawButton((!GameProgress.HasKey("cup_rank_cheat", GameProgress.Location.Local, null)) ? "Enable rank cheat" : ("Current Rank:\n" + rankCheat.ToString() + "\nLower rank?"), delegate { switch (rankCheat) { case 1: case 2: break; case 3: rankCheat = 5; goto IL_E6; default: if (rankCheat == 50) { rankCheat = 100; goto IL_E6; } if (rankCheat == 100) { rankCheat = 250; goto IL_E6; } if (rankCheat == 250) { rankCheat = 500; goto IL_E6; } if (rankCheat != 500) { rankCheat = 1; goto IL_E6; } break; case 5: rankCheat = 10; goto IL_E6; case 10: rankCheat = 50; goto IL_E6; } rankCheat++; IL_E6: GameProgress.SetInt("cup_rank_cheat", rankCheat, GameProgress.Location.Local); }); } else { this.DrawButton("Current cup:\n" + CakeRaceMenu.GetCurrentLeaderboardCup().ToString() + "\nAdvance to next Cup", delegate { int value = (int)(1 + CakeRaceMenu.GetCurrentLeaderboardCup()); value = Mathf.Clamp(value, (int)PlayFabLeaderboard.LowestCup(), (int)PlayFabLeaderboard.HighestCup()); GameProgress.SetInt("cup_advance_cheat", value, GameProgress.Location.Local); if (GameProgress.HasKey("cup_rank_cheat", GameProgress.Location.Local, null)) { GameProgress.DeleteKey("cup_rank_cheat", GameProgress.Location.Local); } }); } this.DrawButton("Reset cup cheats", delegate { if (GameProgress.HasKey("cup_advance_cheat", GameProgress.Location.Local, null)) { GameProgress.DeleteKey("cup_advance_cheat", GameProgress.Location.Local); } if (GameProgress.HasKey("cup_rank_cheat", GameProgress.Location.Local, null)) { GameProgress.DeleteKey("cup_rank_cheat", GameProgress.Location.Local); } GameProgress.SetInt("cake_race_current_cup", CakeRaceMenu.GetCupIndexFromPlayerLevel(), GameProgress.Location.Local); }); int leaderboardTestAmount = GameProgress.GetInt("cheat_leaderboard_test", -1, GameProgress.Location.Local, null); if (leaderboardTestAmount < 0) { this.DrawButton("Generate test leaderboard", delegate { GameProgress.SetInt("cheat_leaderboard_test", 0, GameProgress.Location.Local); }); } else { this.DrawButton("Test leaderboard amount:\n" + leaderboardTestAmount.ToString(), delegate { switch (leaderboardTestAmount) { case 0: case 1: case 2: case 3: case 4: break; case 5: leaderboardTestAmount = 8; goto IL_1D7; default: switch (leaderboardTestAmount) { case 500: case 501: case 502: break; default: if (leaderboardTestAmount == 25) { leaderboardTestAmount = 50; goto IL_1D7; } if (leaderboardTestAmount == 50) { leaderboardTestAmount = 75; goto IL_1D7; } if (leaderboardTestAmount == 75) { leaderboardTestAmount = 100; goto IL_1D7; } if (leaderboardTestAmount == 100) { leaderboardTestAmount = 175; goto IL_1D7; } if (leaderboardTestAmount == 175) { leaderboardTestAmount = 250; goto IL_1D7; } if (leaderboardTestAmount == 250) { leaderboardTestAmount = 425; goto IL_1D7; } if (leaderboardTestAmount != 425) { leaderboardTestAmount = 0; goto IL_1D7; } leaderboardTestAmount = 500; goto IL_1D7; } break; case 8: leaderboardTestAmount = 10; goto IL_1D7; case 10: leaderboardTestAmount = 25; goto IL_1D7; } leaderboardTestAmount++; IL_1D7: GameProgress.SetInt("cheat_leaderboard_test", leaderboardTestAmount, GameProgress.Location.Local); }); int leaderboardRankCheat = GameProgress.GetInt("cheat_leaderboard_test_local_rank", -1, GameProgress.Location.Local, null); this.DrawButton("Cheat player rank: " + (leaderboardRankCheat + 1), delegate { switch (leaderboardRankCheat + 1) { case 0: leaderboardRankCheat = 0; break; case 1: leaderboardRankCheat = 1; break; case 2: leaderboardRankCheat = 2; break; case 3: leaderboardRankCheat = 3; break; case 4: leaderboardRankCheat = 4; break; case 5: leaderboardRankCheat = 9; break; default: if (leaderboardRankCheat != 24) { if (leaderboardRankCheat != 49) { if (leaderboardRankCheat != 149) { if (leaderboardRankCheat != 499) { if (leaderboardRankCheat != 999) { if (leaderboardRankCheat != 9999) { if (leaderboardRankCheat == 99999) { leaderboardRankCheat = -1; } } else { leaderboardRankCheat = 99999; } } else { leaderboardRankCheat = 9999; } } else { leaderboardRankCheat = 999; } } else { leaderboardRankCheat = 499; } } else { leaderboardRankCheat = 149; } } else { leaderboardRankCheat = 49; } break; case 10: leaderboardRankCheat = 24; break; } GameProgress.SetInt("cheat_leaderboard_test_local_rank", leaderboardRankCheat, GameProgress.Location.Local); }); this.DrawButton("Clear test leaderboard", delegate { GameProgress.DeleteKey("cheat_leaderboard_test", GameProgress.Location.Local); GameProgress.DeleteKey("cheat_leaderboard_test_local_rank", GameProgress.Location.Local); }); } this.DrawButton("Reset alien machine", delegate { if (GameProgress.HasKey("AlienCraftingMachineShown", GameProgress.Location.Local, null)) { GameProgress.DeleteKey("AlienCraftingMachineShown", GameProgress.Location.Local); } }); this.DrawButton("Reset Cake Race unlock", delegate { if (GameProgress.HasKey("CakeRaceUnlockShown", GameProgress.Location.Local, null)) { GameProgress.SetBool("CakeRaceUnlockShown", false, GameProgress.Location.Local); } if (GameProgress.HasKey("UnlockShown_CakeRaceButton", GameProgress.Location.Local, null)) { GameProgress.SetBool("UnlockShown_CakeRaceButton", false, GameProgress.Location.Local); } }); this.DrawButton("Skip cake race tutorial", delegate { int @int = GameProgress.GetInt("cake_race_total_wins", 0, GameProgress.Location.Local, null); if (@int < 7) { GameProgress.SetInt("cake_race_total_wins", 7, GameProgress.Location.Local); } }); this.EndGrid(); GUILayout.EndScrollView(); GUI.Label(new Rect((float)Screen.width * 0.9f, (float)Screen.height * 0.93f, (float)Screen.width * 0.1f, (float)Screen.height * 0.1f), string.Concat(new string[] { "Debug \n(v", Singleton <BuildCustomizationLoader> .Instance.ApplicationVersion, " - ", Singleton <BuildCustomizationLoader> .Instance.SVNRevisionNumber, ")" })); if (GUI.Button(new Rect((float)Screen.width * 0.2f, (float)Screen.height * 0.92f, (float)Screen.width * 0.6f, (float)Screen.height * 0.08f), "Back to Main Menu")) { GameProgress.Save(); PlayerPrefs.Save(); Singleton <GameManager> .Instance.LoadMainMenu(false); } GUI.skin = null; }
public static bool IsWeeklyTrack(int index, string uniqueIdentifier, bool ignoreTutorial = false) { return(CakeRaceMenu.GetTrackIndex(uniqueIdentifier, ignoreTutorial) == index); }
private void OnRankFetched(GetLeaderboardAroundPlayerResult result) { if (!CakeRaceMenu.IsCakeRaceMenuOpen) { return; } if (this.lootCrateSlots.IsPopUpOpen()) { base.StartCoroutine(this.WaitPopUpAndTryRankReward(result)); return; } if (result.Leaderboard == null || (result.Leaderboard.Count > 0 && (result.Leaderboard[0].StatValue <= 0 || result.Leaderboard[0].Position >= 500))) { this.TryToShowCupEndAnimation(false); this.TryToUnlockCakeRaceLockScreen(); return; } GameObject go = UnityEngine.Object.Instantiate <GameObject>(this.seasonEndDialogPopup, Vector3.zero, Quaternion.identity); go.transform.position += Vector3.back * 20f; this.seasonEndDialog = go.GetComponent <LeaderboardSeasonEndDialog>(); this.seasonEndDialog.SetLoading(true); this.seasonEndDialog.onClose += delegate() { UnityEngine.Object.Destroy(go); }; int currentCupIndex = (int)this.rewardPendingCup; int rank = result.Leaderboard[0].Position + 1; int @int = GameProgress.GetInt("cake_race_highest_rank", 0, GameProgress.Location.Local, null); if (@int <= 0 || rank < @int) { GameProgress.SetInt("cake_race_highest_rank", rank, GameProgress.Location.Local); } string text = string.Empty; if (rank != 1) { if (rank != 2) { if (rank == 3) { text = "cake_race_bronze_trophies_won"; } } else { text = "cake_race_silver_trophies_won"; } } else { text = "cake_race_gold_trophies_won"; } if (!string.IsNullOrEmpty(text)) { int int2 = GameProgress.GetInt(text, 0, GameProgress.Location.Local, null); GameProgress.SetInt(text, int2 + 1, GameProgress.Location.Local); } int seasonSnoutCoinReward = CakeRaceMenu.GetSeasonSnoutCoinReward(currentCupIndex, rank); if (seasonSnoutCoinReward > 0) { GameProgress.AddSnoutCoins(seasonSnoutCoinReward); int int3 = GameProgress.GetInt("cake_race_coins_won", 0, GameProgress.Location.Local, null); GameProgress.SetInt("cake_race_coins_won", int3 + seasonSnoutCoinReward, GameProgress.Location.Local); } LootCrateType crateType = CakeRaceMenu.GetSeasonCrateReward(currentCupIndex, rank); if (crateType != LootCrateType.None) { this.seasonEndDialog.onClose += delegate() { LootCrate.SpawnLootCrateOpeningDialog(crateType, 1, WPFMonoBehaviour.s_hudCamera, new Dialog.OnClose(this.OnDialogClosed), new LootCrate.AnalyticData(string.Format("{0}_reward", (PlayFabLeaderboard.Leaderboard)currentCupIndex), "0", LootCrate.AdWatched.NotApplicaple)); }; } else { this.seasonEndDialog.onClose += this.OnDialogClosed; } this.seasonEndDialog.SetCrateRankAndReward(crateType, rank, seasonSnoutCoinReward); this.isRewardingPlayer = false; }
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(); } }
protected override void Awake() { base.Awake(); Transform transform = this.dialogRoot.transform.Find("TitleRibbon/TitleLabel"); if (transform != null) { this.titleLabel = transform.GetComponentsInChildren <TextMesh>(); } transform = this.dialogRoot.transform.Find("RewardContainer/RankLabel"); if (transform != null) { this.rankLabel = transform.GetComponentsInChildren <TextMesh>(); } transform = this.dialogRoot.transform.Find("RewardContainer/RewardLabel"); if (transform != null) { this.rewardLabel = transform.GetComponentsInChildren <TextMesh>(); } Localizer.LocaleParameters localeParameters = Singleton <Localizer> .Instance.Resolve(this.titleLocalizationKey, null); TextMeshHelper.UpdateTextMeshes(this.titleLabel, string.Format(localeParameters.translation, CakeRaceMenu.CurrentCakeRaceWeek() - 1), false); }