public List<vector2i> wallCrawl(List<vector2i> wallList) { List<vector2i> newWalls = new List<vector2i> (); FloodFill f = new FloodFill (); vector2i start = null; for (int x = 0; x < newDungeon.GetLength(0); x++){ for (int y = 0; y < newDungeon.GetLength(1); y++){ if ( newDungeon[x,y] == space){ start = new vector2i (x, y); break; } } if (start != null){ break; } } UnityEngine.Debug.Log ("(" + start.x + " " + start.y + ")"); foreach (vector2i i in wallList) { int spaces = f.reachableSpaces (newDungeon, start); List<vector2i> card = i.getCardinalTiles (newDungeon.GetLength(0), newDungeon.GetLength(1)); vector2i newWall = card [rand.Next (0, card.Count)]; if (newDungeon[newWall.x, newWall.y] == space){ newWalls.Add (newWall); newDungeon [newWall.x,newWall.y] = wall; int newSpaces = f.reachableSpaces(newDungeon, start); if (spaces - newSpaces > 3){ newWalls.Remove (newWall); newDungeon [newWall.x,newWall.y] = space; } else { spaces = newSpaces; } } } wallList.AddRange (newWalls); //newWalls = new List<vector2i> (); return wallList; }
public void clearPoles(List<vector2i> wallList) { // #Clears out lonely walls, or "Poles". FloodFill f = new FloodFill(); for (int x = 0; x < newDungeon.GetLength(0); x++){ for (int y = 0; y < newDungeon.GetLength(1); y++){ if (newDungeon[x,y] == wall && countAdjWall (new vector2i(x,y)) == 0){ newDungeon [x,y] = space; } else if(f.reachableSpaces(newDungeon, new vector2i(x,y)) < 10) { newDungeon [x,y] = wall; } } } // List<vector2i> newSpaces = new List<vector2i> (); // foreach (vector2i i in wallList) { // if (countAdjWall (i) == 0) { // newDungeon [i.x,i.y] = space; // newSpaces.Add (i); // } // } // foreach (vector2i i in newSpaces) { // wallList.Remove (i); // } //return wallList; }