コード例 #1
0
ファイル: Monster.cs プロジェクト: SnarkhProject/Cronkpit
        public bool is_doodad_within(Floor fl, int radius, Doodad.Doodad_Type target_doodad)
        {
            int doodad_index = 0;

            while (fl.Doodad_by_index(doodad_index) != null)
            {
                Doodad d = fl.Doodad_by_index(doodad_index);
                if (d.get_my_doodad_type() == target_doodad)
                {
                    gridCoordinate doodad_gcoord = d.get_g_coord();
                    for (int i = 0; i < my_grid_coords.Count; i++)
                    {
                        if (doodad_gcoord.x >= (my_grid_coords[i].x - radius) &&
                            doodad_gcoord.x <= (my_grid_coords[i].x + radius) &&
                            doodad_gcoord.y >= (my_grid_coords[i].y - radius) &&
                            doodad_gcoord.y <= (my_grid_coords[i].y + radius))
                        {
                            return(true);
                        }
                    }
                }
                doodad_index++;
            }

            return(false);
        }
コード例 #2
0
ファイル: Necromancer.cs プロジェクト: SnarkhProject/Cronkpit
        public void raise_additional_undead(Floor fl, Player pl, int grade)
        {
            if (is_doodad_within(fl, sight_range - 1, Doodad.Doodad_Type.CorpsePile))
            {
                List <Doodad> corpses      = new List <Doodad>();
                int           corpse_index = 0;
                while (fl.Doodad_by_index(corpse_index) != null)
                {
                    Doodad         d = fl.Doodad_by_index(corpse_index);
                    gridCoordinate corpse_position = d.get_g_coord();
                    if (d.get_my_doodad_type() == Doodad.Doodad_Type.CorpsePile &&
                        corpse_position.x <= my_grid_coords[0].x + (sight_range - 1) &&
                        corpse_position.x >= my_grid_coords[0].x - (sight_range - 1) &&
                        corpse_position.y <= my_grid_coords[0].y + (sight_range - 1) &&
                        corpse_position.y >= my_grid_coords[0].y - (sight_range - 1) &&
                        can_i_see_point(fl, corpse_position) &&
                        !occupies_tile(corpse_position))
                    {
                        corpses.Add(fl.Doodad_by_index(corpse_index));
                    }
                    corpse_index++;
                }

                if (corpses.Count > 0)
                {
                    int            target_corpse     = rGen.Next(corpses.Count);
                    int            corpse_ID         = corpses[target_corpse].get_my_index();
                    gridCoordinate rezzed_corpse_pos = new gridCoordinate(corpses[target_corpse].get_g_coord());
                    fl.remove_doodad_at_index(corpse_ID);

                    List <Monster> fl_monsters        = fl.see_badGuys();
                    int            next_index         = -1;
                    bool           found_valid_number = false;
                    while (!found_valid_number)
                    {
                        next_index++;
                        bool valid_number = true;
                        for (int i = 0; i < fl_monsters.Count; i++)
                        {
                            if (next_index == fl_monsters[i].my_Index)
                            {
                                valid_number = false;
                            }
                        }

                        if (valid_number)
                        {
                            found_valid_number = true;
                        }
                    }

                    int  whoCares     = -1;
                    bool force_wander = (pl.get_my_grid_C().x == rezzed_corpse_pos.x &&
                                         pl.get_my_grid_C().y == rezzed_corpse_pos.y) ||
                                        fl.is_monster_here(rezzed_corpse_pos, out whoCares) ||
                                        !fl.isWalkable(rezzed_corpse_pos);
                    switch (grade)
                    {
                    //Minor undead
                    case 1:
                        int minor_monster_type = rGen.Next(3);
                        int minor_skel_type    = rGen.Next(6);
                        add_minor_undead(fl, minor_monster_type, minor_skel_type,
                                         next_index, rezzed_corpse_pos, force_wander, pl);
                        break;

                    //Major undead
                    case 2:
                        break;

                    //Lethal undead
                    case 3:
                        break;
                    }
                    fl.add_new_popup("Summoned!", Popup.popup_msg_color.Purple, rezzed_corpse_pos);
                }
            }
        }