Esempio n. 1
0
 public override void BuildContextualMenu(ContextualMenuPopulateEvent evt)
 {
     if (evt.target is GraphView)
     {
         evt.menu.AppendAction("Create Dialogue Node", delegate(DropdownMenuAction a)
         {
             var node    = DialogueNode.Create("Dialogue Node", new DialogueProperties());
             var nodePos = this.contentViewContainer.WorldToLocal(a.eventInfo.mousePosition);
             node.SetPosition(new Rect(nodePos, nodeSize));
             AddElement(node);
         });
     }
     if (evt.target is GraphView)
     {
         evt.menu.AppendAction("Create Choice Node", delegate(DropdownMenuAction a)
         {
             var node    = ChoiceNode.Create("Choice Node");
             var nodePos = this.contentViewContainer.WorldToLocal(a.eventInfo.mousePosition);
             node.SetPosition(new Rect(nodePos, nodeSize));
             AddElement(node);
         });
     }
     if (evt.target is BlackboardSection)
     {
         evt.menu.AppendAction("Create", null);
     }
     base.BuildContextualMenu(evt);
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 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);
         }
     }
 }