Exemplo n.º 1
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);
        }
    }