public virtual FloorPathBranch <T> .ListPathBranchExpansion?ChooseRoomExpansion(IRandom rand, FloorPlan floorPlan) { List <RoomHallIndex> availableExpansions = new List <RoomHallIndex>(); for (int ii = 0; ii < floorPlan.RoomCount; ii++) { if (!BaseRoomFilter.PassesAllFilters(floorPlan.GetRoomPlan(ii), this.Filters)) { continue; } availableExpansions.Add(new RoomHallIndex(ii, false)); } for (int ii = 0; ii < floorPlan.HallCount; ii++) { if (!BaseRoomFilter.PassesAllFilters(floorPlan.GetHallPlan(ii), this.Filters)) { continue; } availableExpansions.Add(new RoomHallIndex(ii, true)); } return(FloorPathBranch <T> .ChooseRoomExpansion(this.PrepareBossRoom, 100, rand, floorPlan, availableExpansions)); }
public static ConsoleKey PrintListRoomHalls(IGenContext map, string msg, bool printDebug, bool printViewer) { IFloorPlanGenContext context = map as IFloorPlanGenContext; if (context == null) { return(ConsoleKey.Enter); } StringBuilder str = new StringBuilder(); FloorPlan plan = context.RoomPlan; if (plan == null) { return(ConsoleKey.Enter); } for (int yy = 0; yy < plan.DrawRect.Bottom; yy++) { for (int xx = 0; xx < plan.DrawRect.Right; xx++) { str.Append(' '); } } for (int ii = 0; ii < plan.RoomCount; ii++) { char chosenChar = '@'; //if (ii < 26) chosenChar = (char)('A' + ii % 26); IRoomGen gen = plan.GetRoom(ii); for (int xx = gen.Draw.Left; xx < gen.Draw.Right; xx++) { for (int yy = gen.Draw.Top; yy < gen.Draw.Bottom; yy++) { int index = yy * plan.DrawRect.Right + xx; if (str[index] == ' ') { str[index] = chosenChar; } else { str[index] = '!'; } } } } for (int ii = 0; ii < plan.HallCount; ii++) { char chosenChar = '#'; //if (ii < 26) chosenChar = (char)('a' + ii % 26); IRoomGen gen = plan.GetHall(ii); for (int xx = gen.Draw.Left; xx < gen.Draw.Right; xx++) { for (int yy = gen.Draw.Top; yy < gen.Draw.Bottom; yy++) { int index = yy * plan.DrawRect.Right + xx; if (str[index] == ' ') { str[index] = chosenChar; } else if (str[index] >= 'a' && str[index] <= 'z' || str[index] == '#') { str[index] = '+'; } else { str[index] = '!'; } } } } for (int yy = plan.DrawRect.Bottom - 1; yy > 0; yy--) { str.Insert(plan.DrawRect.Right * yy, '\n'); } string newStr = str.ToString(); if (listDebugString[currentDepth].MapString == newStr) { return(ConsoleKey.Enter); } listDebugString[currentDepth].MapString = newStr; if (printDebug) { Debug.WriteLine(msg); Debug.Print(newStr); } if (printViewer) { SteppingIn = false; Console.Clear(); Console.WriteLine(msg); Loc start = new Loc(Console.CursorLeft, Console.CursorTop); Console.Write(newStr); Loc end = new Loc(Console.CursorLeft, Console.CursorTop + 1); Console.SetCursorPosition(start.X, start.Y); int prevFarthestPrint = end.Y; while (true) { int farthestPrint = end.Y; Loc mapLoc = new Loc(Console.CursorLeft, Console.CursorTop) - start; rewriteLine(farthestPrint, String.Format("X:{0} Y:{1}", mapLoc.X.ToString("D3"), mapLoc.Y.ToString("D3"))); farthestPrint++; for (int ii = 0; ii < plan.RoomCount; ii++) { FloorRoomPlan roomPlan = plan.GetRoomPlan(ii); if (roomPlan.RoomGen.Draw.Contains(mapLoc)) { //stats string roomString = String.Format("Room #{0}: {1}x{2} {3}", ii, roomPlan.RoomGen.Draw.X, roomPlan.RoomGen.Draw.Y, roomPlan.RoomGen.ToString()); rewriteLine(farthestPrint, roomString); farthestPrint++; string componentString = String.Format("Components: {0}", String.Join(", ", roomPlan.Components)); rewriteLine(farthestPrint, componentString); farthestPrint++; //borders StringBuilder lineString = new StringBuilder(" "); for (int xx = 0; xx < roomPlan.RoomGen.Draw.Width; xx++) { lineString.Append(roomPlan.RoomGen.GetFulfillableBorder(Dir4.Up, xx) ? "^" : " "); } rewriteLine(farthestPrint, lineString.ToString()); farthestPrint++; for (int yy = 0; yy < roomPlan.RoomGen.Draw.Height; yy++) { lineString = new StringBuilder(roomPlan.RoomGen.GetFulfillableBorder(Dir4.Left, yy) ? "<" : " "); for (int xx = 0; xx < roomPlan.RoomGen.Draw.Width; xx++) { lineString.Append("#"); } lineString.Append(roomPlan.RoomGen.GetFulfillableBorder(Dir4.Right, yy) ? ">" : " "); rewriteLine(farthestPrint, lineString.ToString()); farthestPrint++; } lineString = new StringBuilder(" "); for (int xx = 0; xx < roomPlan.RoomGen.Draw.Width; xx++) { lineString.Append(roomPlan.RoomGen.GetFulfillableBorder(Dir4.Down, xx) ? "V" : " "); } rewriteLine(farthestPrint, lineString.ToString()); farthestPrint++; } } for (int ii = 0; ii < plan.HallCount; ii++) { FloorHallPlan hallPlan = plan.GetHallPlan(ii); if (hallPlan.RoomGen.Draw.Contains(mapLoc)) { string roomString = String.Format("Hall #{0}: {1}x{2} {3}", ii, hallPlan.RoomGen.Draw.X, hallPlan.RoomGen.Draw.Y, hallPlan.RoomGen.ToString()); rewriteLine(farthestPrint, roomString); farthestPrint++; string componentString = String.Format("Components: {0}", String.Join(", ", hallPlan.Components)); rewriteLine(farthestPrint, componentString); farthestPrint++; } } for (int ii = farthestPrint; ii < prevFarthestPrint; ii++) { clearLine(ii); } prevFarthestPrint = farthestPrint; Console.SetCursorPosition(start.X + mapLoc.X, start.Y + mapLoc.Y); ConsoleKeyInfo key = Console.ReadKey(true); if (key.Key == ConsoleKey.UpArrow) { Console.SetCursorPosition(Console.CursorLeft, Math.Max(start.Y, Console.CursorTop - 1)); } else if (key.Key == ConsoleKey.DownArrow) { Console.SetCursorPosition(Console.CursorLeft, Math.Min(Console.CursorTop + 1, end.Y - 1)); } else if (key.Key == ConsoleKey.LeftArrow) { Console.SetCursorPosition(Math.Max(start.X, Console.CursorLeft - 1), Console.CursorTop); } else if (key.Key == ConsoleKey.RightArrow) { Console.SetCursorPosition(Math.Min(Console.CursorLeft + 1, end.X - 1), Console.CursorTop); } else { return(key.Key); } } } else { return(ConsoleKey.Enter); } }