public void build_floor(Cronkpit.CronkPit.Dungeon c_dungeon, int fl_number, Floor.floor_type f_type) { //init main texture list init_all_sourceRect_lists(c_dungeon); fl_type = f_type; current_floordepth = fl_number; //init spawn tables int floor_difficulty = fl_number; if (fl_type == Floor.floor_type.Cavern) floor_difficulty += 3; spawn_manager.set_table(floor_difficulty); fl_type = f_type; switch (c_dungeon) { case CronkPit.Dungeon.Necropolis: build_necropolis_floor(fl_type); break; case CronkPit.Dungeon.NadirHalls: build_nadir_floor(); break; } if (fl_number == 12) add_tier1_boss_monster(c_dungeon); }
public void init_all_sourceRect_lists(Cronkpit.CronkPit.Dungeon c_dungeon) { universal_spritesheet = cManager.Load<Texture2D>("Background/general_purpose_spritesheet"); //Sorted by X 0=>~, then by Y 0=>~ general_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Deep_Blood, new gridCoordinate(0, 0))); general_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Shallow_Blood, new gridCoordinate(1, 0))); general_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Entrance, new gridCoordinate(2, 0))); general_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Gravel, new gridCoordinate(3, 0))); general_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Shallow_Water, new gridCoordinate(4, 0))); general_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Deep_Sewage, new gridCoordinate(0, 1))); general_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Deep_Water, new gridCoordinate(1, 1))); general_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Exit, new gridCoordinate(2, 1))); general_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Gravel, new gridCoordinate(3, 1))); general_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Natural_Stone_Wall, new gridCoordinate(0, 2))); general_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Rubble_Floor, new gridCoordinate(1, 2))); general_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Rubble_Floor, new gridCoordinate(2, 2))); general_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Rubble_Wall, new gridCoordinate(3, 2))); general_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Rubble_Floor, new gridCoordinate(0, 3))); general_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Rubble_Wall, new gridCoordinate(1, 3))); general_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Rubble_Wall, new gridCoordinate(2, 3))); general_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Shallow_Sewage, new gridCoordinate(3, 3))); general_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Cavern_Entrance, new gridCoordinate(4, 1))); general_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Cavern_Exit, new gridCoordinate(4, 2))); general_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Natural_Stone_Floor, new gridCoordinate(4, 3))); switch (c_dungeon) { case CronkPit.Dungeon.Necropolis: dungeon_specific_spritesheet = cManager.Load<Texture2D>("Background/Necropolis/necropolis_sheet"); dungeon_specific_moss_spritesheet = cManager.Load<Texture2D>("Background/Necropolis/necropolis_sheet_moss"); //Sorted by tile type, since these often have to be passed in a specific order. //Do the general one first, then do the subsets. //Exit + Entrance dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Locked_Dungeon_Exit, new gridCoordinate(0, 0))); dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Dungeon_Exit, new gridCoordinate(0, 1))); //Dirt Floor dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.DirtFloor, new gridCoordinate(2, 0))); dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.DirtFloor, new gridCoordinate(0, 1))); dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.DirtFloor, new gridCoordinate(1, 1))); //Dirt Wall dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.DirtWall, new gridCoordinate(3, 1))); dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.DirtWall, new gridCoordinate(3, 0))); dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.DirtWall, new gridCoordinate(2, 1))); //Stone Floor dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneFloor, new gridCoordinate(2, 2))); dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneFloor, new gridCoordinate(3, 2))); dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneFloor, new gridCoordinate(1, 2))); dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneFloor, new gridCoordinate(1, 3))); dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneFloor, new gridCoordinate(2, 3))); //Stone Wall dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneWall, new gridCoordinate(4, 0))); dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneWall, new gridCoordinate(0, 2))); dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneWall, new gridCoordinate(0, 3))); dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneWall, new gridCoordinate(3, 3))); //Dungeon moss set next. //Dirt Floor moss_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.DirtFloor, new gridCoordinate(0, 0))); moss_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.DirtFloor, new gridCoordinate(0, 1))); //Dirt Wall moss_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.DirtWall, new gridCoordinate(1, 0))); moss_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.DirtWall, new gridCoordinate(1, 1))); //Stone Floor moss_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneFloor, new gridCoordinate(2, 1))); moss_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneFloor, new gridCoordinate(0, 2))); moss_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneFloor, new gridCoordinate(3, 0))); moss_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneFloor, new gridCoordinate(3, 1))); moss_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneFloor, new gridCoordinate(0, 3))); //Stone Wall moss_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneWall, new gridCoordinate(2, 0))); moss_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneWall, new gridCoordinate(1, 2))); break; case CronkPit.Dungeon.NadirHalls: dungeon_specific_spritesheet = cManager.Load<Texture2D>("Background/NadirHalls/nadirhalls_sheet"); //Stone Floor dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneFloor, new gridCoordinate(0, 1))); dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneFloor, new gridCoordinate(1, 1))); dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneFloor, new gridCoordinate(2, 1))); dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneFloor, new gridCoordinate(3, 1))); dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneFloor, new gridCoordinate(4, 1))); //Stone Wall dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneWall, new gridCoordinate(3, 0))); dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneWall, new gridCoordinate(2, 0))); dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneWall, new gridCoordinate(1, 0))); dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.StoneWall, new gridCoordinate(0, 0))); //Carpet dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Carpet, new gridCoordinate(0, 2))); dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Carpet_NS, new gridCoordinate(1, 2))); dungeon_texture_map.Add(new KeyValuePair<Tile.Tile_Type, gridCoordinate>(Tile.Tile_Type.Carpet_EW, new gridCoordinate(2, 2))); break; } general_texture_map.AddRange(dungeon_texture_map); }
public void add_tier1_boss_monster(Cronkpit.CronkPit.Dungeon c_dungeon) { List<gridCoordinate> all_boss_spawn_coords = new List<gridCoordinate>(); for (int i = 0; i < roomlayout.Count; i++) { //Normally i like to make this conversion inside the room class itself, but since the room doesn't know whether //its been moved around or not by the time I call this, well, let's just say I'm future proofing it! List<gridCoordinate> temp_boss_spawn_coords = roomlayout[i].get_boss_spawns(); for(int j = 0; j < temp_boss_spawn_coords.Count; j++) all_boss_spawn_coords.Add(new gridCoordinate(temp_boss_spawn_coords[j].x + roomlayout[i].startXPos, temp_boss_spawn_coords[j].y + roomlayout[i].startYPos)); } switch (c_dungeon) { case CronkPit.Dungeon.Necropolis: if (all_boss_spawn_coords.Count > 0) badguys.Add(new Boneyard(all_boss_spawn_coords[randGen.Next(all_boss_spawn_coords.Count)], cManager, blank_texture, badguys.Count, true)); else badguys.Add(new Boneyard(random_valid_position(current_floorsize, Monster.Monster_Size.Large, random_coord_restrictions.Monster), cManager, blank_texture, badguys.Count, true)); break; } }
private void parse_room_instructions(Cronkpit.CronkPit.Dungeon c_dungeon, RoomDC[] room_list, List<Room.Room_Type> roomTypes, Tile.Tile_Type generic_room_floor, bool allow_room_overlap) { List<RoomDC> valid_rooms = new List<RoomDC>(); for (int i = 0; i < roomTypes.Count; i++) { switch (roomTypes[i]) { case Room.Room_Type.SewerShaft: case Room.Room_Type.MineShaft: Room.Room_Type shaft_type = roomTypes[i]; bool shaft_placed = false; while (!shaft_placed) { bool horizontal_shaft = false; if (randGen.Next(2) == 0) horizontal_shaft = true; int xSize = 3; int ySize = 3; if (horizontal_shaft) ySize = randGen.Next(10, 21); else xSize = randGen.Next(10, 21); int nextX = randGen.Next(1, ((current_floorsize - 1) - xSize)); int nextY = randGen.Next(1, ((current_floorsize - 1) - ySize)); Room shaft_room = new Room(ySize, xSize, nextX, nextY, shaft_type, Tile.Tile_Type.StoneFloor, false, false); if (room_position_OK(shaft_room)) { shaft_placed = true; roomlayout.Add(shaft_room); } } break; case Room.Room_Type.Destroyed: case Room.Room_Type.DarkRoom: Room.Room_Type r_typ = roomTypes[i]; bool rm_placed = false; while (!rm_placed) { int next_room_height = randGen.Next(4, 10); int next_room_width = randGen.Next(4, 10); int next_room_startX = randGen.Next(1, ((current_floorsize - 1) - next_room_width)); int next_room_startY = randGen.Next(1, ((current_floorsize - 1) - next_room_height)); if (r_typ == Room.Room_Type.DarkRoom) { if (next_room_height > next_room_width) next_room_width = next_room_height; else next_room_height = next_room_width; } //Create generic room templates Room.Room_Type r_type = Room.Room_Type.Generic; Tile.Tile_Type f_type = generic_room_floor; if (r_typ == Room.Room_Type.Destroyed) f_type = Tile.Tile_Type.Rubble_Floor; //Assumes that the room will not have doors. //Addendum: again, only occurs on normal type floors bool door_room = false; if (randGen.Next(4) == 0 || r_typ == Room.Room_Type.DarkRoom) door_room = true; bool room_columns = false; if (r_type != Room.Room_Type.GenericCircular && randGen.Next(4) == 0) //Square room room_columns = true; //25% chance to have columns in these rooms. //Column pattern is picked at random when the room is initialized. //Initialize the room. Room rm = new Room(next_room_height, next_room_width, next_room_startX, next_room_startY, r_type, f_type, door_room, room_columns); if (r_type == Room.Room_Type.DarkRoom) rm.set_allowed_overlap(false); //Since we're in the necropolis, set whether the room has corpses in it or not. if (c_dungeon == CronkPit.Dungeon.Necropolis) { int corpse_chance = current_floordepth * 7; rm.set_corpses(corpse_chance); rm.set_allowed_overlap(allow_room_overlap); } //Now, if rooms are not allowed to overlap, we check to make sure there's no overlap //with other rooms. //first: we assume that the position of the room is valid. rm_placed = room_position_OK(rm); //If the room is good, we place it. //Otherwise the loop starts again. if (rm_placed) { roomlayout.Add(rm); //We add a special event if the room is a darkroom. if (r_typ == Room.Room_Type.DarkRoom) events.Add(new Fl_Special_Event(Fl_Special_Event.event_triggers.player_in_area, Fl_Special_Event.event_type.darkness_rad_2, 64000, (int)Math.Ceiling((double)(next_room_width/2)), false, rm.findCenter())); } } break; default: if (valid_rooms.Count == 0) for (int j = 0; j < room_list.Count(); j++) if (room_type_match(room_list[j].RoomType, roomTypes[i])) valid_rooms.Add(room_list[j]); if (valid_rooms.Count > 0) { bool room_placed = false; int tries = 0; int chosen_room = randGen.Next(valid_rooms.Count); while (!room_placed) { if (tries > 9) { chosen_room = randGen.Next(valid_rooms.Count); tries = 0; } Room next_room = new Room(valid_rooms[chosen_room], spawn_manager); int nextX = randGen.Next(1, ((current_floorsize - 1) - next_room.roomWidth)); int nextY = randGen.Next(1, ((current_floorsize - 1) - next_room.roomHeight)); next_room.reset_starting_position(nextX, nextY); room_placed = room_position_OK(next_room); if (room_placed) roomlayout.Add(next_room); tries++; } } break; } if (roomTypes[i] != roomTypes[Math.Min(roomTypes.Count - 1, i + 1)]) valid_rooms.Clear(); } }
private void add_random_generic_rooms(Cronkpit.CronkPit.Dungeon c_dungeon, int predtermined_rooms, bool allow_room_overlap) { //Randomly generate generic rooms int number_of_rooms = 0; Tile.Tile_Type generic_room_floor = Tile.Tile_Type.Void; switch(fl_type) { case Floor.floor_type.Normal: number_of_rooms = 5 + randGen.Next(4) - predtermined_rooms; generic_room_floor = Tile.Tile_Type.StoneFloor; break; case Floor.floor_type.Cavern: number_of_rooms = 3 + randGen.Next(2); generic_room_floor = Tile.Tile_Type.Natural_Stone_Floor; break; } //50% chance to make a dirt room on floor 0. This decreases by 2% per floor //Until it bottoms out at 20%. This occurs on floor 15 and lower. int dirt_threshold = Math.Max((50 - ((current_floordepth - 1) * 2)), 20); for (int i = 0; i < number_of_rooms; i++) { bool room_placed = false; while (!room_placed) { //Create new room dimensions int next_room_height = randGen.Next(4, 10); int next_room_width = randGen.Next(4, 10); int next_room_startX = randGen.Next(1, ((current_floorsize - 1) - next_room_width)); int next_room_startY = randGen.Next(1, ((current_floorsize - 1) - next_room_height)); int lower_room_x_edge = next_room_startX + next_room_width; int lower_room_y_edge = next_room_startY + next_room_height; int upper_room_x_edge = next_room_startX - next_room_width; int upper_room_y_edge = next_room_startY - next_room_height; //Create generic room templates Room.Room_Type r_type = Room.Room_Type.Generic; Tile.Tile_Type f_type = generic_room_floor; //Dirt rooms are kept towards the outer edges of the dungeon. //See above for % chance of creating a dirt room. The only thing that //differs is the floor type + wall type. int dirt_dice_roll = randGen.Next(100); if (dirt_dice_roll < dirt_threshold && (lower_room_x_edge < 15 || upper_room_x_edge > 35 || lower_room_y_edge < 15 || upper_room_y_edge > 35)) f_type = Tile.Tile_Type.DirtFloor; //If the room is square and the width is an odd number (so 3x3, 5x5, 7x7) //It has a 66% chance of becoming a roughly circular shaped room. //Addendum: only occurs on normal type floors if (fl_type == Floor.floor_type.Normal) { if (next_room_height == next_room_width && next_room_width % 2 == 1) if (randGen.Next(3) < 2) r_type = Room.Room_Type.GenericCircular; } //Assumes that the room will not have doors. //Addendum: again, only occurs on normal type floors bool door_room = false; if (fl_type == Floor.floor_type.Normal) { //If the room type is _not_ circular, there is a 25% chance of there being doors if (r_type != Room.Room_Type.GenericCircular && randGen.Next(4) == 0) door_room = true; } bool room_columns = false; if (r_type != Room.Room_Type.GenericCircular && randGen.Next(10) < 6) //Square room room_columns = true; //60% chance to have columns //Column pattern is picked at random when the room is initialized. //Initialize the room. Room rm = new Room(next_room_height, next_room_width, next_room_startX, next_room_startY, r_type, f_type, door_room, room_columns); //Since we're in the necropolis, set whether the room has corpses in it or not. if (c_dungeon == CronkPit.Dungeon.Necropolis) { int corpse_chance = current_floordepth * 5; rm.set_corpses(corpse_chance); rm.set_allowed_overlap(allow_room_overlap); } //Now, if rooms are not allowed to overlap, we check to make sure there's no overlap //with other rooms. //first: we assume that the position of the room is valid. room_placed = room_position_OK(rm); //If the room is good, we place it. //Otherwise the loop starts again. if (room_placed) roomlayout.Add(rm); } } }
private void add_floor_specific_rooms(string basePath, Cronkpit.CronkPit.Dungeon c_dungeon) { RoomDC[] fl_rooms = cManager.Load<RoomDC[]>(basePath + "Floors/" + c_dungeon.ToString().ToLower() + "_floor_" + current_floordepth.ToString()); for (int i = 0; i < fl_rooms.Count(); i++) roomlayout.Add(new Room(fl_rooms[i], spawn_manager)); }
private void add_floor_specific_features(string basePath, Cronkpit.CronkPit.Dungeon c_dungeon) { FeatureDC[] fl_features = cManager.Load<FeatureDC[]>(basePath + "Floors/" + c_dungeon.ToString().ToLower() + "_features_" + current_floordepth.ToString()); for(int i = 0; i < fl_features.Count(); i++) featurelayout.Add(new NaturalFeature(fl_features[i])); }