Esempio n. 1
0
        /// <summary>
        /// Methog that appends components to a Node
        /// </summary>
        /// <param name="node">Node to append the components on</param>
        /// <param name="nd">NodeData with the information of what
        /// components to append</param>
        /// <returns>The new Node with appended components</returns>
        public DialogueNode AppendDefaultItems(DialogueNode node, NodeData nd = null)
        {
            node.title = "Dialogue Node";

            Button butt = new Button(clickEvent: () =>
            {
                AddPort(node);
            });

            butt.text = "Add Choice";
            node.titleContainer.Insert(1, butt);

            //Create and Add default Input Port
            Port generateImpPort = GeneratePort(node, Direction.Input);

            generateImpPort.portName = "Prev";
            node.inputContainer.Add(generateImpPort);

            string choice = "";

            if (nd?.OutPorts.Count > 0)
            {
                choice = nd.OutPorts[0].Name;
            }
            //Create and Add Output Port
            AddPort(node, choice);


            //Create and Add a textField to input the dialogue
            TextField text = new TextField();

            text.RegisterCallback <ChangeEvent <string> >((ChangeEvent <string> evt) =>
            {
                node.DialogText = evt.newValue;
            });
            text.multiline = true;
            text.value     = $"{nd?.Dialogue}\n\n\n";
            node.mainContainer.Insert(1, text);

            node.RefreshExpandedState();
            node.RefreshPorts();

            AddElement(node);

            return(node);
        }
Esempio n. 2
0
        /// <summary>
        /// Method responsible for creating the "Start" node of the
        /// Dialogue System
        /// </summary>
        /// <returns>The first Node</returns>
        private DialogueNode GenerateFirstNode()
        {
            DialogueNode node = new DialogueNode
            {
                title      = "Start",
                GUID       = Guid.NewGuid().ToString(),
                DialogText = "ENTRYPOINT",
                EntryPoint = true
            };

            Port generatePort = GeneratePort(node, Direction.Output);

            generatePort.portName = "Next";
            node.outputContainer.Add(generatePort);

            node.RefreshExpandedState();
            node.RefreshPorts();

            node.SetPosition(new Rect(100, 200, 100, 150));
            return(node);
        }