public static void AttemptRoomPlace(Vector2 TopLeft, List <int[]>[] RoomTileTypes, int[,,,] Rooms, ref bool[,] region, int type = -1) { for (int i = 0; i < 100; i++) { int x = Main.rand.Next(region.GetLength(0) - Rooms.GetLength(3)); int y = Main.rand.Next(region.GetLength(1) - Rooms.GetLength(2)); if (CheckRegion(x, y, Rooms.GetLength(3), Rooms.GetLength(2), region)) { Fortress2Blueprints.BuildRoom((int)(TopLeft.X + x), (int)(TopLeft.Y + y), RoomTileTypes, Rooms); OccupyRegion(x, y, Rooms.GetLength(3), Rooms.GetLength(2), ref region); return; } } }
public override void PreUpdate() { /* * Vector2 positionB = Main.MouseWorld / 16f; * positionB.X = (int)positionB.X; * positionB.Y = (int)positionB.Y; * UIDimensions = new Vector2(1, 1); * Main.NewText(Main.tile[(int)positionB.X, (int)positionB.Y].nactive()); */ if (placeAltar) { UIDimensions = new Vector2(3, 2); if (Main.mouseLeft) { Vector2 position = Main.MouseWorld / 16f; position.X = (int)position.X; position.Y = (int)position.Y; WorldGen.PlaceTile((int)position.X + 1, (int)position.Y + 1, mod.TileType("FortressAltar")); PlaceUpdate(); } } if (placeTinyRoom) { UIDimensions = new Vector2(20, 10); if (Main.mouseLeft) { Vector2 position = Main.MouseWorld / 16f; position.X = (int)position.X; position.Y = (int)position.Y; Fortress2Blueprints.BuildRoom((int)position.X, (int)position.Y, Fortress2Blueprints.TinyRoomTileTypes, Fortress2Blueprints.TinyRooms, roomType); PlaceUpdate(); } } if (exportTinyRoom) { UIDimensions = new Vector2(20, 10); if (Main.mouseLeft) { Vector2 position = Main.MouseWorld / 16f; ExportRoom(position, Fortress2Blueprints.TinyRooms); } } if (placeSmallRoom) { UIDimensions = new Vector2(40, 20); if (Main.mouseLeft) { Vector2 position = Main.MouseWorld / 16f; position.X = (int)position.X; position.Y = (int)position.Y; Fortress2Blueprints.BuildRoom((int)position.X, (int)position.Y, Fortress2Blueprints.SmallRoomTileTypes, Fortress2Blueprints.SmallRooms, roomType); PlaceUpdate(); } } if (exportSmallRoom) { UIDimensions = new Vector2(40, 20); if (Main.mouseLeft) { Vector2 position = Main.MouseWorld / 16f; ExportRoom(position, Fortress2Blueprints.SmallRooms); } } if (placeMediumRoom) { UIDimensions = new Vector2(60, 30); if (Main.mouseLeft) { Vector2 position = Main.MouseWorld / 16f; position.X = (int)position.X; position.Y = (int)position.Y; Fortress2Blueprints.BuildRoom((int)position.X, (int)position.Y, Fortress2Blueprints.MediumRoomTileTypes, Fortress2Blueprints.MediumRooms, roomType); PlaceUpdate(); } } if (exportMediumRoom) { UIDimensions = new Vector2(60, 30); if (Main.mouseLeft) { Vector2 position = Main.MouseWorld / 16f; ExportRoom(position, Fortress2Blueprints.MediumRooms); } } if (placeLargeRoom) { UIDimensions = new Vector2(80, 40); if (Main.mouseLeft) { Vector2 position = Main.MouseWorld / 16f; position.X = (int)position.X; position.Y = (int)position.Y; Fortress2Blueprints.BuildRoom((int)position.X, (int)position.Y, Fortress2Blueprints.LargeRoomTileTypes, Fortress2Blueprints.LargeRooms, roomType); PlaceUpdate(); } } if (exportLargeRoom) { UIDimensions = new Vector2(80, 40); if (Main.mouseLeft) { Vector2 position = Main.MouseWorld / 16f; ExportRoom(position, Fortress2Blueprints.LargeRooms); } } if (placeAltarRoom) { UIDimensions = new Vector2(100, 50); if (Main.mouseLeft) { Vector2 position = Main.MouseWorld / 16f; position.X = (int)position.X; position.Y = (int)position.Y; Fortress2Blueprints.BuildRoom((int)position.X, (int)position.Y, Fortress2Blueprints.AltarRoomTileTypes, Fortress2Blueprints.AltarRooms, roomType); PlaceUpdate(); } } if (exportAltarRoom) { UIDimensions = new Vector2(100, 50); if (Main.mouseLeft) { Vector2 position = Main.MouseWorld / 16f; ExportRoom(position, Fortress2Blueprints.AltarRooms); } } }
public static void BuildFortress() { int lowerLimit; int upperLimit = 60; int CenterX; int maxDistanceFromCenter; int mediumRoomCount = Main.rand.Next(8, 11); int smallRoomsPerMed = 2; int tinyRoomsPerMed = 3; if (Main.dungeonX < Main.maxTilesX * .5f) { CenterX = (int)((double)Main.maxTilesX * 0.8); } else { CenterX = (int)((double)Main.maxTilesX * 0.2); } if (Main.maxTilesX > 8000) { lowerLimit = 320; maxDistanceFromCenter = 750; mediumRoomCount *= 6; } else if (Main.maxTilesX > 6000) { lowerLimit = 230; maxDistanceFromCenter = 550; mediumRoomCount *= 3; } else { lowerLimit = 130; maxDistanceFromCenter = 320; } int height = lowerLimit - upperLimit; Vector2 topLeft = new Vector2(CenterX - maxDistanceFromCenter, upperLimit); QwertyMethods.BreakTiles(CenterX - maxDistanceFromCenter, 0, maxDistanceFromCenter * 2, (int)(lowerLimit)); bool[,] region = new bool[maxDistanceFromCenter * 2, height]; /* * for(int i = 0; i < region.GetLength(0); i++) * { * for(int j = 0; i < region.GetLength(1); j++) * { * region[i, j] = false; * } * }*/ Vector2 offset = new Vector2(maxDistanceFromCenter - Fortress2Blueprints.AltarRooms.GetLength(3) / 2, height / 2 - Fortress2Blueprints.AltarRooms.GetLength(2) / 2); Fortress2Blueprints.BuildRoom((int)(topLeft.X + offset.X), (int)(topLeft.Y + offset.Y), Fortress2Blueprints.AltarRoomTileTypes, Fortress2Blueprints.AltarRooms); OccupyRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.AltarRooms.GetLength(3), Fortress2Blueprints.AltarRooms.GetLength(2), ref region); int l = 4; if (Main.maxTilesX < 6000) { //for (int l/2 = 1; l/2 < l; l/2++) { for (int b = 1; b < l; b++) { if ((b % 2 != 0 && l / 2 % 2 == 0) || (b % 2 == 0 && l / 2 % 2 != 0)) { offset = new Vector2(b * 2 * maxDistanceFromCenter / l - Fortress2Blueprints.LargeRooms.GetLength(3) / 2, l / 2 * height / l - Fortress2Blueprints.LargeRooms.GetLength(2) / 2); if (CheckRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.LargeRooms.GetLength(3), Fortress2Blueprints.LargeRooms.GetLength(2), region)) { Fortress2Blueprints.BuildRoom((int)(topLeft.X + offset.X), (int)(topLeft.Y + offset.Y), Fortress2Blueprints.LargeRoomTileTypes, Fortress2Blueprints.LargeRooms); OccupyRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.LargeRooms.GetLength(3), Fortress2Blueprints.LargeRooms.GetLength(2), ref region); } } } } l = 8; // for (int l/2 = 1; l/2 < l; l/2++) { for (int b = 1; b < l; b++) { if ((b % 2 != 0 && l / 2 % 2 == 0) || (b % 2 == 0 && l / 2 % 2 != 0)) { offset = new Vector2(b * 2 * maxDistanceFromCenter / l - Fortress2Blueprints.MediumRooms.GetLength(3) / 2, l / 2 * height / l - Fortress2Blueprints.MediumRooms.GetLength(2) / 2); if (CheckRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.MediumRooms.GetLength(3), Fortress2Blueprints.MediumRooms.GetLength(2), region)) { Fortress2Blueprints.BuildRoom((int)(topLeft.X + offset.X), (int)(topLeft.Y + offset.Y), Fortress2Blueprints.MediumRoomTileTypes, Fortress2Blueprints.MediumRooms); OccupyRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.MediumRooms.GetLength(3), Fortress2Blueprints.MediumRooms.GetLength(2), ref region); } } } } l = 16; //for (int l/2 = 1; l/2 < l; l/2++) { for (int b = 1; b < l; b++) { if ((b % 2 != 0 && l / 2 % 2 == 0) || (b % 2 == 0 && l / 2 % 2 != 0)) { offset = new Vector2(b * 2 * maxDistanceFromCenter / l - Fortress2Blueprints.SmallRooms.GetLength(3) / 2, l / 2 * height / l - Fortress2Blueprints.SmallRooms.GetLength(2) / 2); if (CheckRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.SmallRooms.GetLength(3), Fortress2Blueprints.SmallRooms.GetLength(2), region)) { Fortress2Blueprints.BuildRoom((int)(topLeft.X + offset.X), (int)(topLeft.Y + offset.Y), Fortress2Blueprints.SmallRoomTileTypes, Fortress2Blueprints.SmallRooms); OccupyRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.SmallRooms.GetLength(3), Fortress2Blueprints.SmallRooms.GetLength(2), ref region); } } } } l = 32; //for (int l/2 = 1; l/2 < l; l/2++) { for (int b = 1; b < l; b++) { if ((b % 2 != 0 && l / 2 % 2 == 0) || (b % 2 == 0 && l / 2 % 2 != 0)) { offset = new Vector2(b * 2 * maxDistanceFromCenter / l - Fortress2Blueprints.TinyRooms.GetLength(3) / 2, l / 2 * height / l - Fortress2Blueprints.TinyRooms.GetLength(2) / 2); if (CheckRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.TinyRooms.GetLength(3), Fortress2Blueprints.TinyRooms.GetLength(2), region)) { Fortress2Blueprints.BuildRoom((int)(topLeft.X + offset.X), (int)(topLeft.Y + offset.Y), Fortress2Blueprints.TinyRoomTileTypes, Fortress2Blueprints.TinyRooms); OccupyRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.TinyRooms.GetLength(3), Fortress2Blueprints.TinyRooms.GetLength(2), ref region); } } } } } else if (Main.maxTilesX < 8000) { for (int q = 1; q < l; q++) { for (int b = 1; b < l; b++) { if ((b % 2 != 0 && q % 2 == 0) || (b % 2 == 0 && q % 2 != 0)) { offset = new Vector2(b * 2 * maxDistanceFromCenter / l - Fortress2Blueprints.LargeRooms.GetLength(3) / 2, q * height / l - Fortress2Blueprints.LargeRooms.GetLength(2) / 2); if (CheckRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.LargeRooms.GetLength(3), Fortress2Blueprints.LargeRooms.GetLength(2), region)) { Fortress2Blueprints.BuildRoom((int)(topLeft.X + offset.X), (int)(topLeft.Y + offset.Y), Fortress2Blueprints.LargeRoomTileTypes, Fortress2Blueprints.LargeRooms); OccupyRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.LargeRooms.GetLength(3), Fortress2Blueprints.LargeRooms.GetLength(2), ref region); } } } } l = 6; for (int q = 1; q < l; q++) { for (int b = 1; b < l; b++) { if ((b % 2 != 0 && q % 2 == 0) || (b % 2 == 0 && q % 2 != 0)) { offset = new Vector2(b * 2 * maxDistanceFromCenter / l - Fortress2Blueprints.MediumRooms.GetLength(3) / 2, q * height / l - Fortress2Blueprints.MediumRooms.GetLength(2) / 2); if (CheckRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.MediumRooms.GetLength(3), Fortress2Blueprints.MediumRooms.GetLength(2), region)) { Fortress2Blueprints.BuildRoom((int)(topLeft.X + offset.X), (int)(topLeft.Y + offset.Y), Fortress2Blueprints.MediumRoomTileTypes, Fortress2Blueprints.MediumRooms); OccupyRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.MediumRooms.GetLength(3), Fortress2Blueprints.MediumRooms.GetLength(2), ref region); } } } } l = 12; for (int q = 1; q < l; q++) { for (int b = 1; b < l; b++) { if ((b % 2 != 0 && q % 2 == 0) || (b % 2 == 0 && q % 2 != 0)) { offset = new Vector2(b * 2 * maxDistanceFromCenter / l - Fortress2Blueprints.SmallRooms.GetLength(3) / 2, q * height / l - Fortress2Blueprints.SmallRooms.GetLength(2) / 2); if (CheckRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.SmallRooms.GetLength(3), Fortress2Blueprints.SmallRooms.GetLength(2), region)) { Fortress2Blueprints.BuildRoom((int)(topLeft.X + offset.X), (int)(topLeft.Y + offset.Y), Fortress2Blueprints.SmallRoomTileTypes, Fortress2Blueprints.SmallRooms); OccupyRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.SmallRooms.GetLength(3), Fortress2Blueprints.SmallRooms.GetLength(2), ref region); } } } } l = 18; for (int q = 1; q < l; q++) { for (int b = 1; b < l; b++) { if ((b % 2 != 0 && q % 2 == 0) || (b % 2 == 0 && q % 2 != 0)) { offset = new Vector2(b * 2 * maxDistanceFromCenter / l - Fortress2Blueprints.TinyRooms.GetLength(3) / 2, q * height / l - Fortress2Blueprints.TinyRooms.GetLength(2) / 2); if (CheckRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.TinyRooms.GetLength(3), Fortress2Blueprints.TinyRooms.GetLength(2), region)) { Fortress2Blueprints.BuildRoom((int)(topLeft.X + offset.X), (int)(topLeft.Y + offset.Y), Fortress2Blueprints.TinyRoomTileTypes, Fortress2Blueprints.TinyRooms); OccupyRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.TinyRooms.GetLength(3), Fortress2Blueprints.TinyRooms.GetLength(2), ref region); } } } } } else { for (int q = 1; q < l; q++) { for (int b = 1; b < l; b++) { if ((b % 2 != 0 && q % 2 == 0) || (b % 2 == 0 && q % 2 != 0)) { offset = new Vector2(b * 2 * maxDistanceFromCenter / l - Fortress2Blueprints.LargeRooms.GetLength(3) / 2, q * height / l - Fortress2Blueprints.LargeRooms.GetLength(2) / 2); if (CheckRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.LargeRooms.GetLength(3), Fortress2Blueprints.LargeRooms.GetLength(2), region)) { Fortress2Blueprints.BuildRoom((int)(topLeft.X + offset.X), (int)(topLeft.Y + offset.Y), Fortress2Blueprints.LargeRoomTileTypes, Fortress2Blueprints.LargeRooms); OccupyRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.LargeRooms.GetLength(3), Fortress2Blueprints.LargeRooms.GetLength(2), ref region); } } } } l = 8; for (int q = 1; q < l; q++) { for (int b = 1; b < l; b++) { if ((b % 2 != 0 && q % 2 == 0) || (b % 2 == 0 && q % 2 != 0)) { offset = new Vector2(b * 2 * maxDistanceFromCenter / l - Fortress2Blueprints.MediumRooms.GetLength(3) / 2, q * height / l - Fortress2Blueprints.MediumRooms.GetLength(2) / 2); if (CheckRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.MediumRooms.GetLength(3), Fortress2Blueprints.MediumRooms.GetLength(2), region)) { Fortress2Blueprints.BuildRoom((int)(topLeft.X + offset.X), (int)(topLeft.Y + offset.Y), Fortress2Blueprints.MediumRoomTileTypes, Fortress2Blueprints.MediumRooms); OccupyRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.MediumRooms.GetLength(3), Fortress2Blueprints.MediumRooms.GetLength(2), ref region); } } } } l = 16; for (int q = 1; q < l; q++) { for (int b = 1; b < l; b++) { if ((b % 2 != 0 && q % 2 == 0) || (b % 2 == 0 && q % 2 != 0)) { offset = new Vector2(b * 2 * maxDistanceFromCenter / l - Fortress2Blueprints.SmallRooms.GetLength(3) / 2, q * height / l - Fortress2Blueprints.SmallRooms.GetLength(2) / 2); if (CheckRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.SmallRooms.GetLength(3), Fortress2Blueprints.SmallRooms.GetLength(2), region)) { Fortress2Blueprints.BuildRoom((int)(topLeft.X + offset.X), (int)(topLeft.Y + offset.Y), Fortress2Blueprints.SmallRoomTileTypes, Fortress2Blueprints.SmallRooms); OccupyRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.SmallRooms.GetLength(3), Fortress2Blueprints.SmallRooms.GetLength(2), ref region); } } } } l = 32; for (int q = 1; q < l; q++) { for (int b = 1; b < l; b++) { if ((b % 2 != 0 && q % 2 == 0) || (b % 2 == 0 && q % 2 != 0)) { offset = new Vector2(b * 2 * maxDistanceFromCenter / l - Fortress2Blueprints.TinyRooms.GetLength(3) / 2, q * height / l - Fortress2Blueprints.TinyRooms.GetLength(2) / 2); if (CheckRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.TinyRooms.GetLength(3), Fortress2Blueprints.TinyRooms.GetLength(2), region)) { Fortress2Blueprints.BuildRoom((int)(topLeft.X + offset.X), (int)(topLeft.Y + offset.Y), Fortress2Blueprints.TinyRoomTileTypes, Fortress2Blueprints.TinyRooms); OccupyRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.TinyRooms.GetLength(3), Fortress2Blueprints.TinyRooms.GetLength(2), ref region); } } } } } /* * int l = 4; * for(int q =1; q< l; q++) * { * for(int b =1; b < l; b++) * { * if ((b % 2 != 0 && q % 2 == 0) || (b % 2 == 0 && q % 2 != 0)) * { * offset = new Vector2(b * 2 * maxDistanceFromCenter / l - Fortress2Blueprints.LargeRooms.GetLength(3) / 2, q * height / l - Fortress2Blueprints.LargeRooms.GetLength(2) / 2); * if (CheckRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.LargeRooms.GetLength(3), Fortress2Blueprints.LargeRooms.GetLength(2), region)) * { * Fortress2Blueprints.BuildRoom((int)(topLeft.X + offset.X), (int)(topLeft.Y + offset.Y), Fortress2Blueprints.LargeRoomTileTypes, Fortress2Blueprints.LargeRooms); * OccupyRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.LargeRooms.GetLength(3), Fortress2Blueprints.LargeRooms.GetLength(2), ref region); * } * } * } * } * * l = 8; * for (int q = 1; q < l; q++) * { * for (int b = 1; b < l; b++) * { * if ((b % 2 != 0 && q % 2 == 0) || (b % 2 == 0 && q % 2 != 0)) * { * offset = new Vector2(b * 2 * maxDistanceFromCenter / l - Fortress2Blueprints.MediumRooms.GetLength(3) / 2, q * height / l - Fortress2Blueprints.MediumRooms.GetLength(2) / 2); * if (CheckRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.MediumRooms.GetLength(3), Fortress2Blueprints.MediumRooms.GetLength(2), region)) * { * Fortress2Blueprints.BuildRoom((int)(topLeft.X + offset.X), (int)(topLeft.Y + offset.Y), Fortress2Blueprints.MediumRoomTileTypes, Fortress2Blueprints.MediumRooms); * OccupyRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.MediumRooms.GetLength(3), Fortress2Blueprints.MediumRooms.GetLength(2), ref region); * } * } * } * } * l = 16; * * for (int q = 1; q < l; q++) * { * for (int b = 1; b < l; b++) * { * if ((b % 2 != 0 && q % 2 == 0) || (b % 2 == 0 && q % 2 != 0)) * { * offset = new Vector2(b * 2 * maxDistanceFromCenter / l - Fortress2Blueprints.SmallRooms.GetLength(3) / 2, q * height / l - Fortress2Blueprints.SmallRooms.GetLength(2) / 2); * if (CheckRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.SmallRooms.GetLength(3), Fortress2Blueprints.SmallRooms.GetLength(2), region)) * { * Fortress2Blueprints.BuildRoom((int)(topLeft.X + offset.X), (int)(topLeft.Y + offset.Y), Fortress2Blueprints.SmallRoomTileTypes, Fortress2Blueprints.SmallRooms); * OccupyRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.SmallRooms.GetLength(3), Fortress2Blueprints.SmallRooms.GetLength(2), ref region); * } * } * } * } * l = 32; * for (int q = 1; q < l; q++) * { * for (int b = 1; b < l; b++) * { * if ((b % 2 != 0 && q % 2 == 0) || (b % 2 == 0 && q % 2 != 0)) * { * offset = new Vector2(b * 2 * maxDistanceFromCenter / l - Fortress2Blueprints.TinyRooms.GetLength(3) / 2, q * height / l - Fortress2Blueprints.TinyRooms.GetLength(2) / 2); * if (CheckRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.TinyRooms.GetLength(3), Fortress2Blueprints.TinyRooms.GetLength(2), region)) * { * Fortress2Blueprints.BuildRoom((int)(topLeft.X + offset.X), (int)(topLeft.Y + offset.Y), Fortress2Blueprints.TinyRoomTileTypes, Fortress2Blueprints.TinyRooms); * OccupyRegion((int)offset.X, (int)offset.Y, Fortress2Blueprints.TinyRooms.GetLength(3), Fortress2Blueprints.TinyRooms.GetLength(2), ref region); * } * } * } * } */ /* * for (int i = 0; i < mediumRoomCount; i++) * { * AttemptRoomPlace(topLeft, Fortress2Blueprints.MediumRoomTileTypes, Fortress2Blueprints.MediumRooms, ref region); * for (int k = 0; k < smallRoomsPerMed; k++) * { * AttemptRoomPlace(topLeft, Fortress2Blueprints.SmallRoomTileTypes, Fortress2Blueprints.SmallRooms, ref region); * } * for (int k = 0; k < tinyRoomsPerMed; k++) * { * AttemptRoomPlace(topLeft, Fortress2Blueprints.TinyRoomTileTypes, Fortress2Blueprints.TinyRooms, ref region); * } * }*/ }