Ejemplo n.º 1
0
        public void Clear(ICounterId id, out IEnumerable <ICounterId> clearObjects)
        {
            var list      = new List <ICounterId>();
            var listClear = new List <NotificationBaseNode>();
            var node      = TryCreateNotificationNode(id);

            if (node.IsObject)
            {
                list.Add(id);
            }
            if (node.IsFinished)
            {
                listClear.Add(node);
            }
            RecurciveFindFinished(node, listClear);
            foreach (var clearNode in listClear)
            {
                if (clearNode.IsObject)
                {
                    list.Add(clearNode.NotifyId);
                }
                SetTreeValue(clearNode.NotifyId, -clearNode.Count.Value);
            }
            clearObjects = list;
        }
Ejemplo n.º 2
0
 public void SetClearObject(ICounterId id)
 {
     if (_saver.HasClearObject(id))
     {
         return;
     }
     _tree.SetObjectId(id, false);
     _saver.SetObject(id, false);
 }
Ejemplo n.º 3
0
 public void SetNewObject(ICounterId id)
 {
     if (_saver.HasNewObject(id) || _saver.HasClearObject(id))
     {
         return;
     }
     _tree.SetObjectId(id, true);
     _saver.SetObject(id, true);
 }
Ejemplo n.º 4
0
        public void ClearNotify(ICounterId id)
        {
            IEnumerable <ICounterId> ids;

            _tree.Clear(id, out ids);
            foreach (var clearId in ids)
            {
                _saver.SetObject(clearId, false);
            }
        }
Ejemplo n.º 5
0
        public void Start()
        {
            var builder = CounterCreator.Builder;

            _root.ForEach(x => builder.AddNode(x.ToString()));
            _notifyId = builder.Build();
            _service.GetNotification(_notifyId).Subscribe(x => {
                _notification?.SetFormatValue(x);
            }).AddTo(gameObject);
        }
Ejemplo n.º 6
0
        public void SetObjectId(ICounterId id, bool isNew)
        {
            var node = TryCreateNotificationNode(id);

            if (!node.IsFinished)
            {
                throw new Exception("Attempting to set a value for a summing counter");
            }
            node.SetObject();
            SetTreeValue(id, isNew ? 1 : -1);
        }
Ejemplo n.º 7
0
 public void SetObject(ICounterId id, bool isNew)
 {
     if (isNew)
     {
         _notificationsNew.Add(id.StringId);
     }
     else
     {
         _notificationsNew.Remove(id.StringId);
         _notificationsClear.Add(id.StringId);
     }
     Save();
 }
Ejemplo n.º 8
0
        private void SetTreeValue(ICounterId id, int value)
        {
            var parent = Root;

            foreach (var nodeId in id.Nodes)
            {
                NotificationBaseNode child;
                if (!parent.Childs.TryGetValue(nodeId, out child))
                {
                    throw new Exception($"Unknow id = {id.StringId}");
                }
                child.ChangeValue(value);
                parent = child;
            }
        }
Ejemplo n.º 9
0
        public void SetValue(ICounterId id, int value)
        {
            var node = TryCreateNotificationNode(id);

            if (!node.IsFinished)
            {
                throw new Exception("Attempting to set a value for a summing counter");
            }
            var change = value - node.Count.Value;

            if (change == 0)
            {
                return;
            }
            SetTreeValue(id, change);
        }
Ejemplo n.º 10
0
        public NotificationBaseNode TryCreateNotificationNode(ICounterId id)
        {
            var parent = Root;

            foreach (var nodeId in id.Nodes)
            {
                NotificationBaseNode child;
                if (!parent.Childs.TryGetValue(nodeId, out child))
                {
                    child = new NotificationBaseNode(nodeId, parent);
                    parent.Childs.Add(nodeId, child);
                }
                parent = child;
            }
            return(parent);
        }
Ejemplo n.º 11
0
 public void SetValue(ICounterId counterId)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 12
0
        public IReadOnlyReactiveProperty <int> GetNotificationValue(ICounterId id)
        {
            var node = TryCreateNotificationNode(id);

            return(node.Count);
        }
Ejemplo n.º 13
0
 public void SetCount(ICounterId id, int count)
 {
     _tree.SetValue(id, count);
 }
Ejemplo n.º 14
0
 public void RefreshObject(ICounterId id)
 {
     _saver.RefreshObject(id);
 }
Ejemplo n.º 15
0
 public void RefreshObject(ICounterId id)
 {
     _notificationsClear.Remove(id.StringId);
 }
Ejemplo n.º 16
0
 public bool HasClearObject(ICounterId id)
 {
     return(_notificationsClear.Contains(id.StringId));
 }
Ejemplo n.º 17
0
 public IReadOnlyReactiveProperty <int> GetNotification(ICounterId id)
 {
     return(_tree.GetNotificationValue(id));
 }