protected override void DrawConnections(NodeInput input, float inputID) { Handles.BeginGUI(); Handles.color = Color.white; for (int i = 0; i < input.inputNode.Count; i++) { NQuestionBranch output = (NQuestionBranch)input.inputNode[i]; int outputID = output.multiOutput.outputNode.IndexOf(this); Vector3 startPos = new Vector3(input.inputNode[i].myRect.x + input.inputNode[i].myRect.width + 24f, input.inputNode[i].myRect.y + (input.inputNode[i].myRect.height * 0.5f), 0f); Vector3 endPos = endPos = new Vector3(myRect.x - 24f, (output.multiOutput.outputNode[outputID].myRect.y + (output.multiOutput.outputNode[outputID].myRect.height * 0.5f) * inputID), 0f); Vector3 startTan = startPos + Vector3.right * (-50 + 100 * 1.5f) + Vector3.up * (-50 + 100 * 0.5f); Vector3 endTan = endPos + Vector3.right * (-50 + 100 * -.5f) + Vector3.up * (-50 + 100 * 0.5f); Color shadowCol = new Color(0, 0, 0, 0.6f);; for (int j = 0; j < 2; j++) { Handles.DrawBezier(startPos, endPos, startTan, endTan, shadowCol, null, (j + 1) * 5); } Handles.DrawBezier(startPos, endPos, startTan, endTan, new Color(0.51f, 0.51f, 1), null, 2); } Handles.EndGUI(); }
public override void CallConnection() { if (ApproveConnection()) { NQuestionBranch connectionNode = (NQuestionBranch)parentGraph.connectionNode; input.inputNode.Add(connectionNode); input.hasSomething = input.inputNode != null ? true : false; if (!connectionNode.multiOutput.outputNode.Contains(this)) { connectionNode.multiOutput.outputNode.Add(this); connectionNode.multiOutput.hasSomething = connectionNode.multiOutput.outputNode.Count > 0 ? true : false; } parentGraph.wantsConnection = false; parentGraph.connectionNode = null; } else { input.hasSomething = input.inputNode != null ? true : false; parentGraph.wantsConnection = false; parentGraph.connectionNode = null; } }
public static void DisconnectOutput(EngineGraph graph, int nodeID) { if (graph.nodes[nodeID] != null) { if (graph.nodes[nodeID].nodeType == EnumNodeType.Branch_Question) { NQuestionBranch multiNode = (NQuestionBranch)graph.nodes[nodeID]; if (multiNode.multiOutput.hasSomething) { for (int i = 0; i < multiNode.multiOutput.outputNode.Count; i++) { multiNode.multiOutput.outputNode[i].input.inputNode.Remove(multiNode); multiNode.multiOutput.outputNode[i].input.hasSomething = multiNode.multiOutput.outputNode[i].input.inputNode.Count > 0 ? true : false; } multiNode.multiOutput.outputNode = new List <NTemplate>(); multiNode.multiOutput.hasSomething = false; } } else if (graph.nodes[nodeID].nodeType == EnumNodeType.Branch_Condition) { NConditionalBranch multiNode = (NConditionalBranch)graph.nodes[nodeID]; if (multiNode.multiOutput.hasSomething) { for (int i = 0; i < multiNode.multiOutput.outputNode.Count; i++) { multiNode.multiOutput.outputNode[i].input.inputNode.Remove(multiNode); multiNode.multiOutput.outputNode[i].input.hasSomething = multiNode.multiOutput.outputNode[i].input.inputNode.Count > 0 ? true : false; } multiNode.multiOutput.outputNode = new List <NTemplate>(); multiNode.multiOutput.hasSomething = false; } } else { if (graph.nodes[nodeID].output.outputNode != null) { graph.nodes[nodeID].output.outputNode.input.inputNode.Remove(graph.nodes[nodeID]); graph.nodes[nodeID].output.outputNode.input.hasSomething = graph.nodes[nodeID].output.outputNode.input.inputNode.Count > 0 ? true : false; graph.nodes[nodeID].output.outputNode = null; graph.nodes[nodeID].output.isOccupied = false; } } } }
public static void DisconnectInput(EngineGraph graph, int nodeID) { if (graph.nodes[nodeID] != null) { if (graph.nodes[nodeID].nodeType == EnumNodeType.Answer) { for (int i = 0; i < graph.nodes[nodeID].input.inputNode.Count; i++) { NQuestionBranch questionNode = (NQuestionBranch)graph.nodes[nodeID].input.inputNode[i]; questionNode.multiOutput.outputNode.RemoveAt(questionNode.multiOutput.outputNode.IndexOf(graph.nodes[nodeID])); questionNode.multiOutput.hasSomething = questionNode.multiOutput.outputNode.Count == 0 ? false : true; } } else if (graph.nodes[nodeID].nodeType == EnumNodeType.Condition) { for (int i = 0; i < graph.nodes[nodeID].input.inputNode.Count; i++) { NConditionalBranch conditionNode = (NConditionalBranch)graph.nodes[nodeID].input.inputNode[i]; conditionNode.multiOutput.outputNode.RemoveAt(conditionNode.multiOutput.outputNode.IndexOf(graph.nodes[nodeID])); conditionNode.multiOutput.hasSomething = conditionNode.multiOutput.outputNode.Count == 0 ? false : true; } } else { for (int i = 0; i < graph.nodes[nodeID].input.inputNode.Count; i++) { graph.nodes[nodeID].input.inputNode[i].output.outputNode = null; graph.nodes[nodeID].input.inputNode[i].output.isOccupied = false; } } graph.nodes[nodeID].input.inputNode = new List <NTemplate>(); graph.nodes[nodeID].input.hasSomething = false; } }
public virtual void CallConnection() { if (ApproveConnection()) { if (parentGraph.connectionNode.output.isOccupied) { parentGraph.connectionNode.output.outputNode.input.inputNode.Remove(parentGraph.connectionNode); } input.inputNode.Add(parentGraph.connectionNode); input.hasSomething = input.inputNode.Count > 0 ? true : false; if (parentGraph.connectionNode.nodeType == EnumNodeType.Branch_Question) { NQuestionBranch connectionNode = (NQuestionBranch)parentGraph.connectionNode; connectionNode.multiOutput.outputNode.Add(this); connectionNode.multiOutput.hasSomething = true; } else { parentGraph.connectionNode.output.outputNode = this; parentGraph.connectionNode.output.isOccupied = true; } parentGraph.wantsConnection = false; parentGraph.connectionNode = null; } else { input.hasSomething = input.inputNode != null ? true : false; parentGraph.wantsConnection = false; parentGraph.connectionNode = null; } }
public static void DeleteNode(EngineGraph graph, int nodeID) { if (graph.nodes.Count <= nodeID) { return; } NTemplate deleteNode = graph.nodes[nodeID]; if (deleteNode == null) { return; } if (deleteNode.nodeType == EnumNodeType.Answer) { for (int i = 0; i < deleteNode.input.inputNode.Count; i++) { NQuestionBranch questionNode = (NQuestionBranch)deleteNode.input.inputNode[i]; questionNode.multiOutput.outputNode.Remove(graph.nodes[nodeID]); questionNode.multiOutput.hasSomething = questionNode.multiOutput.outputNode.Count == 0 ? false : true; } } else { for (int i = 0; i < deleteNode.input.inputNode.Count; i++) { deleteNode.input.inputNode[i].output.outputNode = null; deleteNode.input.inputNode[i].output.isOccupied = false; } } if (deleteNode.nodeType == EnumNodeType.Branch_Question) { NQuestionBranch questionNode = (NQuestionBranch)deleteNode; for (int i = 0; i < questionNode.multiOutput.outputNode.Count; i++) { questionNode.multiOutput.outputNode[i].input.inputNode.Remove(questionNode); questionNode.multiOutput.outputNode[i].input.hasSomething = questionNode.multiOutput.outputNode[i].input.inputNode.Count > 0 ? true : false; } } else if (deleteNode.nodeType == EnumNodeType.Branch_Condition) { NConditionalBranch conditionalNode = (NConditionalBranch)deleteNode; for (int i = 0; i < conditionalNode.multiOutput.outputNode.Count; i++) { conditionalNode.multiOutput.outputNode[i].input.inputNode.Remove(conditionalNode); conditionalNode.multiOutput.outputNode[i].input.hasSomething = conditionalNode.multiOutput.outputNode[i].input.inputNode.Count > 0 ? true : false; } } else { if (deleteNode.output.outputNode != null) { deleteNode.output.outputNode.input.inputNode.Remove(deleteNode); deleteNode.output.outputNode.input.hasSomething = deleteNode.output.outputNode.input.inputNode.Count > 0 ? true : false; } } graph.nodes.RemoveAt(nodeID); GameObject.DestroyImmediate(deleteNode, true); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }