public override bool CanSee(CGPoint pos0, CGPoint pos1)
        {
            var a = ConvertWorldPointToLevelMapPoint(pos0);
            var b = ConvertWorldPointToLevelMapPoint(pos1);

            var deltaX = b.X - a.Y;
            var deltaY = b.Y - a.Y;
            var dist   = GraphicsUtilities.DistanceBetweenCGPoints(a, b);
            var inc    = 1 / dist;
            var p      = CGPoint.Empty;

            for (nfloat i = 0; i <= 1; i += inc)
            {
                p.X = a.X + i * deltaX;
                p.Y = a.Y + i * deltaY;

                DataMap point = levelMap.QueryLevelMap(p);
                if (point.Wall > 200)
                {
                    return(false);
                }
            }
            return(true);
        }
        void AddCollisionWalls()
        {
            var sw = new Stopwatch();

            sw.Start();

            var filled = new byte[LevelMapSize * LevelMapSize];

            int numVolumes = 0;
            int numBlocks  = 0;

            // Add horizontal collision walls.
            for (int y = 0; y < LevelMapSize; y++)               // iterate in horizontal rows
            {
                for (int x = 0; x < LevelMapSize; x++)
                {
                    var     location = new CGPoint(x, y);
                    DataMap spot     = levelMap.QueryLevelMap(location);

                    // Get the world space point for this pixel.
                    CGPoint worldPoint = ConvertLevelMapPointToWorldPoint(location);

                    if (spot.Wall < 200)
                    {
                        continue;                         // no wall
                    }
                    int     horizontalDistanceFromLeft = x;
                    DataMap nextSpot = spot;
                    while (horizontalDistanceFromLeft < LevelMapSize &&
                           nextSpot.Wall >= 200 &&
                           filled [(y * LevelMapSize) + horizontalDistanceFromLeft] == 0)
                    {
                        horizontalDistanceFromLeft++;
                        nextSpot = levelMap.QueryLevelMap(new CGPoint(horizontalDistanceFromLeft, y));
                    }

                    int wallWidth = horizontalDistanceFromLeft - x;
                    int verticalDistanceFromTop = y;

                    if (wallWidth > 8)
                    {
                        nextSpot = spot;
                        while (verticalDistanceFromTop < LevelMapSize &&
                               nextSpot.Wall >= 200)
                        {
                            verticalDistanceFromTop++;
                            nextSpot = levelMap.QueryLevelMap(new CGPoint(x + (wallWidth / 2), verticalDistanceFromTop));
                        }

                        int wallHeight = (verticalDistanceFromTop - y);
                        for (int j = y; j < verticalDistanceFromTop; j++)
                        {
                            for (int i = x; i < horizontalDistanceFromLeft; i++)
                            {
                                filled [j * LevelMapSize + i] = 255;
                                numBlocks++;
                            }
                        }

                        AddCollisionWallAtWorldPoint(worldPoint, LevelMapDivisor * wallWidth, LevelMapDivisor * wallHeight);
                        numVolumes++;
                    }
                }
            }

            // Add vertical collision walls.
            for (int x = 0; x < LevelMapSize; x++)               // iterate in vertical rows
            {
                for (int y = 0; y < LevelMapSize; y++)
                {
                    var     location = new CGPoint(x, y);
                    DataMap spot     = levelMap.QueryLevelMap(location);

                    // Get the world space point for this pixel.
                    CGPoint worldPoint = ConvertLevelMapPointToWorldPoint(location);

                    if (spot.Wall < 200 || filled [y * LevelMapSize + x] != 0)
                    {
                        continue;                         // no wall, or already filled from X collision walls
                    }
                    int     verticalDistanceFromTop = y;
                    DataMap nextSpot = spot;
                    while (verticalDistanceFromTop < LevelMapSize &&
                           nextSpot.Wall >= 200 &&
                           filled [verticalDistanceFromTop * LevelMapSize + x] == 0)
                    {
                        verticalDistanceFromTop++;
                        nextSpot = levelMap.QueryLevelMap(new CGPoint(x, verticalDistanceFromTop));
                    }

                    int wallHeight = verticalDistanceFromTop - y;
                    int horizontalDistanceFromLeft = x;

                    if (wallHeight > 8)
                    {
                        nextSpot = spot;
                        while (horizontalDistanceFromLeft < LevelMapSize &&
                               nextSpot.Wall >= 200)
                        {
                            horizontalDistanceFromLeft++;
                            nextSpot = levelMap.QueryLevelMap(new CGPoint(horizontalDistanceFromLeft, y + wallHeight / 2));
                        }

                        int wallLength = horizontalDistanceFromLeft - x;
                        for (int j = y; j < verticalDistanceFromTop; j++)
                        {
                            for (int i = x; i < horizontalDistanceFromLeft; i++)
                            {
                                filled [j * LevelMapSize + i] = 255;
                                numBlocks++;
                            }
                        }

                        AddCollisionWallAtWorldPoint(worldPoint, LevelMapDivisor * wallLength, LevelMapDivisor * wallHeight);
                        numVolumes++;
                    }
                }
            }

            Console.WriteLine("converted {0} collision blocks into {1} volumes in {2} seconds", numBlocks, numVolumes, sw.Elapsed.Seconds);
        }