// NOTE: SPEECHLINE VARIABLES ARE {{ }}, THIS CLASS SHOULD INJECT THE CORRECT VARIABLE FOR THE SITUATION public void ExecuteEventWithVars(string filename, Dictionary <string, string> vars) // vars should be: variable name, variable value { // fetch the dialogue information DialogueText dialogueText = new DialogueText(); dialogueText.ReadRawLinesFromFile(filename); // inject {{vars}} in order foreach (KeyValuePair <string, string> entry in vars) { // search each line for the variable and inject as needed foreach (List <SpeechLine> lines in dialogueText.lines) { foreach (SpeechLine line in lines) { if (line.lineText.Contains("{{" + entry.Key + "}}")) { Debug.Log("Injecting var " + entry.Key + " into " + filename + "..."); line.lineText = line.lineText.Replace("{{" + entry.Key + "}}", entry.Value); } } } } // execute event DialogueEvent.ExecuteEvent(dialogueText); }
public void ExecuteEvent(string filename) { Debug.Log("Executing dialogue event: " + filename); // fetch the dialogue information DialogueText dialogueText = new DialogueText(); dialogueText.ReadRawLinesFromFile(filename); DialogueEvent.ExecuteEvent(dialogueText); }