示例#1
0
    /**
     * Handles all events that should be handled at this turn of the given
     * priority.
     *
     * @param priority
     *      The priority of the events that should be handled.
     */
    public void HandleEvents(int priority)
    {
        // record the current turn
        int curTurn = TurnManager.GetCurrentTurn();

        List <GEvent> current = Events[priority];

        if (current == null)
        {
            return;
        }

        current.Sort();

        // Iterate over all the events of the priority
        while (Events[priority].Count > 0 && Events[priority][0].Turn <= curTurn)
        {
            GEvent e = Events[priority][0];

            // Removes the event that was just handled.
            Events[priority].RemoveAt(0);

            ////Debug.Log("Handling Event of type: " + e.GetType().ToString());

            // Iterate over every interested handler
            foreach (EventHandler h in EventHandlers[e.GetEventType()])
            {
                // Send the event to be handled by the handler
                h.ProcessEvent(e);
            }
        }
    }