private void InitStoreData() { VirtualCurrencies = StoreInfo.Currencies; VirtualGoods = StoreInfo.Goods; VirtualCurrencyPacks = StoreInfo.CurrencyPacks; VirtualGoodsDictionary = new Dictionary <string, VirtualGood>(); foreach (VirtualGood virtualGood in VirtualGoods) { VirtualGoodsDictionary.Add(virtualGood.ItemId, virtualGood); } this.UpdateStoreBalances(); Debug.Log("GNOME: Notifying Shop Data Initialized"); this.NotifyShopDataInitialized(); // Give 10 tokens for free if it's the first time playing if (PlayerPrefsFast.GetBool(SharedResources.FirstTimeUserKey, true)) { StoreInventory.GiveItem(GnomeStoreAssets.TokenId, 10); PlayerPrefsFast.SetBool(SharedResources.FirstTimeUserKey, false); PlayerPrefsFast.Flush(); } this.NotifyTokensChanged(); }
private void SetStartDialogSpecial(SpecialStage specialStage) { // Show the Quest Dialog if this is the first time playing the a level in the special stage string key = string.Format("{0}_{1}", SharedResources.SpecialStageStartQuestDialogShownKey, specialStage.StageId); bool shown = PlayerPrefsFast.GetBool(key, false); if (!shown) { this.CompletedImage.SetActive(false); this.gameObject.SetActive(true); foreach (GameObject dialog in this.StageMapping) { dialog.SetActive(false); } foreach (IdkyKeyValuePairGameObject specialStageMapping in this.SpecialStageMappings) { specialStageMapping.GetValue().SetActive(specialStageMapping.GetKey().Equals(specialStage.StageId)); } PlayerPrefsFast.SetBool(key, true); PlayerPrefsFast.Flush(); } }
private void Awake() { if (Instance != null && Instance != this) { Destroy(this.gameObject); } Instance = this; this.Paused = false; // Make sure music and sound fx is on by default if it's never been initialized if (!PlayerPrefsFast.HasKey(this.MusicOptionKey)) { PlayerPrefsFast.SetBool(this.MusicOptionKey, true); PlayerPrefsFast.Flush(); } if (!PlayerPrefsFast.HasKey(this.SoundOptionKey)) { PlayerPrefsFast.SetBool(this.SoundOptionKey, true); PlayerPrefsFast.Flush(); } this.CheckOptions(); this.BackgroundMusicSource = this.gameObject.AddComponent <AudioSource>(); this.BackgroundMusicSource.loop = true; this.ContinuousSoundSource = this.gameObject.AddComponent <AudioSource>(); this.ContinuousSoundSource.loop = true; DontDestroyOnLoad(this.gameObject); }
private void OnClick() { // Log what button the user clicked for rating us GoogleAnalyticsV3.instance.LogEvent(new EventHitBuilder().SetEventCategory("Rating").SetEventAction(this.Option.ToString())); PlayerPrefsFast.SetInt(this.OptionKey, (int)this.Option); PlayerPrefsFast.Flush(); }
public void OnStateChanged(bool state) { // Set the state this.CurrentState = state; this.EnableObjects(); // Save the state PlayerPrefsFast.SetBool(this.OptionKey, state); PlayerPrefsFast.Flush(); SoundManager.Instance.RecheckSounds(); }
private void OnSignedOut(object sender, EventArgs args) { if (Debug.isDebugBuild) { Debug.Log("Signed Out"); } // Signed out, so next time don't silently sign in PlayerPrefsFast.SetBool(this.GooglePlusKey, false); PlayerPrefsFast.Flush(); this.SetActiveState(); }
public bool EnterHighScore(float score) { bool isNewHighScore = false; float highScore = PlayerPrefsFast.GetFloat(SharedResources.HighScoreKey, 0); if (score > highScore) { isNewHighScore = true; PlayerPrefsFast.SetFloat(SharedResources.HighScoreKey, score); PlayerPrefsFast.Flush(); FacebookManager.Instance.PostHighScore((uint)score); } return(isNewHighScore); }
private void SetEndDialogSpecial(SpecialStage specialStage) { // Show the Quest Dialog if all the special stages are beaten string key = string.Format("{0}_{1}", SharedResources.SpecialStageEndQuestDialogShownKey, specialStage.StageId); bool shown = PlayerPrefsFast.GetBool(key, false); if (!shown) { bool hasLevelIncomplete = false; foreach (int levelInStage in specialStage.LevelMapping.Keys) { string levelKey = string.Format( "{0}_{1}_{2}", SharedResources.TimesLevelPlayedToCompletePrefix, specialStage.StageId, levelInStage); int timesToCompleteLevel = PlayerPrefsFast.GetInt(levelKey, 0); // Check if the level has been completed yet if (timesToCompleteLevel == 0) { hasLevelIncomplete = true; break; } } if (!hasLevelIncomplete) { this.CompletedImage.SetActive(true); this.gameObject.SetActive(true); foreach (GameObject dialog in this.StageMapping) { dialog.SetActive(false); } foreach (IdkyKeyValuePairGameObject specialStageMapping in this.SpecialStageMappings) { specialStageMapping.GetValue().SetActive(specialStageMapping.GetKey().Equals(specialStage.StageId)); } PlayerPrefsFast.SetBool(key, true); PlayerPrefsFast.Flush(); } } }
public void UseTokensAndSkipLevel() { if (ShopManager.Instance.UseTokens(this.SkipLevelCost)) { // Log that the level was skipped with tokens GoogleAnalyticsV3.instance.LogEvent("Levels", "Skipped With Tokens", "Level " + this.Level, 1); // Unlock the next level int levelUnlocked = PlayerPrefsFast.GetInt(SharedResources.LevelUnlockedKey, this.Level); levelUnlocked++; PlayerPrefsFast.SetInt(SharedResources.LevelUnlockedKey, levelUnlocked); PlayerPrefsFast.Flush(); this.SkipLevel(); } }
private void OnSignInSucceeded(object sender, EventArgs args) { if (Debug.isDebugBuild) { Debug.Log("Sign In Succeeded"); } // Successfully signed in, so silently sign in next time PlayerPrefsFast.SetBool(this.GooglePlusKey, true); PlayerPrefsFast.Flush(); /* * if (this.clicked) * { * LevelDataInitializer.InitializeLevels(); * } */ this.clicked = false; this.SetActiveState(); }
private void Start() { // Get the current prize index int index = PlayerPrefsFast.GetInt(this.RewardIndexKey, 0); // Get the last time a reward was given string lastDateString = PlayerPrefsFast.GetString(this.LastDateRewardKey, string.Empty); DateTime lastDate; bool parsed = DateTime.TryParse(lastDateString, out lastDate); if (parsed) { // Give reward after 1 day if (lastDate.AddDays(1) <= DateTime.Now) { // Give reward, and then set it to the next index index++; List <Transform> childRewards = this.RewardsGrid.GetChildList(); // Make sure we don't give more rewards that we hvae set up if (index <= childRewards.Count) { foreach (Transform child in childRewards) { DailyReward dailyReward = child.GetComponent <DailyReward>(); if (dailyReward != null) { dailyReward.SetCurrentReward(index); if (dailyReward.Day == index) { this.centerOnChildTarget = child.GetComponent <UICenterOnChild>(); } } } PlayerPrefsFast.SetInt(this.RewardIndexKey, index); PlayerPrefsFast.SetString(this.LastDateRewardKey, DateTime.Now.ToString()); PlayerPrefsFast.Flush(); this.RewardsGrid.enabled = true; this.RewardsGrid.repositionNow = true; this.refreshGrid = true; } else { this.gameObject.SetActive(false); } } else { this.gameObject.SetActive(false); } } else { // It's the first time, so set the date as now PlayerPrefsFast.SetString(this.LastDateRewardKey, DateTime.Now.ToString()); PlayerPrefsFast.Flush(); this.gameObject.SetActive(false); } }
private void ApplyMove(MovementDirection direction) { Debug.Log(string.Format("Applying move {0}", direction.ToString())); if (this.selectedGamePiece != null && this.selectedGamePiece.GameBlock is IGameBlockParent) { Debug.Log("Applying move"); BlockMovement move; bool moveApplied = this.selectedGamePiece.ApplyMove(null, direction, out move); if (moveApplied) { Debug.Log("Move applied"); this.movesHistory.Push(move); if (this.firstMove) { this.firstMove = false; this.startLevelTime = Time.time; // Update the number of times played string key = this.specialStageMode ? string.Format( "{0}_{1}_{2}", SharedResources.TimesLevelPlayedPrefix, this.SpecialStage.StageId, this.Level) : string.Format("{0}_{1}", SharedResources.TimesLevelPlayedPrefix, this.Level); int timesPlayed = PlayerPrefsFast.GetInt(key, 0); timesPlayed++; PlayerPrefsFast.SetInt(key, timesPlayed); PlayerPrefsFast.Flush(); } this.goToNextLevel = this.GameBoard.IsSolved(); if (this.goToNextLevel) { this.endLevelTime = Time.time; bool fastComplete = this.endLevelTime - this.startLevelTime <= this.FastCompleteTime; // Set the number of times it took to complete this level. Only set this once. string key = this.specialStageMode ? string.Format( "{0}_{1}_{2}", SharedResources.TimesLevelPlayedToCompletePrefix, this.SpecialStage.StageId, this.Level) : string.Format("{0}_{1}", SharedResources.TimesLevelPlayedToCompletePrefix, this.Level); int timesToComplete = PlayerPrefsFast.GetInt(key, 0); if (timesToComplete == 0) { string timesPlayedKey = this.specialStageMode ? string.Format( "{0}_{1}_{2}", SharedResources.TimesLevelPlayedPrefix, this.SpecialStage.StageId, this.Level) : string.Format("{0}_{1}", SharedResources.TimesLevelPlayedPrefix, this.Level); timesToComplete = PlayerPrefsFast.GetInt(timesPlayedKey, 1); PlayerPrefsFast.SetInt(key, timesToComplete); bool beatOnFirstTry = timesToComplete == 1; bool beatOnTooManyTries = timesToComplete >= this.PlayedTooManyTimes; // Give a free token if passed on the first try if (beatOnFirstTry && fastComplete && !this.usedUndo) { ShopManager.Instance.GiveTokens(this.FastCompleteReward); this.ResultsScreenFreeToken.GetComponent <UILabel>().text = string.Format( "You earned {0} free tokens!", this.FastCompleteReward); } else if (beatOnFirstTry && !this.usedUndo) { ShopManager.Instance.GiveTokens(1); this.ResultsScreenFreeToken.GetComponent <UILabel>().text = "You earned a free token!"; } else if (beatOnTooManyTries) { this.PlayedTooManyTimesSounds.SetActive(true); } this.ResultsScreenFreeToken.SetActive(beatOnFirstTry && !usedUndo); } else { // This level has been beaten before, so no free token this.ResultsScreenFreeToken.SetActive(false); this.PlayedTooManyTimesSounds.SetActive(false); } if (!this.specialStageMode) { // Unlock the next level if needed int levelUnlocked = PlayerPrefsFast.GetInt(SharedResources.LevelUnlockedKey, this.Level); if (levelUnlocked <= this.Level) { levelUnlocked++; PlayerPrefsFast.SetInt(SharedResources.LevelUnlockedKey, levelUnlocked); } } // Log how many tries it took to complete the level string levelPlayed = this.specialStageMode ? string.Format("{0}_{1}", this.SpecialStage.StageId, this.Level) : this.Level.ToString(); GoogleAnalyticsV3.instance.LogEvent("Levels", "Completed Level", levelPlayed, timesToComplete); PlayerPrefsFast.Flush(); } } } else { Debug.Log("Gamepiece is null"); } }