public static void UnlockButton(string buttonId) { if (GameProgress.GetButtonUnlockState(buttonId) == GameProgress.ButtonUnlockState.Locked) { GameProgress.SetButtonUnlockState(buttonId, GameProgress.ButtonUnlockState.UnlockNow); } }
private void UpdateState() { GameProgress.ButtonUnlockState buttonUnlockState = GameProgress.GetButtonUnlockState(this.m_buttonId); if (buttonUnlockState == GameProgress.ButtonUnlockState.Unlocked) { base.gameObject.SetActive(false); } else if (buttonUnlockState == GameProgress.ButtonUnlockState.UnlockNow) { this.Unlock(); } else { base.gameObject.SetActive(true); if (base.transform.parent.GetComponent <TooltipInfo>() == null) { base.transform.parent.GetComponent <Button>().Lock(true); } } }
private void OnEnable() { if (this.m_sandboxSelector != null && this.m_sandboxIdentifier.Equals("S-F") && GameProgress.GetSandboxUnlocked(this.m_sandboxIdentifier)) { UnlockSandboxSequence component = base.GetComponent <UnlockSandboxSequence>(); GameProgress.ButtonUnlockState buttonUnlockState = GameProgress.GetButtonUnlockState("SandboxLevelButton_" + this.m_sandboxIdentifier); if (component == null && buttonUnlockState == GameProgress.ButtonUnlockState.Locked) { base.gameObject.AddComponent <UnlockSandboxSequence>(); } Button component2 = base.GetComponent <Button>(); component2.MethodToCall.SetMethod(this.m_sandboxSelector, "LoadSandboxLevel", this.m_sandboxIdentifier); string str = WPFMonoBehaviour.gameData.m_sandboxLevels.GetLevelData(this.m_sandboxIdentifier).m_starBoxCount.ToString(); this.m_starsText.text = GameProgress.SandboxStarCount(this.m_sandboxSelector.FindLevelFile(this.m_sandboxIdentifier)).ToString() + "/" + str; for (int i = 0; i < this.hideOnContentUnlocked.Length; i++) { this.hideOnContentUnlocked[i].SetActive(false); } for (int j = 0; j < this.hideOnContentLocked.Length; j++) { this.hideOnContentLocked[j].SetActive(true); } } }
private void Awake() { this.episodeSelector = CompactEpisodeSelector.Instance; if (this.buttonLock == null) { this.buttonLock = base.GetComponentInChildren <ButtonLock>(); } SandboxLevelButton component = base.GetComponent <SandboxLevelButton>(); if (component != null) { if (!GameProgress.GetSandboxUnlocked(component.m_sandboxIdentifier)) { GameProgress.SetSandboxUnlocked(component.m_sandboxIdentifier, true); } this.buttonUnlockKey = string.Format("SandboxLevelButton_{0}", component.m_sandboxIdentifier); bool flag = GameProgress.GetFullVersionUnlocked() || GameProgress.GetSandboxUnlocked(component.m_sandboxIdentifier) || (component.m_sandboxIdentifier.Equals("S-F") && GameProgress.GetSandboxUnlocked("S-F")); if (flag) { if (GameProgress.GetButtonUnlockState(this.buttonUnlockKey) == GameProgress.ButtonUnlockState.Locked) { this.episodeSelector.StartCoroutine(this.UnlockSequence()); } } else { GameProgress.SetButtonUnlockState(this.buttonUnlockKey, GameProgress.ButtonUnlockState.Locked); Transform transform = base.transform.Find("StarSet"); if (transform != null) { transform.gameObject.SetActive(false); } } return; } SandboxSkullLevelButton component2 = base.GetComponent <SandboxSkullLevelButton>(); if (component2 != null) { if (!GameProgress.GetSandboxUnlocked(component2.m_sandboxIdentifier)) { GameProgress.SetSandboxUnlocked(component2.m_sandboxIdentifier, true); } this.buttonUnlockKey = string.Format("SandboxLevelButton_{0}", component2.m_sandboxIdentifier); bool flag2 = GameProgress.GetFullVersionUnlocked() || GameProgress.GetSandboxUnlocked(component2.m_sandboxIdentifier); if (flag2) { if (GameProgress.GetButtonUnlockState(this.buttonUnlockKey) == GameProgress.ButtonUnlockState.Locked) { this.episodeSelector.StartCoroutine(this.UnlockSequence()); } else { GameProgress.SetButtonUnlockState(this.buttonUnlockKey, GameProgress.ButtonUnlockState.Locked); Transform transform2 = base.transform.Find("StarSet"); if (transform2 != null) { transform2.gameObject.SetActive(false); } } } } }
private void Start() { if (this.isBigSandboxButton && base.transform.parent != null) { this.m_sandboxSelector = base.transform.parent.GetComponent <SandboxSelector>(); } if (this.m_sandboxSelector == null && base.transform.parent != null && base.transform.parent.parent != null) { this.m_sandboxSelector = base.transform.parent.parent.GetComponent <SandboxSelector>(); } this.starSet = base.transform.Find("StarSet"); if (this.starSet != null && !this.isBigSandboxButton) { this.starSet.parent = base.transform.parent; } UnlockSandboxSequence component = base.GetComponent <UnlockSandboxSequence>(); bool flag = GameProgress.GetSandboxUnlocked(this.m_sandboxIdentifier); bool isOdyssey = Singleton <BuildCustomizationLoader> .Instance.IsOdyssey; if (isOdyssey && (this.m_sandboxIdentifier.Equals("S-M") || this.m_sandboxIdentifier.Equals("S-F"))) { flag = true; } if (!flag && this.m_sandboxIdentifier.Equals("S-M")) { UnityEngine.Debug.LogError("SandboxLevelButton S-M"); int cost = this.GetUnlockPrice(this.m_sandboxIdentifier); this.AddSMSandboxUnlockDialog(base.GetComponent <Button>(), cost, this.m_sandboxIdentifier, () => GameProgress.SnoutCoinCount() >= cost); } else if (!flag && this.m_sandboxIdentifier.Equals("S-F")) { this.AddBuyFieldOfDreamsButton(base.GetComponent <Button>()); } else if (!flag && !isOdyssey) { if (SandboxLevelButton.sandboxUnlockDialog == null) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(Singleton <GameManager> .Instance.gameData.m_sandboxUnlockDialog); gameObject.transform.position = new Vector3(0f, 0f, -10f); SandboxLevelButton.sandboxUnlockDialog = gameObject.GetComponent <SandboxUnlockDialog>(); SandboxLevelButton.sandboxUnlockDialog.Close(); } int cost = this.GetUnlockPrice(this.m_sandboxIdentifier); this.AddSandboxUnlockDialog(base.GetComponent <Button>(), SandboxLevelButton.sandboxUnlockDialog, this.m_sandboxIdentifier, cost, () => GameProgress.SnoutCoinCount() >= cost); } else if (!flag && isOdyssey) { TooltipInfo component2 = base.GetComponent <TooltipInfo>(); if (component2 != null) { this.setTooltipButton = base.GetComponent <Button>(); this.setTooltipButton.MethodToCall.SetMethod(component2, "Show"); } } GameProgress.ButtonUnlockState buttonUnlockState = GameProgress.GetButtonUnlockState("SandboxLevelButton_" + this.m_sandboxIdentifier); if (flag) { if (component == null && buttonUnlockState == GameProgress.ButtonUnlockState.Locked) { base.gameObject.AddComponent <UnlockSandboxSequence>(); } Button component3 = base.GetComponent <Button>(); component3.MethodToCall.SetMethod(this.m_sandboxSelector, "LoadSandboxLevel", this.m_sandboxIdentifier); string str = WPFMonoBehaviour.gameData.m_sandboxLevels.GetLevelData(this.m_sandboxIdentifier).m_starBoxCount.ToString(); this.m_starsText.text = GameProgress.SandboxStarCount(this.m_sandboxSelector.FindLevelFile(this.m_sandboxIdentifier)).ToString() + "/" + str; for (int i = 0; i < this.hideOnContentUnlocked.Length; i++) { this.hideOnContentUnlocked[i].SetActive(false); } } else if (!flag && this.m_starsText != null) { string arg = WPFMonoBehaviour.gameData.m_sandboxLevels.GetLevelData(this.m_sandboxIdentifier).m_starBoxCount.ToString(); this.m_starsText.text = string.Format("{0}/{1}", 0, arg); for (int j = 0; j < this.hideOnContentLocked.Length; j++) { this.hideOnContentLocked[j].SetActive(false); } } }
private void Start() { if (base.transform.parent != null) { this.m_sandboxSelector = base.transform.parent.GetComponent <SandboxSelector>(); } this.starSet = base.transform.Find("StarSet"); this.collectSet = base.transform.Find("Set"); this.m_Limit = 10; bool isOdyssey = Singleton <BuildCustomizationLoader> .Instance.IsOdyssey; bool flag = false; string collectable = string.Empty; string arg = string.Empty; CollectableType collectableType = this.collectableType; if (collectableType != CollectableType.Skull) { if (collectableType == CollectableType.Statue) { flag = (GameProgress.SecretStatueCount() >= this.m_Limit || GameProgress.GetSandboxUnlocked(this.m_sandboxIdentifier)); collectable = "Statues"; arg = "[statue]"; } } else { flag = (GameProgress.SecretSkullCount() >= this.m_Limit || GameProgress.GetSandboxUnlocked(this.m_sandboxIdentifier)); collectable = "Skulls"; arg = "[skull]"; } GameProgress.ButtonUnlockState buttonUnlockState = GameProgress.GetButtonUnlockState("SandboxLevelButton_" + this.m_sandboxIdentifier); if (flag && buttonUnlockState == GameProgress.ButtonUnlockState.Locked && base.GetComponent <UnlockSandboxSequence>() == null) { base.gameObject.AddComponent <UnlockSandboxSequence>(); } if (flag) { Button component = base.GetComponent <Button>(); component.MethodToCall.SetMethod(this.m_sandboxSelector.gameObject.GetComponent <SandboxSelector>(), "LoadSandboxLevel", this.m_sandboxIdentifier); if (this.collectSet != null) { this.collectSet.gameObject.SetActive(false); } if (this.starSet != null) { this.starSet.gameObject.SetActive(true); } string str = WPFMonoBehaviour.gameData.m_sandboxLevels.GetLevelData(this.m_sandboxIdentifier).m_starBoxCount.ToString(); this.m_starsText.text = GameProgress.SandboxStarCount(this.m_sandboxSelector.FindLevelFile(this.m_sandboxIdentifier)).ToString() + "/" + str; } else { if (this.starSet != null) { this.starSet.gameObject.SetActive(false); } int num = 0; CollectableType collectableType2 = this.collectableType; if (collectableType2 != CollectableType.Skull) { if (collectableType2 == CollectableType.Statue) { num = GameProgress.SecretStatueCount(); } } else { num = GameProgress.SecretSkullCount(); } this.m_Text.text = string.Format("{0} {1}/{2}", arg, num, this.m_Limit); this.m_Text.SendMessage("TextUpdated", SendMessageOptions.DontRequireReceiver); if (isOdyssey) { TooltipInfo component2 = base.GetComponent <TooltipInfo>(); if (component2 != null) { Button component3 = base.GetComponent <Button>(); component3.MethodToCall.SetMethod(component2, "Show"); component3.Lock(false); } } else { string id = (this.collectableType != CollectableType.Statue) ? "sandbox_unlock_skull_collectable" : "sandbox_unlock_statue_collectable"; int num2 = Singleton <VirtualCatalogManager> .Instance.GetProductPrice(id); if (num2 <= 0) { num2 = 50; } int cost = (this.m_Limit - num) * num2; this.AddUnlockPopup(base.GetComponent <Button>(), this.m_sandboxIdentifier, collectable, num, this.m_Limit, cost, () => GameProgress.SnoutCoinCount() >= cost); } } }
private void Start() { bool flag = false; bool flag2 = false; bool flag3 = GameProgress.GetRaceLevelUnlocked(this.m_raceLevelIdentifier) || GameProgress.AllLevelsUnlocked(); bool flag4 = LevelInfo.IsContentLimited(-1, this.m_levelNumber); bool flag5 = GameProgress.IsLevelAdUnlocked(this.m_raceLevelIdentifier); int levelIndex = this.m_raceLevelSelector.m_raceLevels.GetLevelIndex(this.m_raceLevelIdentifier); if (levelIndex > 0) { RaceLevels.LevelData levelData = this.m_raceLevelSelector.m_raceLevels.Levels[levelIndex - 1]; int @int = GameProgress.GetInt(levelData.SceneName + "_stars", 0, GameProgress.Location.Local, null); if (GameProgress.GetRaceLevelUnlocked(levelData.m_identifier) && @int > 0) { flag = true; } if (GameProgress.GetRaceLevelUnlocked(levelData.m_identifier) || GameProgress.AllLevelsUnlocked()) { flag2 = true; } } if (!Singleton <BuildCustomizationLoader> .Instance.IsOdyssey && flag2 && !flag3) { int cost = Singleton <VirtualCatalogManager> .Instance.GetProductPrice("road_hogs_level_unlock"); this.AddRoadHogsUnlockDialog(base.GetComponent <Button>(), this.m_raceLevelIdentifier, cost, () => GameProgress.SnoutCoinCount() >= cost); } else if (!flag3) { Animation animation = base.gameObject.AddComponent <Animation>(); animation.AddClip(this.shake, this.shake.name); ButtonAnimation buttonAnimation = base.gameObject.AddComponent <ButtonAnimation>(); buttonAnimation.PlayWholeAnimation = true; buttonAnimation.ActivateAnimationName = this.shake.name; base.gameObject.AddComponent <InactiveButton>(); } if (!flag4 && flag && !flag3) { GameProgress.SetRaceLevelUnlocked(this.m_raceLevelIdentifier, true); } if (flag4 && (flag || flag2 || flag5)) { flag4 = false; } GameProgress.ButtonUnlockState buttonUnlockState = GameProgress.GetButtonUnlockState("RaceLevelButton_" + this.m_raceLevelIdentifier); if (flag3 && buttonUnlockState == GameProgress.ButtonUnlockState.Locked && !flag4) { base.StartCoroutine(this.UnlockNowSequence()); } if ((flag3 && !flag4) || !base.transform.Find("Lock")) { Button component = base.GetComponent <Button>(); component.MethodToCall.SetMethod(this.m_raceLevelSelector.gameObject.GetComponent <RaceLevelSelector>(), "LoadRaceLevel", this.m_raceLevelIdentifier); string sceneName = WPFMonoBehaviour.gameData.FindRaceLevel(this.m_raceLevelIdentifier).SceneName; int int2 = GameProgress.GetInt(this.m_raceLevelSelector.FindLevelFile(this.m_raceLevelIdentifier) + "_stars", 0, GameProgress.Location.Local, null); bool flag6 = GameProgress.HasCollectedSnoutCoins(sceneName, 0); bool flag7 = GameProgress.HasCollectedSnoutCoins(sceneName, 1); bool flag8 = GameProgress.HasCollectedSnoutCoins(sceneName, 2); GameObject[] array = new GameObject[] { component.transform.Find("StarSet/Star1").gameObject, component.transform.Find("StarSet/Star2").gameObject, component.transform.Find("StarSet/Star3").gameObject, component.transform.Find("CoinSet/Star1").gameObject, component.transform.Find("CoinSet/Star2").gameObject, component.transform.Find("CoinSet/Star3").gameObject }; int num = 0; if (flag6) { num++; } if (flag7) { num++; } if (flag8) { num++; } for (int i = 0; i < 3; i++) { bool flag9 = i + 1 <= int2; bool flag10 = i + 1 <= num || Singleton <BuildCustomizationLoader> .Instance.IsOdyssey; array[i].SetActive(flag9 && !flag10); array[i + 3].SetActive(flag9 && flag10); } string sceneName2 = this.m_raceLevelSelector.m_raceLevels.GetLevelData(this.m_raceLevelIdentifier).SceneName; if (GameProgress.HasBestTime(sceneName2)) { float num2 = Mathf.Clamp(GameProgress.GetBestTime(sceneName2), 0f, 3599.99f); TimeSpan timeSpan = TimeSpan.FromSeconds((double)num2); base.transform.Find("BestTime").GetComponent <TextMesh>().text = string.Format("{0:D2}:{1:D2}.{2:D2}", timeSpan.Minutes, timeSpan.Seconds, timeSpan.Milliseconds / 10); base.transform.Find("BestTime").gameObject.SetActive(true); base.transform.Find("TimeBG").gameObject.SetActive(true); } } else { base.transform.Find("StarSet").gameObject.SetActive(false); base.transform.Find("CoinSet").gameObject.SetActive(false); base.transform.Find("BestTime").gameObject.SetActive(false); base.transform.Find("TimeBG").gameObject.SetActive(false); } }
private void UpgradeDataFormatVersion(bool isNewGameProgress = false) { int num = GameProgress.GetInt("DataFormatVersion", 1, GameProgress.Location.Local, null); if (num == 1) { for (int i = 1; i <= 4; i++) { if (GameProgress.m_data.GetBool("sandbox_unlocked_" + i.ToString(), false)) { GameProgress.m_data.SetBool("sandbox_unlocked_S-" + i.ToString(), true); GameProgress.m_data.DeleteKey("sandbox_unlocked_" + i.ToString()); } if (GameProgress.GetButtonUnlockState("SandboxLevelButton_" + i.ToString()) == GameProgress.ButtonUnlockState.Unlocked) { GameProgress.SetButtonUnlockState("SandboxLevelButton_S-" + i.ToString(), GameProgress.ButtonUnlockState.Unlocked); GameProgress.m_data.DeleteKey("button_unlock_SandboxLevelButton_" + i.ToString()); } } num = 2; GameProgress.SetInt("DataFormatVersion", num, GameProgress.Location.Local); } if (num == 2) { UserSettings.SetInt("Episode2LevelSelection_active_page", 0); num = 3; GameProgress.SetInt("DataFormatVersion", num, GameProgress.Location.Local); } if (num == 3) { num = 4; GameProgress.SetInt("DataFormatVersion", num, GameProgress.Location.Local); } if (num == 4) { try { for (int j = 0; j < 6; j++) { List <string> levelNames = LevelInfo.GetLevelNames(j); for (int k = 0; k < levelNames.Count; k++) { if (GameProgress.m_data.GetBool(levelNames[k] + "_challenge_" + 1, false)) { GameProgress.m_data.DeleteKey(levelNames[k] + "_challenge_" + 1); GameProgress.m_data.SetInt(levelNames[k] + "_challenge_" + 1, 1); } if (GameProgress.m_data.GetBool(levelNames[k] + "_challenge_" + 2, false)) { GameProgress.m_data.DeleteKey(levelNames[k] + "_challenge_" + 2); GameProgress.m_data.SetInt(levelNames[k] + "_challenge_" + 2, 1); } } } foreach (RaceLevels.LevelData level in Singleton <GameManager> .Instance.gameData.m_raceLevels.Levels) { string arg = level.SceneName; if (GameProgress.m_data.GetBool(arg + "_challenge_" + 1, false)) { GameProgress.m_data.DeleteKey(arg + "_challenge_" + 1); GameProgress.m_data.SetInt(arg + "_challenge_" + 1, 1); } if (GameProgress.m_data.GetBool(arg + "_challenge_" + 2, false)) { GameProgress.m_data.DeleteKey(arg + "_challenge_" + 2); GameProgress.m_data.SetInt(arg + "_challenge_" + 2, 1); } } } catch { } num = 5; GameProgress.SetInt("DataFormatVersion", num, GameProgress.Location.Local); } if (num == 5) { int[] array = new int[3]; int[] array2 = new int[3]; int num2 = 0; int num3 = 0; int num4 = GameProgress.SecretSkullCount(); int num5 = GameProgress.SecretStatueCount(); foreach (Episode episode in GameProgress.instance.m_gameData.m_episodeLevels) { int num6 = 0; foreach (EpisodeLevelInfo episodeLevelInfo in episode.LevelInfos) { int @int = GameProgress.GetInt(episodeLevelInfo.sceneName + "_stars", 0, GameProgress.Location.Local, null); bool flag = LevelInfo.IsStarLevel(num3, num6); for (int l = 0; l < Mathf.Clamp(@int, 0, 3); l++) { if (flag) { array2[l]++; } else { array[l]++; } } num6++; } num3++; } foreach (SandboxLevels.LevelData levelData in GameProgress.instance.m_gameData.m_sandboxLevels.Levels) { num2 += GameProgress.GetInt(levelData.SceneName + "_stars", 0, GameProgress.Location.Local, null); } foreach (RaceLevels.LevelData levelData2 in GameProgress.instance.m_gameData.m_raceLevels.Levels) { int int2 = GameProgress.GetInt(levelData2.SceneName + "_stars", 0, GameProgress.Location.Local, null); for (int m = 0; m < Mathf.Clamp(int2, 0, 3); m++) { array[m]++; } } Dictionary <PlayerProgress.ExperienceType, int> dictionary = new Dictionary <PlayerProgress.ExperienceType, int>(); int num7 = 0; int num8 = 3; for (int n = 0; n < 3; n++) { if (array[n] > 0) { dictionary.Add((PlayerProgress.ExperienceType)(num7 + n), array[n]); } if (array2[n] > 0) { dictionary.Add((PlayerProgress.ExperienceType)(num8 + n), array2[n]); } } if (num2 > 0) { dictionary.Add(PlayerProgress.ExperienceType.StarBoxCollectedSandbox, num2); } if (num4 > 0) { dictionary.Add(PlayerProgress.ExperienceType.HiddenSkullFound, num4); if (num4 >= GameProgress.MaxSkullCount()) { dictionary.Add(PlayerProgress.ExperienceType.AllHiddenSkullsFound, 1); } } if (num5 > 0) { dictionary.Add(PlayerProgress.ExperienceType.HiddenStatueFound, num5); if (num4 >= GameProgress.MaxStatueCount()) { dictionary.Add(PlayerProgress.ExperienceType.AllHiddenStatuesFound, 1); } } PlayerProgress.AddPendingExperience(dictionary); num = 6; GameProgress.SetInt("DataFormatVersion", num, GameProgress.Location.Local); } GameProgress.SetString("LastKnownVersion", Singleton <BuildCustomizationLoader> .Instance.ApplicationVersion, GameProgress.Location.Local); }