/// <summary> /// Loads the given json as a set of options. /// </summary> public static DialogueSlide[] loadOptions(JSObject json, DialogueSlide parent) { if (json == null) { return(null); } // If it's just a string, then we have just a goto. if (json is JSValue) { DialogueSlide slide = new DialogueSlide(); slide.slidesToGoTo = json.ToString(); slide.track = parent.track; return(new DialogueSlide[1] { slide }); } // Create the set: DialogueSlide[] set = new DialogueSlide[json.length]; foreach (KeyValuePair <string, JSObject> kvp in json) { JSObject entry = kvp.Value; // Get the index: int index; int.TryParse(kvp.Key, out index); // Create the option: DialogueSlide slide = new DialogueSlide(); // Template: slide.template = entry.String("template"); // Markup: slide.markup = entry.String("markup"); // Goto: slide.slidesToGoTo = entry.String("goto"); slide.index = index; slide.track = parent.track; slide.parent = parent; // Add it: set[index] = slide; } return(set); }
/// <summary>Uses the speaker set from a previous slide which defined them.</summary> private void usePrevious(bool mood) { // Step backwards until we hit one // (because of how load works, this should *always* stop at the previous slide). for (int i = index - 1; i >= 0; i--) { DialogueSlide slide = track.slides[i] as DialogueSlide; if (slide != null && slide.speakers != null) { speakers = slide.speakers; if (mood) { this.mood = slide.mood; } break; } } }