示例#1
0
    public int[] GetAllEventIDs(ref bool[] eventConclusions)
    {
        EventBase eventComponent = null;

        int[] eventIDs    = null;
        int   totalEvents = 0;

        eventConclusions = null;
        if (eventComponents != null)
        {
            totalEvents      = eventComponents.Length;
            eventIDs         = new int[totalEvents];
            eventConclusions = new bool[totalEvents];
            for (int i = 0; i < totalEvents; i++)
            {
                eventComponent = eventComponents[i];
                /*halmeida - eventComponent is necessarily not null, for this was certified in Awake().*/
                eventIDs[i] = eventComponent.eventID;

                /*halmeida - some events, like the ones within the ending chain of events, have to be playable more than once.
                 * The only way we can do that without breaking the chain of events itself is to just not save the conclusion
                 * of these events to the save files. The conclusion will be effective until the player closes the game and opens
                 * it again, at which point the game will have forgotten that these events have ever been concluded.*/
                eventConclusions[i] = (eventComponent.IsConcluded() && eventComponent.saveConclusion);
            }
        }
        return(eventIDs);
    }
示例#2
0
    public void PrepareNodelessEvents()
    {
        EventBase nodelessEvent = null;

        if ((stageComponent != null) && (eventsWithoutNode != null))
        {
            for (int i = 0; i < eventsWithoutNode.Length; i++)
            {
                nodelessEvent = eventsWithoutNode[i];
                if (!nodelessEvent.IsConcluded())
                {
                    nodelessEvent.ExtractInterests(stageComponent);
                    nodelessEvent.Trigger(eventComponents, GraphNode.NODE_ID_INVALID);
                }

                /*
                 * if( nodelessEvent.IsTriggered() )
                 * {
                 *      Debug.Log("Debug : EventManager : EVENT "+nodelessEvent.eventID+" IS TRIGGERED, NODE ID "+currentNodeID+".");
                 * }
                 * if( nodelessEvent.IsConcluded() )
                 * {
                 *      Debug.Log("Debug : EventManager : EVENT "+nodelessEvent.eventID+" WAS ALREADY CONCLUDED.");
                 * }
                 */
            }
        }
    }
