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 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 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"); } }