/// <summary>
    /// Generates all nodes based on loaded Graph
    /// </summary>
    private void GenerateNodes()
    {
        if (_containerCache.DialogueNodeData == null)
        {
            Debug.LogError("No Node Data to load");
            return;
        }

        //Create each saved DialogueNode
        foreach (DialogueNodeData nodeDataElement in _containerCache.DialogueNodeData)
        {
            DialogueNode tempNode = _targetGraphView.CreateDialogueNode(nodeDataElement.DialogueText, Vector2.zero);
            tempNode.GUID = nodeDataElement.Guid;
            _targetGraphView.AddElement(tempNode);

            //Create all the necessary output ports foreach DialogueNode
            foreach (NodeLinkData linkDataElement in _containerCache.NodeLinkData)
            {
                if (linkDataElement.BaseNodeGuid == nodeDataElement.Guid)
                {
                    _targetGraphView.AddOutputPort(tempNode, linkDataElement.PortName);
                }
            }
        }
    }
    private bool CheckForNodeType(SearchTreeEntry _searchTreeEntry, Vector2 _pos)
    {
        switch (_searchTreeEntry.userData)
        {
        case StartNode node:
            graphView.AddElement(graphView.CreateStartNode(_pos));
            return(true);

        case DialogueNode node:
            graphView.AddElement(graphView.CreateDialogueNode(_pos));
            return(true);

        case EventNode node:
            graphView.AddElement(graphView.CreateEventNode(_pos));
            return(true);

        case EndNode node:
            graphView.AddElement(graphView.CreateEndNode(_pos));
            return(true);

        case ScriptNode node:
            graphView.AddElement(graphView.CreateScriptNode(_pos));
            return(true);

        default:
            break;
        }
        return(false);
    }
    private void GenerateNodes()
    {
        foreach (var nodeData in _containerCache.dialogueNodeData)
        {
            var tempNode = _targetGraphView.CreateDialogueNode(nodeData.dialogueText, Vector2.zero);
            tempNode.GUID = nodeData.GUID;
            _targetGraphView.AddElement(tempNode);

            var nodePorts = _containerCache.nodeLinks.Where(x => x.baseNodeGuid == nodeData.GUID).ToList();
            nodePorts.ForEach(x => _targetGraphView.AddChoicePort(tempNode, x.portName));
        }
    }
Пример #4
0
    private void CreateNodes()
    {
        foreach (var nodeData in _containerCache.DialogueNodeData)
        {
            var tempNode = _targetGraphView.CreateDialogueNode(nodeData.DialogueText);
            tempNode.GUID = nodeData.Guid;
            _targetGraphView.AddElement(tempNode);

            var nodePorts = _containerCache.NodeLinks.Where(x => x.BaseNodeGuid == nodeData.Guid).ToList();
            nodePorts.ForEach(x => _targetGraphView.AddChoicePort(tempNode, x.PortName));
        }
    }
    private void GenerateNodes(DialogueContainerSO _dialogueContainer)
    {
        // Start
        foreach (StartNodeData node in _dialogueContainer.StartNodeDatas)
        {
            StartNode tempNode = graphView.CreateStartNode(node.Position);
            tempNode.NodeGuid = node.NodeGuid;

            graphView.AddElement(tempNode);
        }

        // End Node
        foreach (EndNodeData node in _dialogueContainer.EndNodeDatas)
        {
            EndNode tempNode = graphView.CreateEndNode(node.Position);
            tempNode.NodeGuid    = node.NodeGuid;
            tempNode.EndNodeType = node.EndNodeType;

            tempNode.LoadValueInToField();
            graphView.AddElement(tempNode);
        }

        // Event Node
        foreach (EventNodeData node in _dialogueContainer.EventNodeDatas)
        {
            EventNode tempNode = graphView.CreateEventNode(node.Position);
            tempNode.NodeGuid      = node.NodeGuid;
            tempNode.DialogueEvent = node.DialogueEventSO;

            tempNode.LoadValueInToField();
            graphView.AddElement(tempNode);
        }

        // Dialogue Node
        foreach (DialogueNodeData node in _dialogueContainer.DialogueNodeDatas)
        {
            DialogueNode tempNode = graphView.CreateDialogueNode(node.Position);
            tempNode.NodeGuid            = node.NodeGuid;
            tempNode.Name                = node.Name;
            tempNode.Texts               = node.TextType;
            tempNode.BackgroundImage     = node.Sprite;
            tempNode.BackgroundImageType = node.DialogueBackgroundImageType;
            tempNode.AudioClips          = node.AudioClips;

            foreach (DialogueNodePort nodePort in node.DialogueNodePorts)
            {
                tempNode.AddChoicePort(tempNode, nodePort);
            }

            tempNode.LoadValueInToField();
            graphView.AddElement(tempNode);
        }
    }
