Example #1
0
        public void render_monsters_to_board(ref List<Monster> fl_monsters, 
                                             ref List<Doodad> fl_doodads,
                                             Spawn_Table_Manager spawn_manager,
                                             ContentManager cmgr,
                                             Texture2D blank_texture, FloorBuilder flb)
        {
            List<KeyValuePair<string, gridCoordinate>> final_monster_list = new List<KeyValuePair<string,gridCoordinate>>();
            //Put all monsters onto the final spawning list, with the exception of Schrodingers_hk, which is spawned immediately.
            for (int i = 0; i < monster_list.Count; i++)
            {
                string monster_name = monster_list[i].Key;
                gridCoordinate monster_coord = monster_list[i].Value;
                gridCoordinate new_monster_coord = new gridCoordinate(monster_coord.x + startXPos,
                                                                      monster_coord.y + startYPos);
                if (flb.is_tile_obstructed(new_monster_coord))
                    new_monster_coord = null;

                if (String.Compare(monster_name, "Schrodingers_HK") != 0)
                    final_monster_list.Add(new KeyValuePair<string, gridCoordinate>(monster_name, new_monster_coord));
                else
                {
                    //If the spawn table comes up hollow knight, add it with a normal chance to spawn a red knight
                    //Otherwise add a suit of armor.
                    if (spawn_manager.roll_to_spawn_family(Monster.Monster_Family.SpiritKnight))
                        spawn_manager.place_monster_from_family(Monster.Monster_Family.SpiritKnight, ref fl_monsters, blank_texture,
                                                                new_monster_coord, flb);
                    else
                        if(new_monster_coord != null && !flb.is_tile_obstructed(new_monster_coord))
                            fl_doodads.Add(new Doodad(Doodad.Doodad_Type.ArmorSuit, cmgr, new_monster_coord, fl_doodads.Count));
                }
            }

            //Spawn all monsters placed by family.
            for (int i = 0; i < monster_family_list.Count; i++)
            {
                //Place at perscribed spot
                gridCoordinate new_monster_coord = new gridCoordinate(monster_family_list[i].Value.x + startXPos,
                                                                      monster_family_list[i].Value.y + startYPos);
                //Unless said spot is blocked - then find a new, random position for the monster. This will occur automatically
                //upon a null coordinate being passed.
                if (flb.is_tile_obstructed(new_monster_coord))
                    new_monster_coord = null;

                if (spawn_manager.family_in_table(monster_family_list[i].Key))
                    spawn_manager.place_monster_from_family(monster_family_list[i].Key, ref fl_monsters, blank_texture,
                                                            new_monster_coord, flb);
            }

            //Spawn all monsters
            for (int i = 0; i < final_monster_list.Count; i++)
            {
                spawn_manager.place_specific_monster_byString(final_monster_list[i].Key, ref fl_monsters, blank_texture,
                                                              final_monster_list[i].Value, flb);
            }
        }
