示例#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);
            }
        }
示例#2
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);
            }
        }