static public void MarkHallWalls(ref AreaMap new_map, int x_loc, int y_loc) { int x_offset = 0; int y_offset = 0; for (int dir = 0; dir < Globals.Directions.Count(); dir += Globals.AllDirItr) { x_offset = Globals.Directions[dir].X + x_loc; y_offset = Globals.Directions[dir].Y + y_loc; if (!new_map.OffMap(x_offset, y_offset)) { if (new_map.ChkMSForState(ref new_map.MSGrid[y_offset][x_offset], MSFlag.BL, MSFlagIndex.BL_ST)) { new_map.MSGrid[y_offset][x_offset].MSStates[(int)MSFlagIndex.WALL_RM_ENT] = MSFlag.PWALL; } } } }
static public void MarkHallWalls(ref AreaMap new_map, ref List <List <Point> > hall_paths) { int x_offset = 0; int y_offset = 0; for (int hall = 0; hall < hall_paths.Count; hall++) { for (int sqr = 0; sqr < hall_paths[hall].Count(); sqr++) { for (int dir = 0; dir < Globals.Directions.Count(); dir += Globals.AllDirItr) { x_offset = Globals.Directions[dir].X + hall_paths[hall][sqr].X; y_offset = Globals.Directions[dir].Y + hall_paths[hall][sqr].Y; if (!new_map.OffMap(x_offset, y_offset)) { if (new_map.ChkMSForState(ref new_map.MSGrid[y_offset][x_offset], MSFlag.BL, MSFlagIndex.BL_ST)) { new_map.MSGrid[y_offset][x_offset].MSStates[(int)MSFlagIndex.WALL_RM_ENT] = MSFlag.PWALL; } } } } } }
static public void SetRoomBarrier(ref AreaMap new_map, ref AreaMapType template, int room_ID) { if (template.roomBarrierSizes[template.currRoomTypeIndex] != 0) { int x = 0; int y = 0; int wave = 0; int old_wave = 1; int wave_size = 0; // size of PREVIOUS wave int wave_counter = 0; // tracker for size of CURRENT wave int no_make_size = template.roomBarrierSizes[template.currRoomTypeIndex] - 1; Point offset = Point.Zero; List <List <Point> > waves = new List <List <Point> >(); waves.Add(new List <Point>()); waves.Add(new List <Point>()); // first iteration through wall square list, populates first "wave" foreach (Point sqr in new_map.RoomList[MapGenHelper.roomCounter].WallSquares) { for (int dir = 0; dir < Globals.NumDirects; dir += Globals.AllDirItr) { offset = Globals.Directions[dir]; x = sqr.X; y = sqr.Y; x += offset.X; y += offset.Y; if (!new_map.OffMap(x, y)) { if (new_map.MSGrid[y][x].RoomID != room_ID) { if (new_map.MSGrid[y][x].MSStates[(int)MSFlagIndex.CAN_MAKE] != MSFlag.NO_MAKE) { new_map.MSGrid[y][x].MSStates[(int)MSFlagIndex.CAN_MAKE] = MSFlag.NO_MAKE; waves[wave].Add(new Point(x, y)); wave_size++; //new_map.MSGrid[y][x].TileColor = Color.Blue; } } } } } // loops back and forth between waves for (int wv = 0; wv < no_make_size; wv++) { if (wave > 0) { wave = 0; old_wave = 1; } else { wave = 1; old_wave = 0; } for (int wav = 0; wav < wave_size; wav++) { for (int dir = 0; dir < Globals.NumDirects; dir += Globals.AllDirItr) { offset = Globals.Directions[dir]; x = waves[old_wave][wav].X; y = waves[old_wave][wav].Y; x += offset.X; y += offset.Y; if (!new_map.OffMap(x, y)) { if (new_map.MSGrid[y][x].RoomID != room_ID) { if (new_map.MSGrid[y][x].MSStates[(int)MSFlagIndex.CAN_MAKE] != MSFlag.NO_MAKE) { new_map.MSGrid[y][x].MSStates[(int)MSFlagIndex.CAN_MAKE] = MSFlag.NO_MAKE; if (wav < waves[wave].Count) { waves[wave][wav] = new Point(x, y); } else { waves[wave].Add(new Point(x, y)); } wave_counter++; //if(wave == 0) // new_map.MSGrid[y][x].TileColor = Color.Aqua; //else // new_map.MSGrid[y][x].TileColor = Color.Green; } } } } } wave_size = wave_counter; wave_counter = 0; } } }
static public bool FloodIsConnectedCheck(ref AreaMap new_map, bool unmark_after) { int adjacent_x = 0; int adjacent_y = 0; int curr_ID = 0; List <int> visited_rooms = new List <int>(); Stack <Point> squares = new Stack <Point>(); Point cur_sqr = Point.Zero; visited_rooms.Add(0); squares.Push(new_map.RoomList[0].RoomSquares[0]); if (new_map.MSGrid[new_map.RoomList[0].RoomSquares[0].Y] [new_map.RoomList[0].RoomSquares[0].X].MSStates[(int)MSFlagIndex.IS_MKD] == MSFlag.MKD) { MapGenHelper.UnmarkMap(ref new_map); /// } while (squares.Count > 0) { cur_sqr = squares.Pop(); for (int dir = 0; dir < Globals.Directions.Count(); dir += Globals.NESWItr) { adjacent_x = cur_sqr.X + Globals.Directions[dir].X; adjacent_y = cur_sqr.Y + Globals.Directions[dir].Y; if (new_map.OffMap(adjacent_x, adjacent_y)) { continue; } if (!new_map.ChkMSForState(ref new_map.MSGrid[adjacent_y][adjacent_x], MSFlag.WALL, MSFlagIndex.WALL_RM_ENT)) // changed: WALL->ROOM { if (new_map.ChkMSForState(ref new_map.MSGrid[adjacent_y][adjacent_x], MSFlag.NT_MKD, MSFlagIndex.IS_MKD)) { curr_ID = new_map.MSGrid[adjacent_y][adjacent_x].RoomID; new_map.MSGrid[adjacent_y][adjacent_x].MSStates[(int)MSFlagIndex.IS_MKD] = MSFlag.MKD; squares.Push(new Point(adjacent_x, adjacent_y)); if (!visited_rooms.Contains(curr_ID)) { visited_rooms.Add(curr_ID); } } } } } MapGenHelper.disconnectedRooms.Clear(); for (int i = 0; i < new_map.RoomList.Count(); i++) { if (!visited_rooms.Contains(i)) { MapGenHelper.disconnectedRooms.Add(i); } } if (MapGenHelper.disconnectedRooms.Count == 0) { MapGenHelper.UnmarkMap(ref new_map); } MapGenHelper.dcCount = MapGenHelper.disconnectedRooms.Count(); if (MapGenHelper.disconnectedRooms.Count > 0) { return(false); } return(true); }