public void HandleButtonClicked(DialogueAction action) { // Check if we need to end the scene if (action.targetNode == "endScene") { SceneManager.LoadScene(dialogueManager.GetComponent <DialogueManager>().nextScene); } if (action.targetNode == "null" && action.jsonFile != null) { dialogueManager.ChangeJsonFile(action.jsonFile); } //trigger a dialoge change dialogueManager.ChangeDialogue(action.targetNode); }
public void SetupActions() { //set up the actions //query to match anything inbetween[[]] - @ before string make it ignore \ as an ecape character var actionRegex = new Regex(@"\[\[(.*?)\]\]"); //find all matches MatchCollection actionMatches = actionRegex.Matches(body); if (actionMatches.Count > 0) { //found a match //loop through matches foreach (Match match in actionMatches) { //create a new action to be populated DialogueAction newDialogueAction = new DialogueAction(); //split the text and target string[] parameters = match.Groups[1].ToString().Split(new Char[] { '|' }); //updated the dialogue action properties newDialogueAction.text = parameters[0]; newDialogueAction.targetNode = parameters[1]; if (2 < parameters.Length) { newDialogueAction.jsonFile = parameters[2]; } //add the action to actions array actions.Add(newDialogueAction); //remove the action from the body body = body.Replace(match.Value, ""); } } else { //@todo does this need to be handled? //Debug.Log("did not find any actions in " + title); } }
public void SetupFunctions() { //set up functions //query to match anything inbetween <<>> var functionRegex = new Regex("<<(.*?)>>"); //find all matches MatchCollection functionMatches = functionRegex.Matches(body); if (functionMatches.Count > 0) { //found a match //loop through matches foreach (Match match in functionMatches) { //create a new action to be populated DialogueAction newDialogueAction = new DialogueAction(); //split the text and target string[] parameters = match.Groups[1].ToString().Split(new Char[] { '|' }); //updated the dialogue action properties newDialogueAction.text = parameters[0]; newDialogueAction.targetNode = parameters[1]; if (2 < parameters.Length) { newDialogueAction.jsonFile = parameters[2]; } //add the action to actions array functions.Add(newDialogueAction); //remove the action from the body body = body.Replace(match.Value, ""); } } }