Пример #6
0
    private void CreateNodes()
    {
        foreach (var nodeData in _containerCache.DialogueNodeData)
        {
            // We pass position later on, so we can just use Vector2.zero for now as position while loading nodes.
            var tempNode = _targetGraphView.CreateDialogueNode(nodeData.DialogueText, Vector2.zero);
            tempNode.GUID = nodeData.Guid;
            _targetGraphView.AddElement(tempNode);

            var nodePorts = _containerCache.NodeLinks.Where(x => x.BaseNodeGuid == nodeData.Guid).ToList();
            nodePorts.ForEach(x => _targetGraphView.AddChoicePort(tempNode, x.PortName));
        }
    }
Пример #7
0
    private void CreateNodes()
    {
        foreach (var nodeData in _containerCache.DialogueNodeData)
        {
            // We''ll handle position later, pass V2.zero for now
            var tempNode = _targetGraphView.CreateDialogueNode(nodeData.DialogueText, Vector2.zero);
            tempNode.Guid = nodeData.Guid;
            _targetGraphView.AddElement(tempNode);

            var nodePorts = _containerCache.NodeLinks.Where(x => x.BaseNodeGuid == nodeData.Guid).ToList();
            nodePorts.ForEach(x => _targetGraphView.AddChoicePort(tempNode, x.PortName));
        }
    }
Пример #8
0
    private static void CreateNodes(DialogueGraphView graphView, DialogueContainer dialogueContainer)
    {
        foreach (var nodeData in dialogueContainer.DialogueNodeData)
        {
            var tempNode = graphView.CreateDialogueNode(nodeData.DialogueText, nodeData.Position);
            tempNode.Load(nodeData);
            graphView.AddElement(tempNode);

            //添加端口
            var nodePorts = dialogueContainer.NodeLinks.Where(x => x.FromNodeGuid == nodeData.Guid).ToList();
            nodePorts.ForEach(x => graphView.AddChoicePort(tempNode, x.PortName));
        }

        graphView.EntryNode.Load(dialogueContainer.EntryNodeData, true);
    }
Пример #9
0
    private void CreateDialogueNodes()
    {
        foreach (var nodeData in _containerCache.DialogueNodeData)
        {
            var tempNode = _targetGraphView.CreateDialogueNode(nodeData.DialogueText, nodeData.TargetPlayer, Vector2.zero);
            tempNode.GUID = nodeData.Guid;
            _targetGraphView.AddElement(tempNode);

            var nodePorts = _containerCache.NodeLinks.Where(x => x.BaseNodeGuid == nodeData.Guid).ToList();
            nodePorts.ForEach(x => _targetGraphView.AddChoicePort(tempNode, x.PortName));

            tempNode.SetPosition(new Rect(
                                     nodeData.Position,
                                     _targetGraphView.defaultNodeSize
                                     ));
        }
    }
Пример #10
0
    private void GenerateNodes(DialogueContainerSO _dialogueContainer)
    {
        // Start Node
        foreach (StartNodeData node in _dialogueContainer.StartNodeData)
        {
            StartNode tempNode = graphView.CreateStartNode(node.Position);
            tempNode.NodeGuid   = node.NodeGuid;
            tempNode.DialogueID = node.dialogueID;

            graphView.AddElement(tempNode);
        }

        // End Node
        foreach (EndNodeData node in _dialogueContainer.EndNodeData)
        {
            EndNode tempNode = graphView.CreateEndNode(node.Position);
            tempNode.NodeGuid    = node.NodeGuid;
            tempNode.EndNodeType = node.EndNodeType;

            graphView.AddElement(tempNode);
        }

        // Event Node
        foreach (EventNodeData node in _dialogueContainer.EventNodeData)
        {
            EventNode tempNode = graphView.CreateEventNode(node.Position);
            tempNode.NodeGuid      = node.NodeGuid;
            tempNode.DialogueEvent = node.DialogueEventSO;

            graphView.AddElement(tempNode);
        }

        // Dialogue Node
        foreach (DialogueNodeData node in _dialogueContainer.DialogueNodeData)
        {
            DialogueNode tempNode = graphView.CreateDialogueNode(node.Position);
            tempNode.NodeGuid = node.NodeGuid;
            tempNode.Name     = node.Name;
            //tempNode.Texts = node.TextType;
            tempNode.FaceImage     = node.Sprite;
            tempNode.BackGround    = node.Background;
            tempNode.FaceImageType = node.DialogueFaceImageType;
            //tempNode.AudioClips = node.AudioClips;

            foreach (LanguageGeneric <string> languageGeneric in node.TextType)
            {
                tempNode.Texts.Find(language => language.LanguageType == languageGeneric.LanguageType).LanguageGenericType = languageGeneric.LanguageGenericType;
            }

            foreach (LanguageGeneric <AudioClip> languageGeneric in node.AudioClips)
            {
                tempNode.AudioClips.Find(language => language.LanguageType == languageGeneric.LanguageType).LanguageGenericType = languageGeneric.LanguageGenericType;
            }

            foreach (DialogueNodePort nodePort in node.DialogueNodePorts)
            {
                tempNode.AddChoicePort(tempNode, nodePort);
            }

            tempNode.LoadValueInToField();
            graphView.AddElement(tempNode);
        }


        // Script Node
        foreach (ScriptNodeData node in _dialogueContainer.ScriptNodeData)
        {
            ScriptNode tempNode = graphView.CreateScriptNode(node.Position);
            tempNode.NodeGuid      = node.NodeGuid;
            tempNode.scriptType    = node.scriptNodeType;
            tempNode.reqScriptType = node.reqNodeType;

            foreach (ScriptNodePort scriptNodePort in node.scriptNodePorts)
            {
                tempNode.AddRequirement(tempNode, scriptNodePort);
                tempNode.ScriptText = node.scriptTexts;
                tempNode.ResultText = node.resultTexts;
            }

            tempNode.LoadValueInToField();
            graphView.AddElement(tempNode);
        }
    }
