예제 #1
0
        protected override void InitGrid()
        {
            VectorPoint rectDimensions = Dimensions;

            switch (shape)
            {
            case Shape.Rectangle:
                base.Grid = PointyHexGrid <TileCell> .Rectangle(rectDimensions.X, rectDimensions.Y);

                break;

            case Shape.Parallelogram:
                base.Grid = PointyHexGrid <TileCell> .Parallelogram(rectDimensions.X, rectDimensions.Y);

                break;

            case Shape.FatRectangle:
                base.Grid = PointyHexGrid <TileCell> .FatRectangle(rectDimensions.X, rectDimensions.Y);

                break;

            case Shape.ThinRectangle:
                base.Grid = PointyHexGrid <TileCell> .ThinRectangle(rectDimensions.X, rectDimensions.Y);

                break;

            case Shape.Hexagon:
                base.Grid = PointyHexGrid <TileCell> .Hexagon(Size);

                break;

            case Shape.UpTriangle:
                base.Grid = PointyHexGrid <TileCell> .UpTriangle(Size);

                break;

            case Shape.DownTriangle:
                base.Grid = PointyHexGrid <TileCell> .DownTriangle(Size);

                break;

            case Shape.Diamond:
                base.Grid = PointyHexGrid <TileCell> .Diamond(Size);

                break;

            case Shape.Single:
                base.Grid = PointyHexGrid <TileCell> .Single();

                break;

            case Shape.Custom:
                base.Grid = GetCustomGrid();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #2
0
파일: Op.cs 프로젝트: mhaque3/soa_unity
        public PointyHexShapeInfo <TCell> Default(int width, int height)
        {
            var rawInfow = MakeShapeStorageInfo <PointyHexPoint>(
                width,
                height,
                x => PointyHexGrid <TCell> .DefaultContains(x, width, height));

            return(new PointyHexShapeInfo <TCell>(rawInfow));
        }
예제 #3
0
        public IGrid <TNewCell, PointyHexPoint> MakeVertexGrid <TNewCell>()
        {
            var vertices = this.SelectMany(x => x.GetVertices());
            var storage  = PointyHexGrid <TNewCell> .CalculateStorage(vertices);

            var offset = PointyHexGrid <TNewCell> .GridPointFromArrayPoint(storage.offset);

            return(new PointyHexGrid <TNewCell>(storage.dimensions.X, storage.dimensions.Y, x => IsInsideVertexGrid(x + offset), offset));
        }
예제 #4
0
        public static bool __CompilerHint2__PointyHex__MeshTileCell()
        {
            //Ensures abstract super classes for base grids gets created
            var grid = new PointyHexGrid <MeshTileCell>(1, 1, p => p == PointyHexPoint.Zero, x => x, x => x, new List <PointyHexPoint>());

            //Ensures shape infpo classes get created
            var shapeStorageInfo = new ShapeStorageInfo <PointyHexPoint>(new IntRect(), p => true);
            var shapeInfo        = new PointyHexShapeInfo <MeshTileCell>(shapeStorageInfo);

            return(grid[grid.First()] == null || shapeInfo.Translate(PointyHexPoint.Zero) != null);
        }
예제 #5
0
        public static bool __CompilerHint__PointyHex__MeshTileCell()
        {
            var grid = new PointyHexGrid <MeshTileCell[]>(1, 1);

            foreach (var point in grid)
            {
                grid[point] = new MeshTileCell[1];
            }

            var shapeStorageInfo = new ShapeStorageInfo <PointyHexPoint>(new IntRect(), p => true);
            var shapeInfo        = new PointyHexShapeInfo <MeshTileCell>(shapeStorageInfo);

            return(grid[grid.First()][0] == null || shapeInfo.Translate(PointyHexPoint.Zero) != null);
        }
예제 #6
0
        /**
         *      Call this method if you use a CairoGrid.
         *      Replace	the type __CellType to whatever type you have in your grid.
         *
         *      You can call the method anywhere in your code.
         *
         *              if(!__CompilerHint__Cairo()) return;
         *
         *      This methods always returns true.
         *
         *      @since 1.6
         */
        public static bool __CompilerHint__Cairo()
        {
            //Ensures abstract super classes for base grids gets created
            var grid = new PointyHexGrid <__CellType[]>(1, 1);

            foreach (var point in grid)
            {
                grid[point] = new __CellType[1];
            }

            //Ensures shape infpo classes get created
            var shapeStorageInfo = new ShapeStorageInfo <CairoPoint>(new IntRect(), p => true);
            var shapeInfo        = new CairoShapeInfo <__CellType>(shapeStorageInfo);

            return(grid[grid.First()][0] == null || shapeInfo.IncIndex(0) != null);
        }
예제 #7
0
        public PointyHexHexagonWrapper(int n)
        {
            int colorCount = 3 * n * n - 3 * n + 1;
            int x1         = 3 * n - 2;

            wrappedPoints = new PointyHexPoint[colorCount];
            var grid = PointyHexGrid <int> .Hexagon(n);

            colorFunc = x => x.GetColor(colorCount, x1, 1);

            foreach (var point in grid)
            {
                int color = colorFunc(point);
                wrappedPoints[color] = point;
            }
        }
예제 #8
0
        protected override void InitGrid()
        {
            int width  = Dimensions.X;
            int height = Dimensions.Y;

            switch (shape)
            {
            case Shape.Parallelogram:
                base.Grid = PointyHexGrid <MeshTileCell> .HorizontallyWrappedParallelogram(width, height);

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #9
0
        /**
         *      This method is provided for generic testing purposes.
         *      It should generally not be used in production code: it may
         *      be slow and not type-safe.
         */
        public static TGrid MakeGrid <TPoint, TGrid, TCell>(int width, int height, TPoint offset)
            where TPoint : IGridPoint <TPoint>
            where TGrid : IGrid <TCell, TPoint>
        {
            if (typeof(TPoint) == typeof(PointyHexPoint))
            {
                Debug.Assert(typeof(TGrid) == typeof(PointyHexGrid <TCell>));

                return((TGrid)(object)new PointyHexGrid <TCell>(
                           width,
                           height,
                           x => PointyHexGrid <TCell> .DefaultContains(x, width, height),
                           (PointyHexPoint)(object)offset));
            }
            if (typeof(TPoint) == typeof(FlatHexPoint))
            {
                Debug.Assert(typeof(TGrid) == typeof(FlatHexGrid <TCell>));

                return((TGrid)(object)new FlatHexGrid <TCell>(
                           width,
                           height,
                           x => FlatHexGrid <TCell> .DefaultContains(x, width, height),
                           (FlatHexPoint)(object)offset));
            }
            if (typeof(TPoint) == typeof(RectPoint))
            {
                Debug.Assert(typeof(TGrid) == typeof(RectGrid <TCell>));

                return((TGrid)(object)new RectGrid <TCell>(
                           width,
                           height,
                           x => RectGrid <TCell> .DefaultContains(x, width, height),
                           (RectPoint)(object)offset));
            }
            if (typeof(TPoint) == typeof(DiamondPoint))
            {
                Debug.Assert(typeof(TGrid) == typeof(DiamondGrid <TCell>));

                return((TGrid)(object)new DiamondGrid <TCell>(
                           width,
                           height,
                           x => DiamondGrid <TCell> .DefaultContains(x, width, height),
                           (DiamondPoint)(object)offset));
            }

            throw new NotSupportedException();
        }
예제 #10
0
        public static bool __CompilerHint__PointyRhomb__SpriteCell()
        {
            var grid1 = new PointyHexGrid <SpriteCell[]>(1, 1);

            foreach (var point in grid1)
            {
                grid1[point] = new SpriteCell[1];
            }

            var grid2 = new PointyRhombGrid <SpriteCell>(1, 1);

            foreach (var point in grid2)
            {
                grid2[point] = null;
            }

            var shapeStorageInfo = new ShapeStorageInfo <PointyRhombPoint>(new IntRect(), p => true);
            var shapeInfo        = new PointyRhombShapeInfo <SpriteCell>(shapeStorageInfo);

            return(grid1[grid1.First()][0] == null || grid2[grid2.First()] == null || shapeInfo.IncIndex(0) != null);
        }
예제 #11
0
        public static bool __CompilerHint__FlatTri__TileCell()
        {
            var grid1 = new PointyHexGrid <TileCell[]>(1, 1);

            foreach (var point in grid1)
            {
                grid1[point] = new TileCell[1];
            }

            var grid2 = new FlatTriGrid <TileCell>(1, 1);

            foreach (var point in grid2)
            {
                grid2[point] = null;
            }

            var shapeStorageInfo = new ShapeStorageInfo <FlatTriPoint>(new IntRect(), p => true);
            var shapeInfo        = new FlatTriShapeInfo <TileCell>(shapeStorageInfo);

            return(grid1[grid1.First()][0] == null || grid2[grid2.First()] == null || shapeInfo.IncIndex(0) != null);
        }
예제 #12
0
 public CairoShapeInfo <TCell> Hexagon(int side)
 {
     return(ShapeFromBase(PointyHexGrid <TCell> .BeginShape().Hexagon(side)));
 }
예제 #13
0
 public static ArrayPoint ArrayPointFromGridPoint(PointyHexPoint point)
 {
     return(PointyHexGrid <TCell> .ArrayPointFromGridPoint(point));
 }
예제 #14
0
 public static PointyHexPoint GridPointFromArrayPoint(ArrayPoint point)
 {
     return(PointyHexGrid <TCell> .GridPointFromArrayPoint(point));
 }
예제 #15
0
 public CairoShapeInfo <TCell> Parallelogram(int width, int height)
 {
     return(ShapeFromBase(PointyHexGrid <TCell> .BeginShape().Parallelogram(width, height)));
 }
예제 #16
0
 public FlatTriShapeInfo <TCell> Rectangle(int width, int height)
 {
     return(ShapeFromBase(PointyHexGrid <TCell> .BeginShape().Rectangle(width, height)));
 }
예제 #17
0
 protected override ArrayPoint ArrayPointFromGridPoint(PointyHexPoint point)
 {
     return(PointyHexGrid <TCell> .ArrayPointFromGridPoint(point));
 }
예제 #18
0
 protected override PointyHexPoint GridPointFromArrayPoint(ArrayPoint point)
 {
     return(PointyHexGrid <TCell> .GridPointFromArrayPoint(point));
 }
예제 #19
0
 public CairoShapeInfo <TCell> ThinRectangle(int width, int height)
 {
     return(ShapeFromBase(PointyHexGrid <TCell> .BeginShape().ThinRectangle(width, height)));
 }
예제 #20
0
파일: Op.cs 프로젝트: mhaque3/soa_unity
 /**
  *      Starts a compound shape operation.
  *
  *      Any shape that is defined in terms of other shape operations must use this method, and use Endgroup() to end the definition.
  *
  *              public static PointyHexShapeInfo<TCell> MyCustomShape(this PointyHexOp<TCell> op)
  *              {
  *                      return
  *                              BeginGroup()
  *                                      .Shape1()
  *                                      .Union()
  *                                      .Shape2()
  *                              .EndGroup(op);
  *              }
  *
  *      @since 1.1
  */
 public PointyHexOp <TCell> BeginGroup()
 {
     return(PointyHexGrid <TCell> .BeginShape());
 }