예제 #1
0
        public Room(RoomDC base_room, Spawn_Table_Manager sManager)
        {
            roomHeight = base_room.RoomHeight;
            roomWidth = base_room.RoomWidth;
            gridCoordinate room_coord = grid_c_from_matrix_c(base_room.Coordinate);
            startXPos = room_coord.x;
            startYPos = room_coord.y;
            has_doors = base_room.RoomDoors;
            doors_always_locked = base_room.DoorsLocked;
            rGen = new Random();
            allow_random_spawns = base_room.AllowRandomSpawn;

            //Necropolis only.
            corpses_in_corner = false;
            corners_that_have_corpses = 0;

            //More general purpose stuff
            c_room_type = Room_Type.Generic;
            c_floor_type = Tile.Tile_Type.StoneFloor;
            c_column_type = Column_Pattern.None;

            room_tiles = base_room.Room_Matrix;
            hallway_anchors = new List<gridCoordinate>();
            boss_spawn_coordinates = new List<gridCoordinate>();
            doodad_list = new List<KeyValuePair<Doodad.Doodad_Type, gridCoordinate>>();
            monster_list = new List<KeyValuePair<string, gridCoordinate>>();
            monster_family_list = new List<KeyValuePair<string, gridCoordinate>>();
            bonus_gold = base_room.RoomGold;
            allow_overlap = base_room.AllowOverlap;

            switch (base_room.RoomType)
            {
                case "Specific":
                    c_room_type = Room_Type.Specific;
                    break;
                case "Gorehound Kennels":
                    c_room_type = Room.Room_Type.GHound_Kennel;
                    break;
                case "Library":
                    c_room_type = Room.Room_Type.Library;
                    break;
                case "Darkroom":
                    c_room_type = Room.Room_Type.DarkRoom;
                    break;
                case "Corpse Storage":
                    c_room_type = Room.Room_Type.CorpseStorage;
                    break;
                case "Sewer":
                    c_room_type = Room.Room_Type.SewerRoom;
                    break;
                case "Rubble Room":
                    c_room_type = Room.Room_Type.Destroyed;
                    break;
                case "Knight Armory":
                    c_room_type = Room.Room_Type.KnightArmory;
                    break;
                case "Sewer Shaft":
                    c_room_type = Room.Room_Type.SewerShaft;
                    break;
                case "Jail":
                    c_room_type = Room.Room_Type.Jail;
                    break;
                case "Mine Shaft":
                    c_room_type = Room.Room_Type.MineShaft;
                    break;
            }
            //Add hallway anchors
            List<string> raw_anchors = base_room.Room_Hallway_Anchors;
            if (raw_anchors.Count == 0)
                hallway_anchors.Add(new gridCoordinate(roomWidth / 2, roomHeight / 2));
            else
                for (int i = 0; i < raw_anchors.Count; i++)
                    if(raw_anchors[i].Length > 0) //prevent from passing ""
                        hallway_anchors.Add(grid_c_from_matrix_c(raw_anchors[i]));

            //Now to add the appropriate list of monsters & doodads
            //Doodads first.
            for (int i = 0; i < base_room.Room_Doodads.Count; i++)
            {
                Doodad.Doodad_Type c_doodad_type = 0; //Altar by default - not a problem.
                switch (base_room.Room_Doodads[i])
                {
                    case "Altar":
                        c_doodad_type = Doodad.Doodad_Type.Altar;
                        break;
                    case "ArmorSuit":
                        c_doodad_type = Doodad.Doodad_Type.ArmorSuit;
                        break;
                    case "BloodSplatter":
                        c_doodad_type = Doodad.Doodad_Type.Blood_Splatter;
                        break;
                    case "Cage":
                        c_doodad_type = Doodad.Doodad_Type.Cage;
                        break;
                    case "CorpsePile":
                        c_doodad_type = Doodad.Doodad_Type.CorpsePile;
                        break;
                    case "DestroyedArmorSuit":
                        c_doodad_type = Doodad.Doodad_Type.Destroyed_ArmorSuit;
                        break;
                    case "Bookshelf":
                        c_doodad_type = Doodad.Doodad_Type.Bookshelf;
                        break;
                    case "DestroyedBookshelf":
                        c_doodad_type = Doodad.Doodad_Type.Destroyed_Bookshelf;
                        break;
                    case "Ironbar_Door":
                        c_doodad_type = Doodad.Doodad_Type.Iron_Door;
                        break;
                    case "Ironbar_Wall":
                        c_doodad_type = Doodad.Doodad_Type.Ironbar_Wall;
                        break;
                    case "NadirBed":
                        c_doodad_type = Doodad.Doodad_Type.NadirBed;
                        break;
                    case "NadirColumn":
                        c_doodad_type = Doodad.Doodad_Type.NadirColumn;
                        break;
                    case "ArcheryTarget":
                        c_doodad_type = Doodad.Doodad_Type.ArcheryTarget;
                        break;
                    case "Desk":
                        c_doodad_type = Doodad.Doodad_Type.Desk;
                        break;
                    case "Hedgehog":
                        c_doodad_type = Doodad.Doodad_Type.Hedgehog;
                        break;
                    case "NadirDoor":
                        c_doodad_type = Doodad.Doodad_Type.NadirDoor;
                        break;

                }
                gridCoordinate c_grid_coord = grid_c_from_matrix_c(base_room.Room_Doodad_Coordinates[i]);
                int doodad_chance = 0;
                Int32.TryParse(base_room.Room_Doodad_Chances[i], out doodad_chance);
                if(rGen.Next(100) < doodad_chance)
                    doodad_list.Add(new KeyValuePair<Doodad.Doodad_Type,gridCoordinate>(c_doodad_type, c_grid_coord));
            }
            //Then monsters by family.
            for (int i = 0; i < base_room.Monster_Families.Count; i++)
            {
                int monster_family_chance = 0;
                Int32.TryParse(base_room.Monster_Family_Chances[i], out monster_family_chance);
                gridCoordinate c_grid_coord = grid_c_from_matrix_c(base_room.Monster_Family_Coordinates[i]);
                if (rGen.Next(100) < monster_family_chance)
                    monster_family_list.Add(new KeyValuePair<string, gridCoordinate>(base_room.Monster_Families[i], c_grid_coord));
            }

            //Then monsters by themselves.
            for (int i = 0; i < base_room.Room_Monsters.Count; i++)
            {
                int monster_chance = 0;
                Int32.TryParse(base_room.Room_Monster_Chances[i], out monster_chance);
                gridCoordinate c_grid_coord = grid_c_from_matrix_c(base_room.Room_Monster_Coordinates[i]);
                if (rGen.Next(100) < monster_chance)
                    monster_list.Add(new KeyValuePair<string, gridCoordinate>(base_room.Room_Monsters[i], c_grid_coord));
            }

            boss_spawn_coordinates = new List<gridCoordinate>();
            for (int i = 0; i < base_room.Boss_Spawn_Coordinates.Count; i++)
                boss_spawn_coordinates.Add(grid_c_from_matrix_c(base_room.Boss_Spawn_Coordinates[i]));
        }
