public void CreateMap() { //Make the borders of the map walls GenerateMapBorders(); //Generate a random Bernouilli map GenerateMapEnv(); //Smooth the map environment SmoothMapEnv(); //Make strong walls (fill blank in walls) StrongMapWalls(); //Draw the map using mesh envMeshHandler = GetComponent <EnvironmentMeshHandler>(); envMeshHandler.GenerateMeshWall(map, 1); }
public void CreateCustomMap() { int i, j; if (this.filePath == "none") { this.filePath = FileBrowser.OpenSingleFile("bmp"); } Texture2D texture = null; byte[] fileData = File.ReadAllBytes(this.filePath); BMPLoader bmpLoader = new BMPLoader(); //Load the BMP data BMPImage bmpImg = bmpLoader.LoadBMP(fileData); //Convert the Color32 array into a Texture2D texture = bmpImg.ToTexture2D(); for (i = 0; i < texture.width; i++) { for (j = 0; j < texture.height; j++) { if (texture.GetPixel(i, j).r == 0) { this.map[i, j] = (int)Definition.pointEnum.WALL; } else { this.map[i, j] = (int)Definition.pointEnum.EMPTY; } } } //Draw the map using mesh envMeshHandler = GetComponent <EnvironmentMeshHandler>(); envMeshHandler.GenerateMeshWall(map, 1); }