Ejemplo n.º 1
0
        public static void Calculate(IntVector2 viewerLocation, int visionRange, Grid2D <bool> visibilityMap, IntSize2 mapSize,
                                     Func <IntVector2, bool> blockerDelegate)
        {
            visibilityMap.Clear();

            if (blockerDelegate(viewerLocation) == true)
            {
                return;
            }

            var g = new IntGrid2(new IntVector2(), mapSize);

            g = g.Offset(-viewerLocation.X, -viewerLocation.Y);
            var vr = new IntVector2(visionRange, visionRange);

            g = g.Intersect(new IntGrid2(vr, -vr));

            int visionRangeSquared = (visionRange + 1) * (visionRange + 1);             // +1 to get a bit bigger view area

            foreach (var dst in g.Range())
            {
                if (dst.X * dst.X + dst.Y * dst.Y > visionRangeSquared)
                {
                    continue;
                }

                bool vis = FindLos(viewerLocation, dst, blockerDelegate);
                visibilityMap[dst] = vis;
            }
        }
Ejemplo n.º 2
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value == null)
            {
                throw base.GetConvertFromException(value);
            }

            string source = value as string;

            if (source == null)
            {
                return(base.ConvertFrom(context, culture, value));
            }

            return(IntGrid2.Parse(source));
        }
Ejemplo n.º 3
0
 public IntGrid2Z(IntGrid2 rect, int z)
 {
     m_grid = rect;
     m_z    = z;
 }
Ejemplo n.º 4
0
 public IntGrid2Z(IntVector2 point1, IntVector2 point2, int z)
 {
     m_grid = new IntGrid2(point1, point2);
     m_z    = z;
 }
Ejemplo n.º 5
0
 public IntGrid2Z(int x, int y, int columns, int rows, int z)
 {
     m_grid = new IntGrid2(x, y, columns, rows);
     m_z    = z;
 }
Ejemplo n.º 6
0
 public IntGrid3(IntGrid2 rect, int z)
     : this(rect.X, rect.Y, z, rect.Columns, rect.Rows, 1)
 {
 }