您不能選擇超過 %s 個話題 話題必須以字母或數字為開頭,可包含連接號 ('-') 且最長為 35 個字
 
 
 

101 行
2.9 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using CIG;
  4. using SUISS.Core;
  5. using SUISSEngine;
  6. using UnityEngine;
  7. public class CIGLocalNotificationManager : SingletonMonobehaviour<CIGLocalNotificationManager>
  8. {
  9. protected override void Awake()
  10. {
  11. base.Awake();
  12. this.CancelAllNotifications();
  13. }
  14. private void OnApplicationPause(bool paused)
  15. {
  16. if (!paused)
  17. {
  18. this.CancelAllNotifications();
  19. }
  20. else
  21. {
  22. this.SetNotifications();
  23. }
  24. }
  25. protected override void OnApplicationQuit()
  26. {
  27. base.OnApplicationQuit();
  28. this.SetNotifications();
  29. }
  30. public void HasNotification(IHasNotification hasNotification)
  31. {
  32. this._hasNotifications.Add(hasNotification);
  33. }
  34. public void NoLongerHasNotification(IHasNotification hasNoNotifiaction)
  35. {
  36. if (this._hasNotifications.Contains(hasNoNotifiaction))
  37. {
  38. this._hasNotifications.Remove(hasNoNotifiaction);
  39. }
  40. else
  41. {
  42. UnityEngine.Debug.LogWarning("HasNotifications doesn't contain this IHasNotification!");
  43. }
  44. }
  45. public void RequestPermissions()
  46. {
  47. }
  48. public void CancelAllNotifications()
  49. {
  50. }
  51. public bool AreNotificationsAllowed
  52. {
  53. get
  54. {
  55. return SingletonMonobehaviour<CIGTutorialManager>.IsAvailable && SingletonMonobehaviour<CIGGameStats>.IsAvailable && SingletonMonobehaviour<CIGTutorialManager>.Instance.IsFinished && SingletonMonobehaviour<CIGGameStats>.Instance.TimesCollected >= 5;
  56. }
  57. }
  58. private void SetNotifications()
  59. {
  60. if (!Singleton<CIGSettings>.Instance.NotificationsEnabled || !this.AreNotificationsAllowed)
  61. {
  62. return;
  63. }
  64. this.CancelAllNotifications();
  65. List<PlannedNotification> list = this.CollectNotifications();
  66. int count = list.Count;
  67. }
  68. private List<PlannedNotification> CollectNotifications()
  69. {
  70. List<PlannedNotification> list = new List<PlannedNotification>();
  71. int count = this._hasNotifications.Count;
  72. for (int i = 0; i < count; i++)
  73. {
  74. PlannedNotification[] notifications = this._hasNotifications[i].GetNotifications();
  75. int num = notifications.Length;
  76. for (int j = 0; j < num; j++)
  77. {
  78. PlannedNotification plannedNotification = notifications[j];
  79. if (plannedNotification.IsValid)
  80. {
  81. list.Add(plannedNotification);
  82. }
  83. }
  84. }
  85. list.Sort((PlannedNotification a, PlannedNotification b) => a.Seconds.CompareTo(b.Seconds));
  86. return list;
  87. }
  88. private List<IHasNotification> _hasNotifications = new List<IHasNotification>();
  89. }