コード例 #1
0
ファイル: Event_Manager.cs プロジェクト: jhc65/Ricochet
    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
ファイル: Event_Manager.cs プロジェクト: jhc65/Ricochet
    /// <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
ファイル: Event_Manager.cs プロジェクト: jhc65/Ricochet
    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);
 }