//Creating SidePath From here private void CreateSidePath(int tiles) { Point nextPosition = keyList[random.Next(0, keyList.Count - 1)]; Tile nextTile = CanCreateSidePath(nextPosition); if (nextTile != null) { tileList.Add(nextTile.gridPosition, nextTile); while (tiles > 0) { List<Point> possiblePositions = new List<Point>(); //Look where a Tile can be placed Point position = new Point(nextTile.gridPosition.X - 1, nextTile.gridPosition.Y); if (!tileList.ContainsKey(position)) possiblePositions.Add(position); position.X = nextTile.gridPosition.X; position.Y = nextTile.gridPosition.Y + 1; if (!tileList.ContainsKey(position)) possiblePositions.Add(position); position.X = nextTile.gridPosition.X + 1; position.Y = nextTile.gridPosition.Y; if (!tileList.ContainsKey(position)) possiblePositions.Add(position); position.X = nextTile.gridPosition.X; position.Y = nextTile.gridPosition.Y - 1; if (!tileList.ContainsKey(position)) possiblePositions.Add(position); if (possiblePositions.Count > 0) { //Choose where to place the Tile nextTile = new SidePathTile(possiblePositions[random.Next(0, possiblePositions.Count - 1)]); tileList.Add(nextTile.gridPosition, nextTile); Console.WriteLine("Side: \nX: " + nextTile.gridPosition.X + "\nY: " + nextTile.gridPosition.Y); } else { break; } tiles--; } } else { } }
//Creating SidePath From here private void CreateSidePath(int tiles) { Point nextPosition = keyList[random.Next(0, keyList.Count - 1)]; Tile nextTile = CanCreateSidePath(nextPosition); if (nextTile != null) { tileList.Add(nextTile.gridPosition, nextTile); while (tiles > 0) { List <Point> possiblePositions = new List <Point>(); //Look where a Tile can be placed Point position = new Point(nextTile.gridPosition.X - 1, nextTile.gridPosition.Y); if (!tileList.ContainsKey(position)) { possiblePositions.Add(position); } position.X = nextTile.gridPosition.X; position.Y = nextTile.gridPosition.Y + 1; if (!tileList.ContainsKey(position)) { possiblePositions.Add(position); } position.X = nextTile.gridPosition.X + 1; position.Y = nextTile.gridPosition.Y; if (!tileList.ContainsKey(position)) { possiblePositions.Add(position); } position.X = nextTile.gridPosition.X; position.Y = nextTile.gridPosition.Y - 1; if (!tileList.ContainsKey(position)) { possiblePositions.Add(position); } if (possiblePositions.Count > 0) { //Choose where to place the Tile nextTile = new SidePathTile(possiblePositions[random.Next(0, possiblePositions.Count - 1)]); tileList.Add(nextTile.gridPosition, nextTile); Console.WriteLine("Side: \nX: " + nextTile.gridPosition.X + "\nY: " + nextTile.gridPosition.Y); } else { break; } tiles--; } } else { } }