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);
        }
    }
Пример #2
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);
            }
        }