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(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); } }
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); } }
// 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); } }