Example #2
0
        public void render_to_board(List<List<Tile>> board, Texture2D general_sheet, Texture2D dungeon_sheet,
                                    List<KeyValuePair<Tile.Tile_Type, gridCoordinate>> source_map, FloorBuilder flb)
        {
            switch (c_room_type)
            {
                case Room_Type.Generic:
                case Room_Type.GenericCircular:
                    for (int x = startXPos; x < startXPos + roomWidth; x++)
                        for (int y = startYPos; y < startYPos + roomHeight; y++)
                            if (c_room_type == Room_Type.GenericCircular &&
                                circular_room_matrix[x - startXPos][y - startYPos])
                                board[x][y].set_tile_type(c_floor_type, general_sheet, dungeon_sheet, source_map);
                            else
                                board[x][y].set_tile_type(c_floor_type, general_sheet, dungeon_sheet, source_map);
                    if (c_column_type != Column_Pattern.None)
                    {
                        List<gridCoordinate> chosen_points = new List<gridCoordinate>();
                        switch (c_column_type)
                        {
                            case Column_Pattern.Four_Corners:
                                chosen_points.Add(new gridCoordinate(startXPos + 1, startYPos + 1));
                                chosen_points.Add(new gridCoordinate(startXPos + roomWidth - 2, startYPos + 1));
                                chosen_points.Add(new gridCoordinate(startXPos + 1, startYPos + roomHeight - 2));
                                chosen_points.Add(new gridCoordinate(startXPos + roomWidth - 2, startYPos + roomHeight - 2));
                                break;
                            case Column_Pattern.Center_Pillar:
                                chosen_points.Add(findCenter());
                                if (roomWidth % 2 == 0) //Both room width + height are even
                                    chosen_points.Add(new gridCoordinate(findCenter(), gridCoordinate.direction.Left));
                                if(roomHeight % 2 == 0)
                                    chosen_points.Add(new gridCoordinate(findCenter(), gridCoordinate.direction.Up));
                                if(roomWidth % 2 == 0 && roomHeight % 2 == 0)
                                    chosen_points.Add(new gridCoordinate(findCenter(), gridCoordinate.direction.UpLeft));
                                break;
                            //These are by far the two most complicated types of columns to put in rooms.
                            case Column_Pattern.Horizontal_Rows:
                            case Column_Pattern.Vertical_Rows:
                                //"Row 1" is the left or the top row.
                                //"Row 2" is the right or the bottom row.
                                //Row_X_points[0] is "n_point" or the point incremented with a negative value
                                //Row_X_points[1] is "p_point" or the point incremented with a positive value

                                //Assumes the room is an odd size on the axis that's to be incremented. Adjusted if
                                //the room is an even size.
                                bool even_axis_size = false;
                                //All values are set to -1 to force an exception if they're set improperly
                                //By the next section of code.
                                int row_1_x = -1;
                                int row_1_y = -1;
                                int row_2_x = -1;
                                int row_2_y = -1;
                                int x_incr_value = 0;
                                int y_incr_value = 0;
                                if (c_column_type == Column_Pattern.Horizontal_Rows)
                                {
                                    //Set the x & y values.
                                    row_1_x = startXPos + (roomWidth / 2);
                                    row_2_x = startXPos + (roomWidth / 2);
                                    row_1_y = startYPos + 1;
                                    row_2_y = startYPos + roomHeight - 2;

                                    //Set the incr value
                                    x_incr_value = 2;
                                    //I don't like adding a special case here but it's warranted.
                                    //Without this, a 9-wide room looks like this:
                                    //[_][_][X][_][X][_][X][_][_]
                                    //WHICH LOOKS REALLY STRANGE
                                    //The special case fixes it to this: [_][X][_][_][X][_][_][X][_]
                                    //Which looks way better.
                                    if (roomWidth == 9)
                                        x_incr_value += 1;

                                    //Adjust even_axis_size as needed
                                    if (roomWidth % 2 == 0)
                                        even_axis_size = true;
                                }
                                else //Vertical rows
                                {
                                    row_1_x = startXPos + 1;
                                    row_2_x = startXPos + roomWidth - 2;
                                    row_1_y = startYPos + (roomHeight / 2);
                                    row_2_y = startYPos + (roomHeight / 2);

                                    y_incr_value = 2;
                                    if (roomHeight == 9)
                                        y_incr_value += 1;

                                    if (roomHeight % 2 == 0)
                                        even_axis_size = true;
                                }
                                gridCoordinate[] row_1_points = new gridCoordinate[] { new gridCoordinate(row_1_x, row_1_y), new gridCoordinate(row_1_x, row_1_y) };
                                gridCoordinate[] row_2_points = new gridCoordinate[] { new gridCoordinate(row_2_x, row_2_y), new gridCoordinate(row_2_x, row_2_y) };

                                //The starting point of each point is adjusted if the room size is even.
                                if (even_axis_size)
                                {
                                    if (c_column_type == Column_Pattern.Horizontal_Rows)
                                    {
                                        row_1_points[0].x -= 2;
                                        row_2_points[0].x -= 2;
                                        row_1_points[1].x += 1;
                                        row_2_points[1].x += 1;
                                    }
                                    else
                                    {
                                        row_1_points[0].y -= 2;
                                        row_2_points[0].y -= 2;
                                        row_1_points[1].y += 1;
                                        row_2_points[1].y += 1;
                                    }
                                }

                                //While none of the points are on or near a wall tile of the room, we increment as needed
                                //First, declare the points that we're going to be adding to the main values to increment them
                                gridCoordinate p_incr_coord = new gridCoordinate(x_incr_value, y_incr_value);
                                gridCoordinate n_incr_coord = new gridCoordinate(x_incr_value*-1, y_incr_value*-1);
                                while(!is_on_or_near_wallTile(row_1_points[0]) &&
                                      !is_on_or_near_wallTile(row_1_points[1]) &&
                                      !is_on_or_near_wallTile(row_2_points[0]) &&
                                      !is_on_or_near_wallTile(row_2_points[1]))
                                {
                                    chosen_points.Add(new gridCoordinate(row_1_points[0]));
                                    chosen_points.Add(new gridCoordinate(row_1_points[1]));
                                    chosen_points.Add(new gridCoordinate(row_2_points[0]));
                                    chosen_points.Add(new gridCoordinate(row_2_points[1]));
                                    row_1_points[0].combineCoords(n_incr_coord);
                                    row_1_points[1].combineCoords(p_incr_coord);
                                    row_2_points[0].combineCoords(n_incr_coord);
                                    row_2_points[1].combineCoords(p_incr_coord);
                                }

                                break;
                        }
                        for (int i = 0; i < chosen_points.Count; i++)
                            board[chosen_points[i].x][chosen_points[i].y].set_tile_type(Tile.Tile_Type.Void, general_sheet, dungeon_sheet, source_map);
                    }
                    break;
                case Room_Type.SewerShaft:
                case Room_Type.MineShaft:
                    //TODO - add shaft generation code here.
                    Tile.Tile_Type edge_fl_type = Tile.Tile_Type.StoneFloor;
                    Tile.Tile_Type central_fl_type = Tile.Tile_Type.Deep_Sewage;
                    if (c_room_type == Room_Type.MineShaft)
                    {
                        edge_fl_type = Tile.Tile_Type.Natural_Stone_Floor;
                        central_fl_type = Tile.Tile_Type.Gravel;
                    }

                    bool horizontal_shaft = false;
                    if (roomHeight == 3)
                        horizontal_shaft = true;

                    for (int x = startXPos; x < startXPos + roomWidth; x++)
                        for (int y = startYPos; y < startYPos + roomHeight; y++)
                        {
                            if (horizontal_shaft)
                            {
                                if (y == startYPos + 1 && x != startXPos && x != startXPos + roomWidth - 1)
                                    board[x][y].set_tile_type(central_fl_type, general_sheet, dungeon_sheet, source_map);
                                else
                                    board[x][y].set_tile_type(edge_fl_type, general_sheet, dungeon_sheet, source_map);
                            }
                            else
                            {
                                if (x == startXPos + 1 && y != startYPos && y != startYPos + roomHeight - 1)
                                    board[x][y].set_tile_type(central_fl_type, general_sheet, dungeon_sheet, source_map);
                                else
                                    board[x][y].set_tile_type(edge_fl_type, general_sheet, dungeon_sheet, source_map);
                            }
                        }

                    break;
                default:
                    for (int y = startYPos; y < startYPos + roomHeight; y++)
                    {
                        string[] row = room_tiles[y - startYPos].Split(' ');
                        for (int x = startXPos; x < startXPos + roomWidth; x++)
                        {
                            if (String.Compare(row[x - startXPos], "EX") == 0)
                            {
                                flb.set_exit_location(new gridCoordinate(x, y));
                                if (flb.get_current_floor_number() % 12 == 0)
                                    row[x - startXPos] = "DNEX";
                            }

                            if (String.Compare(row[x - startXPos], "EN") == 0)
                                flb.set_entrance_location(new gridCoordinate(x, y));

                            if (String.Compare(row[x - startXPos], "V") != 0)
                                board[x][y].set_tile_type_str(row[x - startXPos], general_sheet, dungeon_sheet, source_map);
                        }
                    }
                    break;
            }
        }
