Exemple #1
0
    /// <summary>
    /// Add a history event.
    /// </summary>
    /// <param name="historyEvent"></param>
    public void AddHistoryEvent(HistoryEvent historyEvent, string additionalText = "")
    {
        if (historyEvent == null)
        {
            Debug.LogWarning("History event could not be added because it is 'null'. Missing a proper configuration at a value script or an result of one of the scriptable objects (item, quest, etc.)?");
            return;
        }


        mDebug("Add " + historyEvent.ToString());

        //create new timeline data from the history event
        C_TimelineData timelineData = new C_TimelineData();

        if (vs != null)
        {
            timelineData.year         = Mathf.RoundToInt(vs.value);
            timelineData.historyEvent = historyEvent;
            timelineData.timelineKey  = historyEvent.name;
            timelineData.addText      = TextReplacement.TranslateAndReplace(additionalText);
            history.events.Add(timelineData);

            expandDisplayedHistory(timelineData);

            timelineChanged();

            save();
        }
        else
        {
            Debug.Log("Could not generate history event because the time value '" + timeValue.ToString() + "' is not available.");
        }
    }
Exemple #2
0
    void expandDisplayedHistory(C_TimelineData timelineData)
    {
        while (displayedHistory.Count <= (history.timelineEnd))
        {
            displayedHistory.Add(new C_TimelineData());
        }

        if (timelineData != null)
        {
            while (displayedHistory.Count <= (timelineData.year))
            {
                displayedHistory.Add(new C_TimelineData());
            }
            //overwrite with new event (if not null)-> last event counts
            if (timelineData.historyEvent != null)
            {
                displayedHistory[timelineData.year] = timelineData;
            }
        }
    }