Esempio n. 1
0
        public PointyRhombShapeInfo <TCell> Default(int width, int height)
        {
            var rawInfow = MakeShapeStorageInfo <PointyRhombPoint>(
                width,
                height,
                x => PointyRhombGrid <TCell> .DefaultContains(x, width, height));

            return(new PointyRhombShapeInfo <TCell>(rawInfow));
        }
Esempio n. 2
0
        /// <summary>
        /// Makes an edge grid for this grid.
        /// </summary>
        public IGrid <TNewCell, PointyRhombPoint> MakeEdgeGrid <TNewCell>()
        {
            var edges   = this.SelectMany(x => x.GetEdges());
            var storage = PointyRhombGrid <TNewCell> .CalculateStorage(edges);

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

            return(new PointyRhombGrid <TNewCell>(storage.dimensions.X + 2, storage.dimensions.Y + 2, x => IsInsideEdgeGrid(x + offset), offset));
        }
        protected override void InitGrid()
        {
            VectorPoint rectDimensions = Dimensions;

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

                break;

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

                break;

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

                break;

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

                break;

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

                break;

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

                break;

            case Shape.SingleGroup:
                base.Grid = PointyRhombGrid <TileCell> .SingleGroup();

                break;

            case Shape.Custom:
                var shapeBuilder = GetComponent <CustomGridBuilder>();
                base.Grid = shapeBuilder.MakeGrid <TileCell, PointyRhombPoint>();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Esempio n. 4
0
        public static bool __CompilerHint__PointyRhomb__MeshTileCell()
        {
            var grid1 = new PointyHexGrid <MeshTileCell[]>(1, 1);

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

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

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

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

            return(grid1[grid1.First()][0] == null || grid2[grid2.First()] == null || shapeInfo.IncIndex(0) != null);
        }
Esempio n. 5
0
 protected override ArrayPoint ArrayPointFromGridPoint(PointyHexPoint point)
 {
     return(PointyRhombGrid <TCell> .ArrayPointFromGridPoint(point));
 }
Esempio n. 6
0
 protected override PointyHexPoint GridPointFromArrayPoint(ArrayPoint point)
 {
     return(PointyRhombGrid <TCell> .GridPointFromArrayPoint(point));
 }
Esempio n. 7
0
 /**
  *      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 PointyRhombShapeInfo<TCell> MyCustomShape(this PointyRhombOp<TCell> op)
  *              {
  *                      return
  *                              BeginGroup()
  *                                      .Shape1()
  *                                      .Union()
  *                                      .Shape2()
  *                              .EndGroup(op);
  *              }
  *
  *      @since 1.1
  */
 public PointyRhombOp <TCell> BeginGroup()
 {
     return(PointyRhombGrid <TCell> .BeginShape());
 }