/// <summary> /// Gets the map of the entire region and all it's subregions. /// </summary> /// <returns></returns> public GeneratorMap[,] GetEntireMap() { GeneratorMap[,] OutputMap = new GeneratorMap[MapWidth + 1, MapHeight + 1]; //Populate the base map. for (int i = 0; i <= Map.GetUpperBound(0); i++) { for (int j = 0; j <= Map.GetUpperBound(1); j++) { OutputMap[i, j] = Map[i, j]; } } //Overlay the subregions for (int i = 0; i < SubRegions.Count; i++) { GeneratorMap[,] overlay = SubRegions[i].GetEntireMap(); int subX = 0; for (int a = SubRegions[i].originX; a <= SubRegions[i].originX + SubRegions[i].MapWidth; a++) { int subY = 0; for (int b = SubRegions[i].originY; b <= SubRegions[i].originY + SubRegions[i].MapHeight; b++) { OutputMap[a, b] = overlay[subX, subY]; subY++; } subX++; } } return(OutputMap); }
public void RandomFillMap() { // New, empty map // Map = new GeneratorMap[MapWidth, MapHeight]; BlankMap(); int mapMiddle = 0; // Temp variable for (int column = 0, row = 0; row <= MapHeight; row++) { for (column = 0; column <= MapWidth; column++) { Map[column, row] = new GeneratorMap(); Map[column, row].TileLayoutMap = OPEN; // If coordinants lie on the the edge of the map (creates a border) if (column == 0) { Map[column, row].TileLayoutMap = SOLID; } else if (row == 0) { Map[column, row].TileLayoutMap = SOLID; } else if (column == MapWidth - 1) { Map[column, row].TileLayoutMap = SOLID; } else if (row == MapHeight - 1) { Map[column, row].TileLayoutMap = SOLID; } // Else, fill with a wall a random percent of the time else { mapMiddle = (MapHeight / 2); if (row == mapMiddle) { Map[column, row].TileLayoutMap = SOLID; } else { Map[column, row].TileLayoutMap = RandomPercentWall(PercentAreWalls); } } } } }
protected void InitRegion(int index, int RegionLayer, int x, int y, int width, int height, Region Parent) { Debug.Log("Region " + RegionType() + " " + index + " at " + x + "," + y + " " + width + "x" + height); ParentRegion = Parent; RegionIndex = index; layer = RegionLayer; originX = x; originY = y; MapHeight = height; MapWidth = width; SetBaseHeight(); Map = new GeneratorMap[MapWidth + 1, MapHeight + 1]; for (int a = 0; a <= Map.GetUpperBound(0); a++) { for (int b = 0; b <= Map.GetUpperBound(1); b++) { Map[a, b] = new GeneratorMap(); Map[a, b].FloorTexture = index; Map[a, b].FloorHeight = BaseHeight; Map[a, b].TileLayoutMap = OPEN; } } }