Ejemplo n.º 1
0
        private static void scanOctant1(Level level, Location heroLocation, int depth, double startSlope, double endSlope)
        {
            if (depth >= Hero.MAX_SIGHT_DISTANCE)
            {
                return;
            }

            int y = heroLocation.y - depth;
            int x = heroLocation.x - (int)(startSlope * depth);

            while (getSlope(x, y, heroLocation.x, heroLocation.y, false) >= endSlope)
            {
                if (level.blocksSight(new Location(x, y)))
                {
                    if (!level.blocksSight(new Location(x - 1, y)))
                    {
                        double newEndSlope = getSlope(x - 0.5, y + 0.5, heroLocation.x, heroLocation.y, false);
                        scanOctant1(level, heroLocation, depth + 1, startSlope, newEndSlope);
                    }
                }
                else
                {
                    if (level.blocksSight(new Location(x - 1, y)))
                    {
                        startSlope = getSlope(x - 0.5, y - 0.5, heroLocation.x, heroLocation.y, false);
                    }
                }
                level.setLit(new Location(x, y), 0);
                x++;
            }
            x--;
            if (depth < Hero.MAX_SIGHT_DISTANCE && !level.blocksSight(new Location(x, y)))
            {
                scanOctant1(level, heroLocation, depth + 1, startSlope, endSlope);
            }
        }