private void GenerateNodeFromContainer(DialogueData dialogueContainer) { foreach (var node in dialogueContainer.Nodes) { if (node.isEntryPoint) { var entryPoint = Nodes.Find(n => n.isEntryPoint); entryPoint.Guid = node.Guid; (entryPoint.outputContainer.Q <Port>() as DialoguePort).Next = node.Next; continue; } if (node.isChoiceNode) { ChoiceNode temp = graph.CreateChoiceNode("Choice Node"); temp.Guid = node.Guid; foreach (var choice in node.Choices) { graph.AddChoicePort(temp as ChoiceNode, choice.Question, choice.Next); } temp.SetPosition(new Rect(JsonUtility.FromJson <Vector2>(node.JsonData), graph.nodeSize)); graph.AddElement(temp); } else { DialogueNode temp = graph.CreateDialogueNode("Dialogue Node", node.Text, node.Character, node.Next);; temp.Guid = node.Guid; temp.SetPosition(new Rect(JsonUtility.FromJson <Vector2>(node.JsonData), graph.nodeSize)); graph.AddElement(temp); } } }
private void CreateGraph() { graph = new DialogueGraph() { name = "Dialogue Graph" }; graph.StretchToParentSize(); rootVisualElement.Add(graph); var toolbar = new Toolbar(); var addDilogueNodeButton = new Button(() => { graph.AddElement(DialogueNode.Create("Dialogue Node", new DialogueProperties())); }) { text = "New Dialogue Node" }; var createChoiceNodeButton = new Button(() => { graph.AddElement(ChoiceNode.Create("Choice Node")); }) { text = "New Choice Node" }; var saveButton = new Button(() => { var saveUtility = DataUtilities.GetInstance(graph, container); saveUtility.SaveGraph(path); }) { text = "Save" }; toolbar.Add(addDilogueNodeButton); toolbar.Add(createChoiceNodeButton); toolbar.Add(saveButton); rootVisualElement.Add(toolbar); }
private void GenerateNodeFromContainer(DialogueData dialogueContainer) { foreach (var node in dialogueContainer.Nodes) { if (node.isEntryPoint) { var entryPoint = Nodes.Find(n => n.isEntryPoint); entryPoint.Guid = node.Guid; (entryPoint.outputContainer.Q <Port>() as DialoguePort).Next = node.Next; continue; } if (node.isChoiceNode) { ChoiceNode temp = ChoiceNode.Create("Choice Node"); temp.Guid = node.Guid; foreach (var choice in node.Choices) { ChoiceNode.AddChoicePort(temp, choice.Question, choice.Next); } temp.SetPosition(new Rect(JsonUtility.FromJson <Vector2>(node.JsonData), graph.nodeSize)); graph.AddElement(temp); } else { var properties = new DialogueProperties { Text = node.Properties.Text, Speaker = node.Properties.Speaker, speakerPosition = node.Properties.speakerPosition, Conversant1 = node.Properties.Conversant1, conversant1Position = node.Properties.conversant1Position, Conversant2 = node.Properties.Conversant2, conversant2Position = node.Properties.conversant2Position }; DialogueNode temp = DialogueNode.Create("Dialogue Node", properties, node.Next); temp.Guid = node.Guid; temp.SetPosition(new Rect(JsonUtility.FromJson <Vector2>(node.JsonData), graph.nodeSize)); graph.AddElement(temp); } } }