Example #3
0
        public void render_doodads_to_board(ref List<Doodad> fl_doodads, int fl_size, ContentManager cmgr, FloorBuilder flb)
        {
            for (int i = 0; i < doodad_list.Count; i++)
            {
                gridCoordinate doodad_coord = doodad_list[i].Value;
                gridCoordinate new_doodad_coord = new gridCoordinate(doodad_coord.x + startXPos,
                                                                     doodad_coord.y + startYPos);

                if(!flb.is_tile_obstructed(new_doodad_coord))
                    fl_doodads.Add(new Doodad(doodad_list[i].Key, cmgr, new_doodad_coord, fl_doodads.Count));
            }

            if (bonus_gold > 0)
            {
                gridCoordinate tbox_gc = new gridCoordinate(-1, -1);
                List<gridCoordinate> potential_tbox_spots = new List<gridCoordinate>();
                for (int x = 0; x < roomWidth; x++)
                {
                    gridCoordinate target_gc = new gridCoordinate(startXPos + x, startYPos);
                    gridCoordinate target_gc_2 = new gridCoordinate(startXPos + x, startYPos + roomHeight - 1);
                    if(!flb.is_tile_obstructed(target_gc))
                        potential_tbox_spots.Add(target_gc);
                    if (!flb.is_tile_obstructed(target_gc_2))
                        potential_tbox_spots.Add(target_gc_2);
                }

                for (int y = 0; y < roomHeight; y++)
                {
                    gridCoordinate target_gc = new gridCoordinate(startXPos, startYPos + y);
                    gridCoordinate target_gc_2 = new gridCoordinate(startXPos + roomWidth - 1, startYPos + y);
                    if (!flb.is_tile_obstructed(target_gc))
                        potential_tbox_spots.Add(target_gc);
                    if (!flb.is_tile_obstructed(target_gc_2))
                        potential_tbox_spots.Add(target_gc_2);
                }

                if (potential_tbox_spots.Count > 0)
                    tbox_gc = potential_tbox_spots[rGen.Next(potential_tbox_spots.Count)];
                else
                    tbox_gc = flb.random_valid_position(fl_size);

                Doodad treasure_box = new Doodad(Doodad.Doodad_Type.TreasureBox, cmgr, tbox_gc, fl_doodads.Count);
                treasure_box.set_chest_contents(bonus_gold);
                fl_doodads.Add(treasure_box);
            }
        }