public MapHandler() { DungeonGenerator gen = new DungeonGenerator(); int width = 1024; int height = 1024; int[,] map = gen.Generate(width, height, 50, 30, 250, 100); World.width = height / World.chunkSize; World.depth = width / World.chunkSize; World.CreateChunks(); TextureHandler th = (TextureHandler)GameObject.FindObjectOfType <TextureHandler> (); // Create pillars below rooms List <KeyValuePair <int, int[]> > pillars = gen.GetPillars(); foreach (var p in pillars) { CreatePlane(p.Key, 100, p.Value[2], p.Value[0], p.Value[1]); } // Create lights List <int[]> lights = gen.GetLights(); foreach (var l in lights) { // Create light pillars. int size = 10; for (int x = l[0] - size / 2 + 1; x < l[0] + size / 2 - 1; x++) { for (int y = l[1] - size / 2 + 1; y < l[1] + size / 2 - 1; y++) { float r = Random.Range(1, 15); for (int h = 15; h > 15 - r; h--) { // World.blocks [x, h, y] = th.GetGroundColor2 (x, h); World.blocks [x, h, y] = th.GetColor(th.pillars); } for (int h = 40; h > 15; h--) { //World.blocks [x, h, y] = th.GetGroundColor2 (x, h); World.blocks [x, h, y] = th.GetColor(th.pillars); } } } CreateLight(l[0] - 1, 45, l[1] - 1); } // Create brdige lights List <int[]> bridgeLights = gen.GetBridgeLights(); foreach (var l in bridgeLights) { // Create light pillars. int size = 6; for (int x = l[0] - size / 2; x < l[0] + size / 2; x++) { for (int y = l[1] - size / 2; y < l[1] + size / 2; y++) { float r = Random.Range(1, 15); for (int h = 15; h > 15 - r; h--) { World.blocks [x, h, y] = th.GetColor(th.pillars); // World.blocks [x, h, y] = th.GetGroundColor2 (x, h); } for (int h = 35; h > 15; h--) { // World.blocks [x, h, y] = th.GetGroundColor2 (x, h); World.blocks [x, h, y] = th.GetColor(th.pillars); } } } World.blocks [l [0] - 1, 36, l [1] - 1] = (255 & 0xFF) << 24 | (255 & 0xFF) << 16 | (251 & 0xFF) << 8; World.blocks [l [0] - 1, 37, l [1] - 1] = (255 & 0xFF) << 24 | (255 & 0xFF) << 16 | (251 & 0xFF) << 8; CreateBridgeLight(l[0] - 1, 37, l[1] - 1); } // Fences on bridges List <int[]> bridgeFence = gen.GetBridgeFence(); foreach (var l in bridgeFence) { // Create light pillars. int size = 4; for (int x = l[0] - size / 2; x < l[0] + size / 2; x++) { for (int y = l[1] - size / 2; y < l[1] + size / 2; y++) { World.blocks [x, 30, y] = th.GetColor(th.fence); //World.blocks [x, 30, y] = th.GetFenceColor (x, y); } } } for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { if (map [x, y] == (int)DungeonGenerator.types.Room) { // World.blocks [x, World.floorHeight, y] = th.GetGroundColor (x,y); World.blocks [x, World.floorHeight, y] = th.GetColor(th.floor); } else if (map[x, y] == (int)DungeonGenerator.types.Road) { // World.blocks [x, World.floorHeight, y] = th.GetGroundColor2 (x,y); World.blocks [x, World.floorHeight, y] = th.GetColor(th.bridge); } else if (map[x, y] == (int)DungeonGenerator.types.Player) { Player.player.obj.transform.position = new Vector3(x, World.floorHeight, y); } // ROOMS if (x + 1 < width) { if (map [x + 1, y] == (int)DungeonGenerator.types.Empty && map [x, y] == (int)DungeonGenerator.types.Room) { int r = (int)Random.Range(4, 15); for (int n = World.floorHeight - r; n <= World.floorHeight - 3; n++) { for (int i = 0; i < 6; i++) { World.blocks [x + i, n, y] = th.GetColor(th.wall); // World.blocks [x + i, n, y] = th.GetWallColor (n, y); } } for (int n = World.floorHeight - 3; n <= World.floorHeight + 2; n++) { for (int i = 0; i < 3; i++) { // World.blocks [x + i, n, y] = th.GetWallColor (n, y); World.blocks [x + i, n, y] = th.GetColor(th.wall); } } for (int n = World.floorHeight + 2; n <= World.floorHeight + 15; n++) { for (int i = 0; i < 6; i++) { /// World.blocks [x + i, n, y] = th.GetWallColor (n, y); World.blocks [x + i, n, y] = th.GetColor(th.wall); } if (n == World.floorHeight + 15) { for (int i = 0; i < 6; i++) { //World.blocks [x + i, n, y] = th.GetGroundColor2 (x-i, y); World.blocks [x + i, n, y] = th.GetColor(th.floor); } } } } } if (x - 1 > 0) { if (map [x - 1, y] == (int)DungeonGenerator.types.Empty && map [x, y] == (int)DungeonGenerator.types.Room) { int r = (int)Random.Range(4, 15); for (int n = World.floorHeight - r; n <= World.floorHeight - 3; n++) { for (int i = 0; i < 6; i++) { // World.blocks [x - i, n, y] = th.GetWallColor (n, y); World.blocks [x - i, n, y] = th.GetColor(th.wall); } } for (int n = World.floorHeight - 3; n <= World.floorHeight + 2; n++) { for (int i = 0; i < 3; i++) { // World.blocks [x - i, n, y] = th.GetWallColor (n, y); World.blocks [x - i, n, y] = th.GetColor(th.wall); } } for (int n = World.floorHeight + 2; n <= World.floorHeight + 15; n++) { for (int i = 0; i < 6; i++) { // World.blocks [x - i, n, y] = th.GetWallColor (n, y); World.blocks [x - i, n, y] = th.GetColor(th.wall); } if (n == World.floorHeight + 15) { for (int i = 0; i < 6; i++) { // World.blocks [x - i, n, y] = th.GetGroundColor2 (x+i, y); World.blocks [x - i, n, y] = th.GetColor(th.floor); } } } } } if (y + 1 < height) { if (map [x, y + 1] == (int)DungeonGenerator.types.Empty && map [x, y] == (int)DungeonGenerator.types.Room) { int r = (int)Random.Range(4, 15); for (int n = World.floorHeight - r; n <= World.floorHeight - 3; n++) { for (int i = 0; i < 6; i++) { // World.blocks [x, n, y+i] = th.GetWallColor (x, n); World.blocks [x, n, y + i] = th.GetColor(th.wall); } } for (int n = World.floorHeight - 3; n <= World.floorHeight + 2; n++) { for (int i = 0; i < 3; i++) { // World.blocks [x, n, y+i] = th.GetWallColor (x, n); World.blocks [x, n, y + i] = th.GetColor(th.wall); } } for (int n = World.floorHeight + 2; n <= World.floorHeight + 15; n++) { for (int i = 0; i < 6; i++) { // World.blocks [x, n, y+i] = th.GetWallColor (x, n); World.blocks [x, n, y + i] = th.GetColor(th.wall); } if (n == World.floorHeight + 15) { for (int i = 0; i < 6; i++) { // World.blocks [x, n, y+i] = th.GetGroundColor2 (x, y+i); World.blocks [x, n, y + i] = th.GetColor(th.floor); } } } } } if (y > 0) { if (map [x, y - 1] == (int)DungeonGenerator.types.Empty && map [x, y] == (int)DungeonGenerator.types.Room) { int r = (int)Random.Range(4, 15); for (int n = World.floorHeight - r; n <= World.floorHeight - 3; n++) { for (int i = 0; i < 6; i++) { // World.blocks [x, n, y-i] = th.GetWallColor (x, n); World.blocks [x, n, y - i] = th.GetColor(th.wall); } } for (int n = World.floorHeight - 3; n <= World.floorHeight + 2; n++) { for (int i = 0; i < 3; i++) { World.blocks [x, n, y - i] = th.GetColor(th.wall); // World.blocks [x, n, y-i] = th.GetWallColor (x, n); } } for (int n = World.floorHeight + 2; n <= World.floorHeight + 15; n++) { for (int i = 0; i < 6; i++) { World.blocks [x, n, y - i] = th.GetColor(th.wall); // World.blocks [x, n, y-i] = th.GetWallColor (x, n); } if (n == World.floorHeight + 15) { for (int i = 0; i < 6; i++) { // World.blocks [x, n, y-i] = th.GetGroundColor2 (x, y-i); World.blocks [x, n, y - i] = th.GetColor(th.floor); } } } } } // ROADS if (x + 1 < width) { if (map [x + 1, y] == (int)DungeonGenerator.types.Empty && map [x, y] == (int)DungeonGenerator.types.Road) { int r = (int)Random.Range(4, 10); for (int n = World.floorHeight - r; n <= World.floorHeight - 3; n++) { for (int i = 0; i < 6; i++) { // World.blocks [x + i, n, y] = th.GetWallColor (n, y); World.blocks [x + i, n, y] = th.GetColor(th.wall); } } for (int n = World.floorHeight - 3; n <= World.floorHeight; n++) { for (int i = 0; i < 3; i++) { World.blocks [x + i, n, y] = th.GetColor(th.wall); // World.blocks [x + i, n, y] = th.GetWallColor (n, y); } } for (int n = World.floorHeight; n <= World.floorHeight + 2; n++) { for (int i = 0; i < 2; i++) { // World.blocks [x + i, n, y] = th.GetWallColor (n, y); World.blocks [x + i, n, y] = th.GetColor(th.wall); } if (n == World.floorHeight + 2) { for (int i = 0; i < 6; i++) { World.blocks [x + i, n, y] = th.GetColor(th.floor); // World.blocks [x + i, n, y] = th.GetGroundColor2 (x-i, y); } } } } } if (x - 1 > 0) { if (map [x - 1, y] == (int)DungeonGenerator.types.Empty && map [x, y] == (int)DungeonGenerator.types.Road) { int r = (int)Random.Range(4, 10); for (int n = World.floorHeight - r; n <= World.floorHeight - 3; n++) { for (int i = 0; i < 6; i++) { // World.blocks [x - i, n, y] = th.GetWallColor (n, y); World.blocks [x - i, n, y] = th.GetColor(th.wall); } } for (int n = World.floorHeight - 3; n <= World.floorHeight; n++) { for (int i = 0; i < 3; i++) { World.blocks [x - i, n, y] = th.GetColor(th.wall); // World.blocks [x - i, n, y] = th.GetWallColor (n, y); } } for (int n = World.floorHeight; n <= World.floorHeight + 2; n++) { for (int i = 0; i < 6; i++) { World.blocks [x - i, n, y] = th.GetColor(th.wall); // World.blocks [x - i, n, y] = th.GetWallColor (n, y); } if (n == World.floorHeight + 2) { for (int i = 0; i < 6; i++) { // World.blocks [x - i, n, y] = th.GetGroundColor2 (x+i, y); World.blocks [x - i, n, y] = th.GetColor(th.floor); } } } } } if (y + 1 < height) { if (map [x, y + 1] == (int)DungeonGenerator.types.Empty && map [x, y] == (int)DungeonGenerator.types.Road) { int r = (int)Random.Range(4, 10); for (int n = World.floorHeight - r; n <= World.floorHeight - 3; n++) { for (int i = 0; i < 6; i++) { World.blocks [x, n, y + i] = th.GetColor(th.wall); // World.blocks [x, n, y+i] = th.GetWallColor (x, n); } } for (int n = World.floorHeight - 3; n <= World.floorHeight; n++) { for (int i = 0; i < 3; i++) { World.blocks [x, n, y + i] = th.GetColor(th.wall); // World.blocks [x, n, y+i] = th.GetWallColor (x, n); } } for (int n = World.floorHeight; n <= World.floorHeight + 2; n++) { for (int i = 0; i < 6; i++) { // World.blocks [x, n, y+i] = th.GetWallColor (x, n); World.blocks [x, n, y + i] = th.GetColor(th.wall); } if (n == World.floorHeight + 2) { for (int i = 0; i < 6; i++) { World.blocks [x, n, y + i] = th.GetColor(th.floor); // World.blocks [x, n, y+i] = th.GetGroundColor2 (x, y+i); } } } } } if (y > 0) { if (map [x, y - 1] == (int)DungeonGenerator.types.Empty && map [x, y] == (int)DungeonGenerator.types.Road) { int r = (int)Random.Range(4, 10); for (int n = World.floorHeight - r; n <= World.floorHeight - 3; n++) { for (int i = 0; i < 6; i++) { // World.blocks [x, n, y-i] = th.GetWallColor (x, n); World.blocks [x, n, y - i] = th.GetColor(th.wall); } } for (int n = World.floorHeight - 3; n <= World.floorHeight; n++) { for (int i = 0; i < 3; i++) { World.blocks [x, n, y - i] = th.GetColor(th.wall); // World.blocks [x, n, y-i] = th.GetWallColor (x, n); } } for (int n = World.floorHeight; n <= World.floorHeight + 2; n++) { for (int i = 0; i < 6; i++) { // World.blocks [x, n, y-i] = th.GetWallColor (x, n); World.blocks [x, n, y - i] = th.GetColor(th.wall); } if (n == World.floorHeight + 2) { for (int i = 0; i < 6; i++) { // World.blocks [x, n, y-i] = th.GetGroundColor2 (x, y-i); World.blocks [x, n, y - i] = th.GetColor(th.floor); } } } } } } } }