示例#3
0
    public bool[] GetEventConclusions(int[] eventIDs)
    {
        EventBase eventComponent = null;

        bool[] eventConclusions = null;
        int    length           = 0;
        int    eventID          = -1;

        if (eventIDs != null)
        {
            length = eventIDs.Length;
            if (length > 0)
            {
                eventConclusions = new bool[length];
                for (int i = 0; i < length; i++)
                {
                    eventConclusions[i] = false;
                }
                if (eventComponents != null)
                {
                    for (int i = 0; i < length; i++)
                    {
                        eventID = eventIDs[i];
                        for (int j = 0; j < eventComponents.Length; j++)
                        {
                            eventComponent = eventComponents[j];
                            if (eventComponent != null)
                            {
                                if (eventID == eventComponent.eventID)
                                {
                                    if (eventComponent.IsConcluded())
                                    {
                                        eventConclusions[i] = true;
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
        return(eventConclusions);
    }
示例#4
0
    public void PrepareNodeEvents(int loadedNodeID)
    {
        EventBase nodeEvent = null;

        currentNodeID     = GraphNode.NODE_ID_INVALID;
        currentNodeEvents = null;
        if ((stageComponent != null) && (eventsPerNode != null))
        {
            /*halmeida - if eventsPerNode is not null, it means eventNodeIDs is also not null and
             * both have the same length.*/
            currentNodeID = loadedNodeID;
            for (int i = 0; i < eventNodeIDs.Length; i++)
            {
                if (eventNodeIDs[i] == currentNodeID)
                {
                    currentNodeEvents = eventsPerNode[i];
                    if (currentNodeEvents != null)
                    {
                        for (int j = 0; j < currentNodeEvents.Length; j++)
                        {
                            nodeEvent = currentNodeEvents[j];
                            if (!nodeEvent.IsConcluded())
                            {
                                nodeEvent.ExtractInterests(stageComponent);
                                nodeEvent.Trigger(eventComponents, currentNodeID);
                            }

                            /*
                             * if( nodeEvent.IsTriggered() )
                             * {
                             *      Debug.Log("Debug : EventManager : EVENT "+nodeEvent.eventID+" IS TRIGGERED, NODE ID "+currentNodeID+".");
                             * }
                             * if( nodeEvent.IsConcluded() )
                             * {
                             *      Debug.Log("Debug : EventManager : EVENT "+nodeEvent.eventID+" WAS ALREADY CONCLUDED.");
                             * }
                             */
                        }
                    }
                    break;
                }
            }
        }
    }
示例#5
0
    public void CloseNodeEvents()
    {
        EventBase nodeEvent = null;

        if (currentNodeEvents != null)
        {
            /*halmeida - since currentNodeEvents is just a subset of eventComponents, it
             * means all of its elements are not null, for they were already validated during
             * the Awake().*/
            for (int i = 0; i < currentNodeEvents.Length; i++)
            {
                nodeEvent = currentNodeEvents[i];
                if (!nodeEvent.IsConcluded())
                {
                    nodeEvent.Cancel(false, false);
                }
            }
        }
    }
示例#6
0
    public void Progress(float timeStep)
    {
        EventBase nodeEvent      = null;
        EventBase nodelessEvent  = null;
        bool      eventConcluded = false;

        if (currentNodeEvents != null)
        {
            /*halmeida - since currentNodeEvents is just a subset of eventComponents, it
             * means all of its elements are not null, for they were already validated during
             * the Awake().*/
            for (int i = 0; i < currentNodeEvents.Length; i++)
            {
                nodeEvent = currentNodeEvents[i];
                if (!nodeEvent.IsConcluded())
                {
                    nodeEvent.Progress(timeStep);
                    if (nodeEvent.IsConcluded())
                    {
                        eventConcluded = true;
                    }
                }
            }
        }
        if (eventsWithoutNode != null)
        {
            /*halmeida - since eventsWithoutNode is just a subset of eventComponents, it
             * means all of its elements are not null, for they were already validated during
             * the Awake().*/
            for (int i = 0; i < eventsWithoutNode.Length; i++)
            {
                nodelessEvent = eventsWithoutNode[i];
                if (!nodelessEvent.IsConcluded())
                {
                    nodelessEvent.Progress(timeStep);
                    if (nodelessEvent.IsConcluded())
                    {
                        eventConcluded = true;
                    }
                }
            }
        }
        if (eventConcluded)

        /*halmeida - when an event is concluded, it may have made it possible for
         * other events to trigger themselves. Furthermore, an event that is triggered
         * might be immediately concluded if it, for example, takes no time. Since we
         * cannot tell how much of the time of this processing (how much of the timeStep
         * interval) was spent for the event to conclude, it would be very incorrect to
         * just repeat the Progress call with the same timeStep. So, to allow at least
         * the immediate events to trigger and conclude themselves, we repeat the Progress
         * call with zero timeStep.*/
        {
            if (currentNodeEvents != null)
            {
                for (int i = 0; i < currentNodeEvents.Length; i++)
                {
                    nodeEvent = currentNodeEvents[i];
                    if (!nodeEvent.IsConcluded())
                    {
                        nodeEvent.ExtractInterests(stageComponent);
                        nodeEvent.Trigger(eventComponents, currentNodeID);
                    }
                }
            }
            if (eventsWithoutNode != null)
            {
                for (int i = 0; i < eventsWithoutNode.Length; i++)
                {
                    nodelessEvent = eventsWithoutNode[i];
                    if (!nodelessEvent.IsConcluded())
                    {
                        nodelessEvent.ExtractInterests(stageComponent);
                        nodelessEvent.Trigger(eventComponents, currentNodeID);
                    }
                }
            }
            Progress(0f);
        }
    }
示例#7
0
    private void UpdateEventConclusions(EventBase[] eventSet)
    {
        EventBase otherEvent          = null;
        int       otherEventID        = INVALID_EVENT_ID;
        bool      otherEventConcluded = false;

        prohibitiveEventConcluded   = false;
        totalPendingEventsPreviousA = totalEventsPreviousA;
        totalPendingEventsPreviousB = totalEventsPreviousB;
        if ((eventSet != null) && ((totalEventsPreviousA > 0) || (totalEventsPreviousB > 0) || (totalEventsProhibitive > 0)))
        {
            for (int i = 0; i < eventSet.Length; i++)
            {
                otherEvent = eventSet[i];
                if (otherEvent != null)
                {
                    otherEventID        = otherEvent.eventID;
                    otherEventConcluded = otherEvent.IsConcluded();
                    if (!prohibitiveEventConcluded && otherEventConcluded && (totalEventsProhibitive > 0))
                    {
                        for (int j = 0; j < totalEventsProhibitive; j++)
                        {
                            if (prohibitiveEventIDs[j] == otherEventID)
                            {
                                prohibitiveEventConcluded = true;
                                break;
                            }
                        }
                    }
                    if (totalEventsPreviousA > 0)
                    {
                        for (int j = 0; j < totalEventsPreviousA; j++)
                        {
                            if (previousEventIDsA[j] == otherEventID)
                            {
                                eventConclusionsPreviousA[j] = otherEventConcluded;
                                if (otherEventConcluded)
                                {
                                    totalPendingEventsPreviousA--;
                                }
                                break;
                            }
                        }
                    }
                    if (totalEventsPreviousB > 0)
                    {
                        for (int j = 0; j < totalEventsPreviousB; j++)
                        {
                            if (previousEventIDsB[j] == otherEventID)
                            {
                                eventConclusionsPreviousB[j] = otherEventConcluded;
                                if (otherEventConcluded)
                                {
                                    totalPendingEventsPreviousB--;
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
    }