private void FillMap() { GraphNode n1 = null; int index = 0; for (int i = 0; i < this.currentNode.children.Count; i++) { GraphNode node = (GraphNode)this.currentNode.children[i]; index = this.GetLayerIndex(node, node.depth + 1); n1 = node.AddLevel(index); } for (int i = 0; i < 12; i++) { GraphNode foundNode = this.GetNodeAt(2, i); if (foundNode == null) { n1 = n1.AddSibling(i); } else { n1 = foundNode; } } index = this.GetLayerIndex(n1, n1.depth + 1); n1 = n1.AddLevel(index); for (int i = 0; i < 12; i++) { GraphNode foundNode = this.GetNodeAt(3, i); if (foundNode == null) { n1 = n1.AddSibling(i); } else { n1 = foundNode; } } index = this.GetLayerIndex(n1, n1.depth + 1); n1 = n1.AddLevel(index); for (int i = 0; i < 12; i++) { GraphNode foundNode = this.GetNodeAt(4, i); if (foundNode == null) { n1 = n1.AddSibling(i); } else { n1 = foundNode; } } }
private void ExploreNodeAt(GraphNode node, int depth, int index) { GraphNode nextNode = this.GetNodeAt(depth, index); int nextRealDepth = this.GetRealDepth(depth); if (node.depth == depth) { if (nextNode == null) { node.AddSibling(index, this.GetNodeType()); } else if (!this.HasEdge(node, nextNode)) { node.AttachNode(nextNode); } } else { if (nextNode == null && depth > node.depth) { // Chance to generate path to next layer bool spawnPath = Random.Range(0, 1f) <= 0.5f; if (nextRealDepth > this.GetRealDepth(node.depth)) { if (!spawnPath || layerPaths[nextRealDepth - 1] > 2) { return; } int nodeType = this.IsFinalRoom(depth) ? NodeTypes.BATTLE : this.GetNodeType(); GraphNode newNode = node.AddLevel(index, nodeType); newNode.SetHidden(true); layerPaths[nextRealDepth - 1]++; } else { node.AddLevel(index, this.GetNodeType()); } } else if (nextNode == null && depth < node.depth && this.GetRealDepth(node.depth) == nextRealDepth) { node.AddPrevLevel(index, this.GetNodeType()); } else if (nextNode != null && !this.HasEdge(node, nextNode) && this.NodesOnSamePlane(node, nextNode) && this.GetRealDepth(node.depth) == nextRealDepth) { node.AttachNode(nextNode); } } }
private void MakeStartingNodes() { spawnNode = new GraphNode(0); spawnNode.visited = true; this.currentNode = spawnNode; this.LockDepths(); // Add initial routes GraphNode n; n = spawnNode.AddLevel(0); n = spawnNode.AddLevel(1); n = spawnNode.AddLevel(2); n = spawnNode.AddLevel(3); }