// Put anything in here that should happen as a result of the pet using the daily inhaler. private void GameDone() { InhalerGameUIManager.Instance.StopShowHintTimer(); StatsManager.Instance.ChangeStats(healthDelta: 20, hungerDelta: 80, isInternal: true); DateTime now = LgDateTime.GetTimeNow(); DateTime then = DataManager.Instance.GameData.Inhaler.LastPlayPeriodUsed; TimeSpan lastTimeSinceInhaler = now - then; if (lastTimeSinceInhaler.TotalHours > 24) { DataManager.Instance.GameData.Inhaler.timesUsedInARow = 0; } DataManager.Instance.GameData.Inhaler.timesUsedInARow++; // Save settings into DataManager IsFirstTimeRescue = false; DataManager.Instance.GameData.Inhaler.LastPlayPeriodUsed = PlayPeriodLogic.GetCurrentPlayPeriod(); DataManager.Instance.GameData.Inhaler.LastInhalerPlayTime = LgDateTime.GetTimeNow(); // Finish inhaler tutorial if (!IsTutorialCompleted) { DataManager.Instance.GameData.Tutorial.ListPlayed.Add(TutorialManagerBedroom.TUT_INHALER); } // Send out a task completion event for the wellapad WellapadMissionController.Instance.TaskCompleted("DailyInhaler"); // Calculate the next play period for the inhaler PlayPeriodLogic.Instance.InhalerGameDonePostLogic(); // Show ending UI InhalerGameUIManager.Instance.GameEndUI(); }
/// <summary> /// Checks if inhaler can be used at the current time. /// Open if yes or show notification. /// </summary> private void CheckToOpenInhaler() { if (PlayPeriodLogic.Instance.CanUseEverydayInhaler()) { OpenRealInhaler(); } else { TimeFrames currentTimeFrame = PlayPeriodLogic.GetTimeFrame(LgDateTime.GetTimeNow()); string popupMessage; if (currentTimeFrame == TimeFrames.Morning) { popupMessage = "POPUP_INHALER_TONIGHT"; AudioManager.Instance.PlayClip("superWellaInhalerTonight"); } else { popupMessage = "POPUP_INHALER_MORNING"; AudioManager.Instance.PlayClip("superWellaInhalerMorning"); } // Display tutorial notification Hashtable notificationEntry = new Hashtable(); notificationEntry.Add(NotificationPopupData.PrefabName, "PopupInhalerRecharging"); notificationEntry.Add(NotificationPopupData.Title, null); notificationEntry.Add(NotificationPopupData.Message, Localization.Localize(popupMessage)); notificationEntry.Add(NotificationPopupData.SpecialButtonCallback, null); NotificationUIManager.Instance.AddToQueue(notificationEntry); } }
/// <summary> /// Refreshs check. /// Function that checks to see if the wellapad missions /// list should be refreshed. If it should, it will /// delete the current save data. /// </summary> public void RefreshCheck() { //do not refresh wellapad task for lite version // if(VersionManager.IsLite()) return; DateTime now = LgDateTime.GetTimeNow(); TimeSpan sinceCreated = now - DataManager.Instance.GameData.Wellapad.DateMissionsCreated; // the list needs to be refreshed if it has been more than 12 hours from creation OR the creation time frame (morning/evening) // is different than the current time frame (morning/evening) DateTime dateMissionsCreated = DataManager.Instance.GameData.Wellapad.DateMissionsCreated; bool IsRefresh = sinceCreated.TotalHours >= 12 || PlayPeriodLogic.GetTimeFrame(now) != PlayPeriodLogic.GetTimeFrame(dateMissionsCreated); //bool IsRefresh = needMission; // alert...if the user has not finished the last tutorial, no matter what, don't refresh /*if(!DataManager.Instance.GameData.Tutorial.AreTutorialsFinished()) * IsRefresh = false;*/ // if we have to refresh, just delete our data...the missions list will take it from there if (IsRefresh) { //Before reseting mission. Go through current mission and send failed tasks to analytics server foreach (KeyValuePair <string, MutableDataWellapadTask> taskList in DataManager.Instance.GameData.Wellapad.CurrentTasks) { MutableDataWellapadTask _task = taskList.Value; //task is incomplete if (_task.Completed == WellapadTaskCompletionStates.Uncompleted) { Analytics.Instance.WellapadTaskEvent(Analytics.TASK_STATUS_FAIL, _task.TaskID, _task.TaskID); if (_task.TaskID == "DailyInhaler") { Analytics.Instance.DidUseInhaler(false); } } } DataManager.Instance.GameData.Wellapad.ResetMissions(); //AddDefaultMissions(); // have the screens of the wellapad refresh before we send out the event below, because we want to make sure the // missions screen is active //WellapadUIManager.Instance.RefreshScreen(); // send event if (OnMissionsRefreshed != null) { OnMissionsRefreshed(this, EventArgs.Empty); } IsRefresh = false; } }
/// <summary> /// Depending on how long the player has been away and what time of day it is, return the number of /// new triggers that should spawn. /// <summary> private int GetNewTriggerCount() { int newTriggers = 0; MutableDataDegradation degradationData = DataManager.Instance.GameData.Degradation; int playPeriodsOffset = GetNumPlayPeriodsOffset(); //There are missed play periods if (playPeriodsOffset > 1) { //max of 2 missed play period will be accounted if (playPeriodsOffset > 2) { playPeriodsOffset = 2; } //calculate num of new triggers newTriggers = playPeriodsOffset * 3; //update lastTriggerSpawnedPlayPeriod. Important that we update it here //otherwise more triggers will be spawned if user return from pause degradationData.LastPlayPeriodTriggerSpawned = PlayPeriodLogic.GetCurrentPlayPeriod(); Debug.Log("Missed play periods spawning " + newTriggers + "triggers"); } //No missed play periods. spawn triggers for Next Play Period else { DateTime now = LgDateTime.GetTimeNow(); DateTime lastTriggerSpawnedPlayPeriod = degradationData.LastPlayPeriodTriggerSpawned; TimeSpan timeSinceLastTriggerSpawned = now - lastTriggerSpawnedPlayPeriod; //only spawn new trigger if time hasn't been rewind somehow if (lastTriggerSpawnedPlayPeriod <= now) { //new play period need to refresh variable if (timeSinceLastTriggerSpawned.TotalHours >= 12) { degradationData.IsTriggerSpawned = false; } if (!degradationData.IsTriggerSpawned) { newTriggers = 3; degradationData.IsTriggerSpawned = true; degradationData.LastPlayPeriodTriggerSpawned = PlayPeriodLogic.GetCurrentPlayPeriod(); } } } return(newTriggers); }
void OnGUI() { GUI.Label(new Rect(50, 50, 200, 50), "Current PP: " + PlayPeriodLogic.GetCurrentPlayPeriod().ToString(), style); GUI.Label(new Rect(80, 100, 200, 50), "Last PP: " + PlayPeriodLogic.Instance.GetLastPlayPeriod().ToString(), style); }
private void Init() { LastPlayPeriodTriggerSpawned = PlayPeriodLogic.GetCurrentPlayPeriod(); IsTriggerSpawned = false; UncleanedTriggers = 0; }
/// <summary> /// Determines whether new minipet locations should be spawned, also flags the datetime automatically /// Only call once per a play period all furture calls will be false /// </summary> public bool CanSpawnNewMinipetLocations() { // Debug.Log("---Checking can spawn minipets " + DataManager.Instance.GameData.MiniPetLocations.LastestPlayPeriodUpdated + " " + PlayPeriodLogic.GetCurrentPlayPeriod()); if (DataManager.Instance.GameData.MiniPetLocations.LastestPlayPeriodUpdated < PlayPeriodLogic.GetCurrentPlayPeriod()) { DataManager.Instance.GameData.MiniPetLocations.LastestPlayPeriodUpdated = PlayPeriodLogic.GetCurrentPlayPeriod(); // Debug.Log("----SPAWN NEW LOCATIONS?: YES"); if (UnityEngine.Random.Range(0, 4) == 0) { merchantSpawnChance = true; DataManager.Instance.GameData.MiniPetLocations.SetMerchantSpawning(merchantSpawnChance); } else { merchantSpawnChance = false; DataManager.Instance.GameData.MiniPetLocations.SetMerchantSpawning(merchantSpawnChance); } return(true); } else { // Debug.Log("----SPAWN NEW LOCATIONS?: NO"); return(false); } }