public NodeAction createNodeAction(DialoguePath path = null, Action action = null) { //If no path, if (path == null) { //create a path path = createContainerNode().path; } NodeDialogue container = containers.First(cn => cn.path == path); //Add a node to the path if (action == null) { //Set default variable name string defaultVarName = dialogueData.Variables.Last(); if (path.conditions.Count > 0) { defaultVarName = path.conditions[0].variableName; } //Create new action action = new Action(defaultVarName); action.path = path; path.actions.Add(action); } NodeAction node = new NodeAction(action); container.AddNode(node); return(node); }
public void createQuote() { List <Control> prevSelected = new List <Control>(selectedNodes); deselectAll(); prevSelected.ForEach( c => { DialoguePath path = (c is NodeDialogue) ? path = ((NodeDialogue)c).path : path = ((Node)c).data.path; int index = (c is NodeQuote) ? ((NodeQuote)c).quote.Index : -1; NodeQuote node = Managers.Node.createNodeQuote(path, index); node.Editing = true; select(node, true); } ); if (prevSelected.Count == 0) { //If nothing is selected, make a new dialogue path //(which will auto-create a new quote too) createDialoguePath(); } }
public void receiveInfoDump(DialoguePath path, string[] textArray) { NodeQuote lastNode = Managers.Node.createNodes(path, textArray); lastNode.Editing = true; select(lastNode); }
/// <summary> /// This method makes a UI node for the given quote in the given dialogue path /// </summary> /// <param name="path"></param> /// <param name="quote"></param> /// <returns></returns> public NodeQuote createNodeQuote(DialoguePath path, Quote quote) { NodeQuote node = new NodeQuote(quote); NodeDialogue container = containers.First(cn => cn.path == path); container.AddNode(node); return(node); }
public Dialogue TakePath(DialoguePath option) { if (!Options.Contains(option)) { throw new Exception(String.Format("El diálogo {0} no contiene la opción {1}", this, option)); } OnNodeLeave?.Invoke(); return(option.TakePath()); }
public NodeDialogue createContainerNode(DialoguePath path = null) { if (path == null) { path = new DialoguePath(); dialogueData.dialogues.Add(path); } NodeDialogue container = new NodeDialogue(path); containers.Add(container); dialoguePanel.Controls.Add(container); return(container); }
/// <summary> /// Creates a new node for each string in the given array /// Returns the last created node /// </summary> /// <param name="path"></param> /// <param name="textArray"></param> public NodeQuote createNodes(DialoguePath path, string[] textArray) { if (path == null) { path = createContainerNode().path; } NodeQuote lastNode = null; foreach (string text in textArray) { NodeQuote node = createNodeQuote(path); node.Text = text; lastNode = node; } return(lastNode); }
public NodeCondition createNodeCondition(DialoguePath path = null, Condition condition = null) { //If no path, if (path == null) { //create a path path = createContainerNode().path; } NodeDialogue container = containers.First(cn => cn.path == path); //Add a node to the path if (condition == null) { //Find template Condition template = null; if (containers.Count > 0) { List <NodeDialogue> templateContainers = containers .Where(c => c.path.conditions.Count > 0).ToList(); if (templateContainers.Count > 0) { template = templateContainers.Last() .path.conditions[0]; } } //Create condition if (template != null) { condition = new Condition( template.variableName, template.testType, template.testValue + 1 ); } else { condition = new Condition(dialogueData.Variables.Last()); } condition.path = path; path.conditions.Add(condition); } NodeCondition node = new NodeCondition(condition); container.AddNode(node); return(node); }
public void enterPressed() { NodeQuote activeNode = (NodeQuote)selectedNodes.FirstOrDefault( c => c is NodeQuote ); if (activeNode != null) { activeNode.Editing = false; //If it's the last in the path, DialoguePath path = activeNode.quote.path; if (activeNode.quote.Index == path.quotes.Count - 1) { //Add new node at the end NodeQuote newNode = Managers.Node.createNodeQuote(path); newNode.Editing = true; select(newNode); } } }
/// <summary> /// Creates a UI Node and a Quote, /// Also creates a DialoguePath if none is provided /// </summary> /// <param name="path"></param> /// <param name="index"></param> /// <returns></returns> public NodeQuote createNodeQuote(DialoguePath path = null, int index = -1) { NodeDialogue container; //If no path, if (path == null) { //create a path container = createContainerNode(); path = container.path; } else { container = containers.First(cn => cn.path == path); } //Add a node to the path Quote quote = new Quote(); quote.path = path; if (index < 0) { path.quotes.Add(quote); } else { path.quotes.Insert(index, quote); } if (quote.Index >= 2) { Quote prevQuote = quote.path.quotes[quote.Index - 2]; quote.characterName = prevQuote.characterName; quote.imageFileName = prevQuote.imageFileName; } NodeQuote node = new NodeQuote(quote); container.AddNode(node); return(node); }
public void createAction() { List <Control> prevSelected = new List <Control>(selectedNodes); deselectAll(); prevSelected.ForEach( c => { DialoguePath path = (c is NodeDialogue) ? path = ((NodeDialogue)c).path : path = ((Node)c).data.path; NodeAction node = Managers.Node.createNodeAction(path); select(node, true); } ); if (prevSelected.Count == 0) { //If nothing is selected, make a new dialogue path //(which will auto-create a new quote too) DialoguePath path = createDialoguePath(); Managers.Node.createNodeAction(path); } }
// // Methods // public void AddOption(DialoguePath option) { Options.Add(option); }
// Escoge el camino "path" del diálogo actual public void PathTaken(DialoguePath path) { CurrentDialogue = CurrentDialogue.TakePath(path); DialogueUpdate(); }
public void DrawDialogueFutureEditor() { Dialogue dialogue = target as Dialogue; EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); if (GUILayout.Button("Add Dialogue")) { dialogue.dialoguePaths.Add(new DialoguePath("", newDialogue)); newDialogue = null; } GUILayout.Label("Dialogue"); for (int i = 0; i < dialogue.dialoguePaths.Count; i++) { dialogue.dialoguePaths[i].dialogue = EditorGUILayout.ObjectField( dialogue.dialoguePaths[i].dialogue, typeof(Dialogue), true) as Dialogue; } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); newDialogue = EditorGUILayout.ObjectField( newDialogue, typeof(Dialogue), true) as Dialogue; GUILayout.Label("Response"); for (int i = 0; i < dialogue.dialoguePaths.Count; i++) { dialogue.dialoguePaths[i].response = GUILayout.TextField(dialogue.dialoguePaths[i].response, textLayoutOptions); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); GUILayout.Label(""); GUILayout.Label("Up"); for (int i = 0; i < dialogue.dialoguePaths.Count; i++) { if (GUILayout.Button("+") && i > 0) { DialoguePath tempDialoguePath = dialogue.dialoguePaths[i]; dialogue.dialoguePaths[i] = dialogue.dialoguePaths[i - 1]; dialogue.dialoguePaths[i - 1] = tempDialoguePath; } } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); GUILayout.Label(""); GUILayout.Label("Down"); for (int i = 0; i < dialogue.dialoguePaths.Count; i++) { if (GUILayout.Button("-") && i < dialogue.dialoguePaths.Count - 1) { DialoguePath tempDialoguePath = dialogue.dialoguePaths[i]; dialogue.dialoguePaths[i] = dialogue.dialoguePaths[i + 1]; dialogue.dialoguePaths[i + 1] = tempDialoguePath; } } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); GUILayout.Label(""); GUILayout.Label(""); for (int i = 0; i < dialogue.dialoguePaths.Count; i++) { if (GUILayout.Button("Del")) { dialogue.dialoguePaths.RemoveAt(i); } } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); }