示例#1
0
    public bool QueueEvent(iEvent @event)
    {
        if (!_delegates.ContainsKey(@event.GetType()))
        {
            // If there are no listeners assigned to the event trying to be queued,
            // do not queue the event.
            return(false);
        }

        _eventQueue.Enqueue(@event);
        return(true);
    }
示例#2
0
    /// <summary>
    /// Processes the events queued up.
    /// </summary>
    /// <param name="@event"></param>
    private void ProcessEvent(iEvent @event)
    {
        EventDelegate @delegate;

        // Double check that there are actually listeners / delegates for this event
        if (_delegates.TryGetValue(@event.GetType(), out @delegate))
        {
            // If there was one, it's now stored in delegate and we can invoke the delegate
            // associated with this event we pass in.
            @delegate.Invoke(@event);
        }
        else
        {
            // There were no listeners.
            Debug.LogWarning("Event : " + @event.GetType() + " was found to have no listeners.");
        }
    }
示例#3
0
    void Update()
    {
        // Used to keep track of the time between processing events
        float timer = 0.0f;

        while (_eventQueue.Count > 0)
        {
            iEvent @event = _eventQueue.Dequeue() as iEvent;
            if (timer > queueWaitTime && waitTime)
            {
                Debug.Log("EventManager tried to dequeue " + @event.ToString() + " stopped after : " + timer.ToString() + " seconds.");
                return;
            }

            // Inform all the listeners / delegates that the event has been
            // queued.
            ProcessEvent(@event);

            //Check time
            timer += Time.deltaTime;
        }
    }
示例#4
0
 public void SetEvent(iEvent ev)
 {
     evt = ev;
 }
示例#5
0
 public void SetEvent(iEvent ev)
 {
     evts.Add(ev);
 }