예제 #2
0
        public Room(RoomDC base_room, SpawnTable sTable)
        {
            roomHeight = base_room.RoomHeight;
            roomWidth  = base_room.RoomWidth;
            startXPos  = 0;
            startYPos  = 0;
            has_doors  = false;
            rGen       = new Random();

            //Necropolis only.
            corpses_in_corner         = false;
            corners_that_have_corpses = 0;

            //More general purpose stuff
            c_room_type  = Room_Type.Generic;
            c_floor_type = Tile.Tile_Type.StoneFloor;

            room_tiles   = base_room.Room_Matrix;
            doodad_list  = new List <KeyValuePair <Doodad.Doodad_Type, gridCoordinate> >();
            monster_list = new List <KeyValuePair <string, gridCoordinate> >();
            gold_list    = new List <KeyValuePair <Goldpile, gridCoordinate> >();

            switch (base_room.RoomType)
            {
            case "Gorehound Kennels":
                c_room_type = Room.Room_Type.GHound_Kennel;
                break;

            case "Library":
                c_room_type = Room.Room_Type.Library;
                break;

            case "Darkroom":
                c_room_type = Room.Room_Type.DarkRoom;
                break;

            case "Corpse Storage":
                c_room_type = Room.Room_Type.CorpseStorage;
                break;

            case "Sewer":
                c_room_type = Room.Room_Type.SewerRoom;
                break;

            case "Rubble Room":
                c_room_type = Room.Room_Type.Destroyed;
                break;

            case "Knight Armory":
                c_room_type = Room.Room_Type.KnightArmory;
                break;

            case "Sewer Shaft":
                c_room_type = Room.Room_Type.SewerShaft;
                break;

            case "Jail":
                c_room_type = Room.Room_Type.Jail;
                break;

            case "Mine Shaft":
                c_room_type = Room.Room_Type.MineShaft;
                break;
            }

            //Now to add the appropriate list of monsters & doodads
            //Doodads first.
            for (int i = 0; i < base_room.Room_Doodads.Count; i++)
            {
                Doodad.Doodad_Type c_doodad_type = 0; //Altar by default - not a problem.
                switch (base_room.Room_Doodads[i])
                {
                case "Altar":
                    c_doodad_type = Doodad.Doodad_Type.Altar;
                    break;

                case "ArmorSuit":
                    c_doodad_type = Doodad.Doodad_Type.ArmorSuit;
                    break;

                case "BloodSplatter":
                    c_doodad_type = Doodad.Doodad_Type.Blood_Splatter;
                    break;

                case "Cage":
                    c_doodad_type = Doodad.Doodad_Type.Cage;
                    break;

                case "CorpsePile":
                    c_doodad_type = Doodad.Doodad_Type.CorpsePile;
                    break;

                case "DestroyedArmorSuit":
                    c_doodad_type = Doodad.Doodad_Type.Destroyed_ArmorSuit;
                    break;

                case "Bookshelf":
                    c_doodad_type = Doodad.Doodad_Type.Bookshelf;
                    break;

                case "DestroyedBookshelf":
                    c_doodad_type = Doodad.Doodad_Type.Destroyed_Bookshelf;
                    break;
                }
                gridCoordinate c_grid_coord = grid_c_from_matrix_c(base_room.Room_Doodad_Coordinates[i]);
                c_grid_coord.x += startXPos;
                c_grid_coord.y += startYPos;
                int doodad_chance = 0;
                Int32.TryParse(base_room.Room_Doodad_Chances[i], out doodad_chance);
                if (rGen.Next(100) < doodad_chance)
                {
                    doodad_list.Add(new KeyValuePair <Doodad.Doodad_Type, gridCoordinate>(c_doodad_type, c_grid_coord));
                }
            }

            //Then monsters.
            for (int i = 0; i < base_room.Room_Monsters.Count; i++)
            {
                if (sTable.monster_in_table(base_room.Room_Monsters[i]))
                {
                    int monster_chance = 0;
                    Int32.TryParse(base_room.Room_Monster_Chances[i], out monster_chance);
                    gridCoordinate c_grid_coord = grid_c_from_matrix_c(base_room.Room_Monster_Coordinates[i]);
                    if (rGen.Next(100) < monster_chance)
                    {
                        monster_list.Add(new KeyValuePair <string, gridCoordinate>(base_room.Room_Monsters[i], c_grid_coord));
                    }
                }
            }
        }
예제 #3
0
        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();
            }
        }