您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

70 行
2.0 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using CIG.Translation;
  4. using SUISS.Core;
  5. using UnityEngine;
  6. public class ComeBackNotificationsManager : MonoBehaviour, IHasNotification
  7. {
  8. private void Start()
  9. {
  10. SingletonMonobehaviour<CIGLocalNotificationManager>.Instance.HasNotification(this);
  11. }
  12. private void OnDestroy()
  13. {
  14. if (SingletonMonobehaviour<CIGLocalNotificationManager>.IsAvailable)
  15. {
  16. SingletonMonobehaviour<CIGLocalNotificationManager>.Instance.NoLongerHasNotification(this);
  17. }
  18. }
  19. private int GetDaysInSeconds(int day)
  20. {
  21. return 86400 * day;
  22. }
  23. private void LoadLocalisations()
  24. {
  25. for (int i = 0; i < this._possibleNotifications.Length; i++)
  26. {
  27. this._possibleNotifications[i] = Localization.Key("come_back_notification" + (i + 1));
  28. }
  29. }
  30. private ILocalizedString[] RandomizedNotificationTexts()
  31. {
  32. ILocalizedString[] possibleNotifications = this._possibleNotifications;
  33. for (int i = 0; i < possibleNotifications.Length; i++)
  34. {
  35. int num = i + (int)(UnityEngine.Random.value * (float)(possibleNotifications.Length - i));
  36. ILocalizedString localizedString = possibleNotifications[num];
  37. possibleNotifications[num] = possibleNotifications[i];
  38. possibleNotifications[i] = localizedString;
  39. }
  40. return possibleNotifications;
  41. }
  42. public PlannedNotification[] GetNotifications()
  43. {
  44. this.LoadLocalisations();
  45. ILocalizedString[] array = this.RandomizedNotificationTexts();
  46. List<PlannedNotification> list = new List<PlannedNotification>();
  47. list.Add(new PlannedNotification(this.GetDaysInSeconds(7), array[0], false));
  48. int num = 1;
  49. for (int i = 1; i <= 16; i *= 2)
  50. {
  51. if (num >= array.Length)
  52. {
  53. array = this.RandomizedNotificationTexts();
  54. num = 0;
  55. }
  56. list.Add(new PlannedNotification(this.GetDaysInSeconds(15 * i), array[num], false));
  57. num++;
  58. }
  59. return list.ToArray();
  60. }
  61. private ILocalizedString[] _possibleNotifications = new ILocalizedString[7];
  62. }