private void ConnectSecondaryNodes(SecondaryNode node1, SecondaryNode node2) { LocationConnection newConnection = new LocationConnection(node1, node2); connections.Add(newConnection); node1.connections.Add(newConnection); node2.connections.Add(newConnection); }
private void GenerateSecondaryNodes() { secondaryNodes = new List <SecondaryNode>(); foreach (VoronoiCell cell in graphCells) { List <GraphEdge> validEdges = cell.edges.Where(e => e.isInternal == false).ToList(); if (validEdges.Count > 0) { SecondaryNode centerNode = new SecondaryNode(cell.Center, cell); for (int i = 0; i < 2 && validEdges.Count > 0; i++) { int edgeIndex = Rand.Range(0, validEdges.Count - 1, false); GraphEdge selectedEdge = validEdges[edgeIndex]; SecondaryNode newNode; validEdges.Remove(selectedEdge); newNode = selectedEdge.AddSecondaryNode(); if (newNode == null) { continue; } secondaryNodes.Add(newNode); centerNode.attachedNodes.Add(newNode); } if (centerNode.attachedNodes.Count > 0) { secondaryNodes.Add(centerNode); } } /*if (cell.edges.Any(e => e.isInternal == false)) * { * SecondaryNode node = new SecondaryNode(cell.Center, cell); * List<SecondaryNode> secondNodes = new List<SecondaryNode>(); * * if (cell.edges.Count(e => e.isInternal == false) > 1) * { * List<GraphEdge> edges = new List<GraphEdge>(cell.edges.Where(e => e.isInternal == false)); * * int firstEdgeIndex = Rand.Range(0, edges.Count - 1, false); * int secondEdgeIndex = Rand.Range(0, edges.Count - 2, false); * * secondaryNodes.Add(new SecondaryNode(cell.Center, edges[firstEdgeIndex])); * edges.RemoveAt(firstEdgeIndex); * secondaryNodes.Add(new SecondaryNode(cell.Center, edges[secondEdgeIndex])); * } * else * { * secondNodes.Add(new SecondaryNode(cell.Center, cell.edges.First(e => e.isInternal == false))); * * } * }*/ } }
public LocationConnection(SecondaryNode node1, SecondaryNode node2) { secondaryNodes = new SecondaryNode[] { node1, node2 }; missionsCompleted = 0; }