using System; using System.Collections.Generic; using CIG.Translation; using SUISS.Core; using UnityEngine; public class ComeBackNotificationsManager : MonoBehaviour, IHasNotification { private void Start() { SingletonMonobehaviour.Instance.HasNotification(this); } private void OnDestroy() { if (SingletonMonobehaviour.IsAvailable) { SingletonMonobehaviour.Instance.NoLongerHasNotification(this); } } private int GetDaysInSeconds(int day) { return 86400 * day; } private void LoadLocalisations() { for (int i = 0; i < this._possibleNotifications.Length; i++) { this._possibleNotifications[i] = Localization.Key("come_back_notification" + (i + 1)); } } private ILocalizedString[] RandomizedNotificationTexts() { ILocalizedString[] possibleNotifications = this._possibleNotifications; for (int i = 0; i < possibleNotifications.Length; i++) { int num = i + (int)(UnityEngine.Random.value * (float)(possibleNotifications.Length - i)); ILocalizedString localizedString = possibleNotifications[num]; possibleNotifications[num] = possibleNotifications[i]; possibleNotifications[i] = localizedString; } return possibleNotifications; } public PlannedNotification[] GetNotifications() { this.LoadLocalisations(); ILocalizedString[] array = this.RandomizedNotificationTexts(); List list = new List(); list.Add(new PlannedNotification(this.GetDaysInSeconds(7), array[0], false)); int num = 1; for (int i = 1; i <= 16; i *= 2) { if (num >= array.Length) { array = this.RandomizedNotificationTexts(); num = 0; } list.Add(new PlannedNotification(this.GetDaysInSeconds(15 * i), array[num], false)); num++; } return list.ToArray(); } private ILocalizedString[] _possibleNotifications = new ILocalizedString[7]; }