public static OptionsDialogNode Create(DialogNodeEditor.OptionsDialogNode editorNode, BaseDialogNode parent) { OptionsDialogNode created = ScriptableObject.CreateInstance <OptionsDialogNode>(); created.nodeType = "OptionsDialogNode"; created.SpeakerID = editorNode.SpeakerID; created.DialogText = editorNode.DialogText; created.optionsText = new List <string>(editorNode.GetAllOptions().ToArray()); created.parents.Add(parent); parent.children.Add(created); return(created); }
private static void Recursive(Node processing, BaseDialogNode currentRef, Conversation tree) { if (processing == null) { Debug.Log("Converter: Recursive(): Why bother ask me to process a null object? Returnning."); return; } //If skip this check, the recursion will stuck, as pretty much execute in the for(). //Will prevent going deeper at End Node if (processing.Outputs.Count == 0) { return; } for (int i = 0; i < processing.Outputs.Count; i++) { BaseDialogNode creating = null; if (processing.Outputs[i].GetNodeAcrossConnection() == null) { Debug.Log("Converter: This connect to nothing. Returning."); return; } if (Translate(processing.Outputs[i].GetNodeAcrossConnection().GetType()) == null) { Debug.Log("Converter: Warning! Recursive() receiving null translated type."); return; } else if (Translate(processing.Outputs[i].GetNodeAcrossConnection().GetType()) == typeof(ConversationEndNode)) { creating = ConversationEndNode.Create(currentRef); } else if (Translate(processing.Outputs[i].GetNodeAcrossConnection().GetType()) == typeof(SimpleDialogNode)) { creating = SimpleDialogNode.Create(((DialogNodeEditor.SimpleDialogNode)processing.Outputs[i].GetNodeAcrossConnection()), currentRef); } else if (Translate(processing.Outputs[i].GetNodeAcrossConnection().GetType()) == typeof(OptionsDialogNode)) { creating = OptionsDialogNode.Create(((DialogNodeEditor.OptionsDialogNode)processing.Outputs[i].GetNodeAcrossConnection()), currentRef); } else if (Translate(processing.Outputs[i].GetNodeAcrossConnection().GetType()) == typeof(VariableControlNode)) { creating = VariableControlNode.Create((DialogNodeEditor.VariableControlNode)processing.Outputs[i].GetNodeAcrossConnection()); } else if (Translate(processing.Outputs[i].GetNodeAcrossConnection().GetType()) == typeof(VariableConditionalNode)) { creating = VariableConditionalNode.Create((DialogNodeEditor.VariableConditionalNode)processing.Outputs[i].GetNodeAcrossConnection()); } else if (Translate(processing.Outputs[i].GetNodeAcrossConnection().GetType()) == typeof(RandomOutputNode)) { creating = RandomOutputNode.Create(currentRef); } else if (Translate(processing.Outputs[i].GetNodeAcrossConnection().GetType()) == typeof(ConversationJumpNode)) { creating = ConversationJumpNode.Create(((DialogNodeEditor.ConversationJumpNode)processing.Outputs[i].GetNodeAcrossConnection()), currentRef); } tree.AddNode(creating); Recursive(processing.Outputs[i].GetNodeAcrossConnection(), creating, tree); } }