Вы не можете выбрать более 25 тем
Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
|
- using System;
- using System.Collections.Generic;
- using CIG;
- using SUISS.Core;
- using SUISSEngine;
- using UnityEngine;
-
- public class CIGLocalNotificationManager : SingletonMonobehaviour<CIGLocalNotificationManager>
- {
- protected override void Awake()
- {
- base.Awake();
- this.CancelAllNotifications();
- }
-
- private void OnApplicationPause(bool paused)
- {
- if (!paused)
- {
- this.CancelAllNotifications();
- }
- else
- {
- this.SetNotifications();
- }
- }
-
- protected override void OnApplicationQuit()
- {
- base.OnApplicationQuit();
- this.SetNotifications();
- }
-
- public void HasNotification(IHasNotification hasNotification)
- {
- this._hasNotifications.Add(hasNotification);
- }
-
- public void NoLongerHasNotification(IHasNotification hasNoNotifiaction)
- {
- if (this._hasNotifications.Contains(hasNoNotifiaction))
- {
- this._hasNotifications.Remove(hasNoNotifiaction);
- }
- else
- {
- UnityEngine.Debug.LogWarning("HasNotifications doesn't contain this IHasNotification!");
- }
- }
-
- public void RequestPermissions()
- {
- }
-
- public void CancelAllNotifications()
- {
- }
-
- public bool AreNotificationsAllowed
- {
- get
- {
- return SingletonMonobehaviour<CIGTutorialManager>.IsAvailable && SingletonMonobehaviour<CIGGameStats>.IsAvailable && SingletonMonobehaviour<CIGTutorialManager>.Instance.IsFinished && SingletonMonobehaviour<CIGGameStats>.Instance.TimesCollected >= 5;
- }
- }
-
- private void SetNotifications()
- {
- if (!Singleton<CIGSettings>.Instance.NotificationsEnabled || !this.AreNotificationsAllowed)
- {
- return;
- }
- this.CancelAllNotifications();
- List<PlannedNotification> list = this.CollectNotifications();
- int count = list.Count;
- }
-
- private List<PlannedNotification> CollectNotifications()
- {
- List<PlannedNotification> list = new List<PlannedNotification>();
- int count = this._hasNotifications.Count;
- for (int i = 0; i < count; i++)
- {
- PlannedNotification[] notifications = this._hasNotifications[i].GetNotifications();
- int num = notifications.Length;
- for (int j = 0; j < num; j++)
- {
- PlannedNotification plannedNotification = notifications[j];
- if (plannedNotification.IsValid)
- {
- list.Add(plannedNotification);
- }
- }
- }
- list.Sort((PlannedNotification a, PlannedNotification b) => a.Seconds.CompareTo(b.Seconds));
- return list;
- }
-
- private List<IHasNotification> _hasNotifications = new List<IHasNotification>();
- }
|