示例#1
0
        public void set_ranged_attack_aura(Floor fl, gridCoordinate pl_gc, Scroll s, RACursor r1)
        {
            int bow_range = 0;
            if (s == null)
            {
                if (main_hand != null && (main_hand.get_my_weapon_type() == Weapon.Type.Bow ||
                                          main_hand.get_my_weapon_type() == Weapon.Type.Crossbow))
                    bow_range = main_hand.get_my_range();
                else
                    bow_range = off_hand.get_my_range();
            }
            else
                bow_range = s.get_range();

            List<gridCoordinate> endpoints = new List<gridCoordinate>();
            if ((is_bow_equipped() && !is_cbow_equipped()) || s != null)
            {
                endpoints = calculate_endpoints(pl_gc, bow_range);
            }
            else
            {
                endpoints.Add(new gridCoordinate(pl_gc.x, pl_gc.y + bow_range));
                endpoints.Add(new gridCoordinate(pl_gc.x, pl_gc.y - bow_range));
                endpoints.Add(new gridCoordinate(pl_gc.x + bow_range, pl_gc.y));
                endpoints.Add(new gridCoordinate(pl_gc.x - bow_range, pl_gc.y));
            }
            List<VisionRay> range_rays = new List<VisionRay>();

            for (int i = 0; i < endpoints.Count; i++)
            {
                range_rays.Add(new VisionRay(pl_gc, endpoints[i]));
            }
            endpoints.Clear();

            int monsterID = -1;
            while (range_rays.Count > 0)
            {
                for (int i = 0; i < range_rays.Count; i++)
                {
                    bool remove = false;
                    int whoCares = -1;

                    range_rays[i].update();
                    gridCoordinate current_ray_position = new gridCoordinate((int)range_rays[i].my_current_position.X / 32, (int)range_rays[i].my_current_position.Y / 32);
                    int x_difference = positive_difference(pl_gc.x, current_ray_position.x);
                    int y_difference = positive_difference(pl_gc.y, current_ray_position.y);

                    if (!fl.is_tile_opaque(current_ray_position) && (x_difference > 1 || y_difference > 1))
                            fl.set_tile_aura(current_ray_position, Tile.Aura.Attack);

                    if (fl.is_tile_opaque(current_ray_position) ||
                        fl.is_los_blocking_Doodad_here(current_ray_position))
                    {
                        remove = true;
                        if(s != null && s.spell_destroys_walls())
                            fl.set_tile_aura(current_ray_position, Tile.Aura.Attack);
                    }

                    if ((main_hand != null && main_hand.get_my_weapon_type() == Weapon.Type.Crossbow) ||
                        (off_hand != null && off_hand.get_my_weapon_type() == Weapon.Type.Crossbow))
                        if (fl.is_monster_here(current_ray_position, out monsterID) ||
                            fl.is_destroyable_Doodad_here(current_ray_position, out whoCares))
                            remove = true;

                    if (range_rays[i].is_at_end() || remove)
                        range_rays.RemoveAt(i);
                }
            }

            range_rays.Clear();
            if (s != null && s.get_aoe_size() > 1)
            {
                int aoe_range = s.get_aoe_size() / 2;
                endpoints = calculate_endpoints(r1.my_grid_coord, aoe_range);
                bool destroys_walls = s.spell_destroys_walls();

                for (int i = 0; i < endpoints.Count; i++)
                {
                    range_rays.Add(new VisionRay(r1.my_grid_coord, endpoints[i]));
                }
                while (range_rays.Count > 0)
                {
                    for (int i = 0; i < range_rays.Count; i++)
                    {
                        bool remove = false;

                        range_rays[i].update();
                        gridCoordinate current_ray_position = new gridCoordinate((int)range_rays[i].my_current_position.X / 32, (int)range_rays[i].my_current_position.Y / 32);

                        if (!fl.is_tile_opaque(current_ray_position))
                            if (fl.aura_of_specific_tile(current_ray_position) == Tile.Aura.Attack)
                                fl.set_tile_aura(current_ray_position, Tile.Aura.AtkAndAOE);
                            else if(fl.aura_of_specific_tile(current_ray_position) != Tile.Aura.AtkAndAOE &&
                                    fl.aura_of_specific_tile(current_ray_position) != Tile.Aura.Attack)
                                fl.set_tile_aura(current_ray_position, Tile.Aura.AOE_Range);

                        if (fl.is_tile_opaque(current_ray_position) && !destroys_walls)
                            remove = true;

                        if (range_rays[i].is_at_end() || remove)
                            range_rays.RemoveAt(i);
                    }
                }
            }
        }