private uint[] ReadBeats(StoryBeat[] beats) { HashSet<uint> seenIds = new HashSet<uint>(); foreach (StoryBeat beat in beats) foreach (StoryEvent evt in beat.Events) foreach (uint id in evt.Participants) seenIds.Add(id); uint[] result = new uint[seenIds.Count]; seenIds.CopyTo(result); return result; }
public IEnumerator WaitForQueue(StoryBeat beat) { yield return(new WaitForSeconds(.2f)); // Wait for chat to finish while (!beat.chat.queue.isEmpty) { yield return(null); } yield return(new WaitForSeconds(Random.Range(0f, 1.5f))); // Start next chat beat.OnFinishedStory.Invoke(); // Check for triggers for (int i = 0; i < triggers.Length; i++) { if (triggers[i] == beat) { objects[i].gameObject.SetActive(true); } } }
/// <summary> /// Imports a single story beat into the given level. /// </summary> private void ImportStoryBeat(StoryBeat beat, int level) { for (int i = 0; i < beat.Events.Length; i++) { EventStub stub = EventStub.FromStoryEvent((beat.Events[i])); if (level > 0) { foreach (EventStub pred in allEvents.Where((EventStub e) => GetLevelForEvent(e) == level)) { stub.AddPredecessor(pred); } } AddAuthoredEvent(stub); } }
/// <summary> /// Creates a story arc with the given events that can then be played back. /// </summary> public StoryArc ToStoryArc() { int max = DEFAULT_LEVEL; levelsForEvents.Values.ForEach((int m) => max = (max >= m) ? max : m); StoryBeat[] beats = new StoryBeat[max]; for (int i = DEFAULT_LEVEL + 1; i <= max; i++) { beats[i - 1] = ToStoryBeat(i); } return new StoryArc(beats); }
public void OnFinishedStory(StoryBeat beat) { StartCoroutine(WaitForQueue(beat)); }
public StoryBeat(StoryBeat other) { this.Events = new StoryEvent[other.Events.Length]; for (int i = 0; i < other.Events.Length; i++ ) this.Events[i] = new StoryEvent(other.Events[i]); }
public BeatPopulation(IEnumerable<IEnumerable<uint>> oneCombs, StoryBeat b) { beatpopulation = oneCombs; beat = b; }
/// <summary> /// Returns the list of all Beatpopulations for a storybeat "b". /// </summary> private List<BeatPopulation> createBeatPopulationSet(StoryBeat b) { List<BeatPopulation> populationSet = new List<BeatPopulation>(); StoryBeat beat = new StoryBeat (b); List<IEnumerable<IEnumerable<uint>>> eventpopulations = new List<IEnumerable<IEnumerable<uint>>>(); foreach (StoryEvent e in beat.Events) { eventpopulations.Add(stateSpaceManager.getRelaxedPopulations(e)); } IEnumerable<IEnumerable<IEnumerable<uint>>> allCombs = CombinationHelper.CartesianProduct(eventpopulations); foreach(IEnumerable<IEnumerable<uint>> comb in allCombs) { IEnumerable<uint> flattened = comb.SelectMany(o => o); if(!CombinationHelper.ContainsDuplicates(flattened)) populationSet.Add(new BeatPopulation(comb, b)); } if (populationSet.Count () == 0) { String enames = ""; foreach(StoryEvent ev in b.Events) enames += (ev.Signature.ToString() + ", "); Debug.LogError("For the Story Beat containing: " + enames + "no Population of the Beat can be found. You might want to split the Beat up to find a population."); } return populationSet; }
/// <summary> /// Creates a new StoryBeatInstance with the given beat and dependencies. /// </summary> /// <param name="beat">The actual StoryBeat.</param> /// <param name="dependencies">All the termination dependencies.</param> internal StoryBeatInstance(StoryBeat beat, Dictionary<EventID, List<EventID>> dependencies) { this.dependencies = dependencies; this.beat = beat; this.Events = null; }