Пример #1
0
        public void Unsubscribe(ManagerEvents managerEvent, Subscription <TManager> subscription, Priority priority = Priority.Medium)
        {
            switch (priority)
            {
            default:
                if (_mediumSubscriptions.ContainsKey(managerEvent))
                {
                    _mediumSubscriptions[managerEvent].Remove(subscription);
                    _mediumSubscriptionsCache[managerEvent] = _mediumSubscriptions[managerEvent].ToArray();
                }
                break;

            case Priority.Low:
                if (_lowSubscriptions.ContainsKey(managerEvent))
                {
                    _lowSubscriptions[managerEvent].Remove(subscription);
                    _lowSubscriptionsCache[managerEvent] = _lowSubscriptions[managerEvent].ToArray();
                }
                break;

            case Priority.High:
                if (_highSubscriptions.ContainsKey(managerEvent))
                {
                    _highSubscriptions[managerEvent].Remove(subscription);
                    _highSubscriptionsCache[managerEvent] = _highSubscriptions[managerEvent].ToArray();
                }
                break;
            }

            CoreManager.Log(LogLevel.Info, $"{subscription.Target} Unsubscribed! ManagerEvent: \"{ managerEvent}\" Priority: {priority.ToString()}");
        }
Пример #2
0
        private void _Publish(ManagerEvents managerEvent, object[] arguments)
        {
            if (_highSubscriptionsCache.ContainsKey(managerEvent))
            {
                Subscription <TManager>[] array = _highSubscriptionsCache[managerEvent];
                foreach (Subscription <TManager> subscription in array)
                {
                    subscription(arguments);
                }
            }
            if (_mediumSubscriptionsCache.ContainsKey(managerEvent))
            {
                Subscription <TManager>[] array2 = _mediumSubscriptionsCache[managerEvent];
                foreach (Subscription <TManager> subscription2 in array2)
                {
                    subscription2(arguments);
                }
            }
            if (_lowSubscriptionsCache.ContainsKey(managerEvent))
            {
                Subscription <TManager>[] array3 = _lowSubscriptionsCache[managerEvent];
                foreach (Subscription <TManager> subscription3 in array3)
                {
                    subscription3(arguments);
                }
            }

            CoreManager.Log(LogLevel.Info, $"Published! ManagerEvent: \"{managerEvent}\"", arguments);
        }
        public override void Update(double gameTime)
        {
            if (ManagerEvents.Active)
            {
                return;
            }

            _counter += gameTime;
            if (_counter < _cooldown)
            {
                return;
            }

            var ownerSprite = GetComponent <Sprite>(ComponentType.Sprite);

            if (ownerSprite == null)
            {
                return;
            }
            foreach (var baseObject in _targetList)
            {
                var sprite = baseObject.GetComponent <Sprite>(ComponentType.Sprite);
                if (sprite != null)
                {
                    if (ManagerFunction.Distance(ownerSprite.Position, sprite.Position) < _distance)
                    {
                        ManagerEvents.AddEvents(_gameEvent);
                        _counter = 0;
                    }
                }
            }
        }
Пример #4
0
        protected bool Push(ManagerEvents managerEvent, params object[] arguments)
        {
            TManager manager = Manager;

            bool published = manager._OnPull(this, managerEvent, arguments);

            CoreManager.Log(LogLevel.Info, $"Push status: {published} , ManagerEvent: \"{managerEvent}\"", arguments);
            return(published);
        }
Пример #5
0
 public ScreenWorld(ManagerScreen managerScreen) : base(managerScreen)
 {
     _managerCamera = new ManagerCamera();
     _managerMap    = new ManagerMap("newmap", _managerCamera);
     _entities      = new Entities();
     _managerEvents = new ManagerEvents();
     _managerPlayer = new ManagerPlayer();
     //uglyyyyyyy
     FactoryDeathAnimation.Initailize(_managerCamera);
 }
Пример #6
0
 private void Awake()
 {
     if (instance != null)
     {
         Destroy(this.gameObject);
     }
     else
     {
         instance = this;
     }
 }
Пример #7
0
        public void StartEvent()
        {
            if (!ManagerEvents.Active)
            {
                var keys    = _gameEvents.Keys;
                var biggest = -1;
                foreach (int key in keys)
                {
                    if (key > biggest && ManagerLists.GetEventSwitchValue(key))
                    {
                        biggest = key;
                    }
                }

                if (biggest != -1)
                {
                    ManagerEvents.AddEvents(_gameEvents[biggest]);
                }
            }
        }
Пример #8
0
 internal bool _OnPull(Actor <TManager> actor, ManagerEvents managerEvent, object[] arguments)
 {
     return(OnPull(actor, managerEvent, arguments));
 }
Пример #9
0
 protected virtual bool OnPull(Actor <TManager> actor, ManagerEvents managerEvent, object[] arguments)
 {
     _Publish(managerEvent, arguments);
     return(true);
 }
Пример #10
0
 protected void Publish(ManagerEvents managerEvent, params object[] arguments)
 {
     _Publish(managerEvent, arguments);
 }