Пример #11
0
        // Spawning nodes based on ScriptableObject data
        private void GenerateNodes(DialogueContainerSO dialogueContainer)
        {
            // StartNode
            foreach (StartNodeData node in dialogueContainer.StartNodeDatas)
            {
                StartNode tempNode = graphView.CreateStartNode(node.Position);
                tempNode.NodeGuid = node.NodeGuid;

                graphView.AddElement(tempNode);
            }

            // EndNode
            foreach (EndNodeData node in dialogueContainer.EndNodeDatas)
            {
                EndNode tempNode = graphView.CreateEndNode(node.Position);
                tempNode.NodeGuid    = node.NodeGuid;
                tempNode.EndNodeType = node.EndNodeType;

                tempNode.LoadValueInToField();  // Loading values into node fields
                graphView.AddElement(tempNode); // Adding node to graph view
            }

            // EventNode
            foreach (EventNodeData node in dialogueContainer.EventNodeDatas)
            {
                EventNode tempNode = graphView.CreateEventNode(node.Position);
                tempNode.NodeGuid      = node.NodeGuid;
                tempNode.DialogueEvent = node.DialogueEventSO;

                tempNode.LoadValueInToField();
                graphView.AddElement(tempNode);
            }

            // DialogueNode
            foreach (DialogueNodeData node in dialogueContainer.DialogueNodeDatas)
            {
                DialogueNode tempNode = graphView.CreateDialogueNode(node.Position);
                tempNode.NodeGuid        = node.NodeGuid;
                tempNode.NameText        = node.Name;
                tempNode.NpcFaceImage    = node.npcSprite;
                tempNode.PlayerFaceImage = node.playerSprite;

                // Matching language dialogue is set to
                foreach (LanguageGeneric <string> languageGeneric in node.TextLanguages)
                {
                    tempNode.Texts.Find(language => language.LanguageType == languageGeneric.LanguageType).LanguageGenericType = languageGeneric.LanguageGenericType;
                }

                // Matching voice clips language dialogue is set to
                foreach (LanguageGeneric <AudioClip> languageGeneric in node.AudioClips)
                {
                    tempNode.AudioClips.Find(language => language.LanguageType == languageGeneric.LanguageType).LanguageGenericType = languageGeneric.LanguageGenericType;
                }

                // Matching dialogue choice ports
                foreach (DialogueNodePort nodePort in node.DialogueNodePorts)
                {
                    tempNode.AddChoicePort(tempNode, nodePort);
                }

                tempNode.LoadValueInToField();
                graphView.AddElement(tempNode);
            }

            // StatCheckNode
            foreach (StatCheckNodeData node in dialogueContainer.StatCheckNodeDatas)
            {
                StatCheckNode tempNode = graphView.CreateStatCheckNode(node.Position);
                tempNode.NodeGuid       = node.NodeGuid;
                tempNode.StatCheckValue = node.StatCheckValue.ToString();
                tempNode.CheckType      = node.StatCheckType;

                tempNode.LoadValueInToField();
                graphView.AddElement(tempNode);
            }

            // ItemCheckNode
            foreach (ItemCheckNodeData node in dialogueContainer.ItemCheckNodeDatas)
            {
                ItemCheckNode tempNode = graphView.CreateItemCheckNode(node.Position);
                tempNode.NodeGuid          = node.NodeGuid;
                tempNode.ItemCheckValue    = node.ItemCheckValue.ToString();
                tempNode.ItemCheckNodeType = node.ItemCheckType;
                tempNode.NodeItem          = node.NodeItem;

                tempNode.LoadValueInToField();
                graphView.AddElement(tempNode);
            }
        }