public static TileMapSettings PreprocessMap(TileMapSettings mapSettings, SettlingRoomsSettings settings) { settlingRooms = new SettlingRoomsCreator(); settlingRooms.GenerateMap(settings); mapSettings.mapWidth = settlingRooms.Width; //+1 for zero tile mapSettings.mapHeight = settlingRooms.Height; //+1 for zero tile return(mapSettings); }
public static EmptyGrid ProcessMap(EmptyGrid map, SettlingRoomsSettings settings) { settlingRooms.FillCellMap(ref map.values, CellType.Wall, CellType.Floor); return(map); }
public void GenerateMap(SettlingRoomsSettings settings) { this.settings = settings; // Random Generator Random.State initialState = Random.state; if (settings.useFixedSeed) { Random.InitState(settings.seed.GetHashCode()); } else { Random.InitState(Time.time.ToString().GetHashCode()); } SpawnOverlappingRooms(); if (settings.isDebugLogEnabled) { Debug.Log("Rooms spawned inside circle"); } SettleOutRooms(); if (settings.isDebugLogEnabled) { Debug.Log("Roows settled out (separated from each other)"); } PickMainRooms(); if (settings.isDebugLogEnabled) { Debug.Log("Main rooms selected"); } TriangulateMainRoomsMidpointsAndGenerateMST(); if (settings.isDebugLogEnabled) { Debug.Log("Delaunay proceeded, minimal spanning tree found"); } CreateAdditionalConnectionsBetweenRooms(); if (settings.isDebugLogEnabled) { Debug.Log("Added some additional paths (that cause creation of branches or loops)"); } FindConnectedRoomsAndPathsBetweenThem(); if (settings.isDebugLogEnabled) { Debug.Log("Hallways created between rooms"); } FindPathRoomsBetweenMainRooms(); if (settings.isDebugLogEnabled) { Debug.Log("Rooms that are overlapping passages added to spawn pool"); } TranslateAllPointsCorrespondingToZeroOriginOfCoordinates(); if (settings.isDebugLogEnabled) { Debug.Log("Origin of coordinates set to (0, 0). All points translated accordingly to that."); } Random.state = initialState; }