private void clearPathDisplay() { if (SourceNode != null && TargetNode != null) { for (int i = 0; i < path.Count - 1; i++) ChangeEdgeColor(g.GetEdge(path[i], path[i + 1]), EdgeColor); ChangeNodeColor(SourceNode, NodeColor); ChangeNodeColor(TargetNode, NodeColor); SourceNode = null; TargetNode = null; } else if (SourceNode != null && TargetNode == null) { ChangeNodeColor(SourceNode, NodeColor); SourceNode = null; } else if (SourceNode == null && TargetNode != null) { for (int i = 0; i < path.Count - 1; i++) ChangeEdgeColor(g.GetEdge(path[i], path[i + 1]), EdgeColor); ChangeNodeColor(TargetNode, NodeColor); TargetNode = null; } }
private void checkForClickedNode(Vector2 clickPosition, bool leftAltPressed, bool rightAltPressed) { PositionalNode nodeClicked = null; PathNodeRadar nodeRadar = new PathNodeRadar(clickPosition, g); List<PositionalNode> adjacentNodes; nodeRadar.AdjacentNodes(out adjacentNodes); foreach (PositionalNode n in adjacentNodes) { Vector2 mouseToNode = n.Position - clickPosition; if (mouseToNode.LengthSquared() < nodeRadius * nodeRadius) { nodeClicked = n; break; } } if (nodeClicked != null) { if (leftAltPressed && !rightAltPressed) { if (SourceNode != null) ChangeNodeColor(SourceNode, NodeColor); SourceNode = nodeClicked; ChangeNodeColor(nodeClicked, Color.White); } else if (!leftAltPressed && rightAltPressed) { if (TargetNode != null) ChangeNodeColor(TargetNode, NodeColor); TargetNode = nodeClicked; ChangeNodeColor(nodeClicked, Color.Black); } } }
public void ChangeNodeColor(PositionalNode n, Color c) { nodeColors[n.Index] = c; }