/// <summary> /// Save the current state including free prize times /// </summary> public override void SaveState() { MyDebug.Log("FreePrizeManager: SaveState"); PreferencesFactory.SetString("FreePrize.NextCountdownStart", NextCountdownStart.ToString(CultureInfo.InvariantCulture)); PreferencesFactory.SetString("FreePrize.NextPrize", NextFreePrizeAvailable.ToString(CultureInfo.InvariantCulture)); PreferencesFactory.Save(); }
/// <summary> /// Save the current state including free prize times /// </summary> public override void SaveState() { MyDebug.Log("FreePrizeManager: SaveState"); PlayerPrefs.SetString("FreePrize.NextCountdownStart", NextCountdownStart.ToString()); PlayerPrefs.SetString("FreePrize.NextPrize", NextFreePrizeAvailable.ToString()); PlayerPrefs.Save(); }
/// <summary> /// Recalculate new times for a new countdown /// </summary> public void StartNewCountdown() { float seconds = DateTimeUtils.SecondsTillMidnight(); NextCountdownStart = UnbiasedTime.Instance.Now().AddSeconds(UnityEngine.Random.Range(DelayRangeToNextCountdown.Min, DelayRangeToNextCountdown.Max + 1)); NextFreePrizeAvailable = NextCountdownStart.AddSeconds(seconds); SaveState(); }
/// <summary> /// Recalculate new times for a new countdown /// </summary> public void StartNewCountdown() { SetCurrentPrizeAmount(); NextCountdownStart = DateTime.UtcNow.AddSeconds(UnityEngine.Random.Range(DelayRangeToNextCountdown.Min, DelayRangeToNextCountdown.Max + 1)); NextFreePrizeAvailable = NextCountdownStart.AddSeconds(UnityEngine.Random.Range(TimeRangeToNextPrize.Min, TimeRangeToNextPrize.Max + 1)); SaveState(); }
/// <summary> /// Returns the time until the next countdown will start. /// </summary> /// <returns></returns> TimeSpan GetTimeToCountdown() { return(NextCountdownStart.Subtract(DateTime.UtcNow)); }
/// <summary> /// Returns the time until the next countdown will start. /// </summary> /// <returns></returns> TimeSpan GetTimeToCountdown() { return(NextCountdownStart.Subtract(UnbiasedTime.Instance.Now())); }