Ejemplo n.º 1
0
        public FlatRhombShapeInfo <TCell> Default(int width, int height)
        {
            var rawInfow = MakeShapeStorageInfo <FlatRhombPoint>(
                width,
                height,
                x => FlatRhombGrid <TCell> .DefaultContains(x, width, height));

            return(new FlatRhombShapeInfo <TCell>(rawInfow));
        }
Ejemplo n.º 2
0
        /**
         *      Makes an edge grid for this grid.
         */
        public IGrid <TNewCell, FlatRhombPoint> MakeEdgeGrid <TNewCell>()
        {
            var edgeOffset = GridOrigin;

            var edges   = this.SelectMany(x => x.GetEdges());
            var storage = FlatRhombGrid <TNewCell> .CalculateStorage(edges);

            var offset = new FlatHexPoint(-2, 0);

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

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

                break;

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

                break;

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

                break;

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

                break;

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

                break;

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

                break;

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

                break;

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

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Makes an edge grid for this grid.
        /// </summary>
        public IGrid <TNewCell, FlatRhombPoint> MakeEdgeGrid <TNewCell>()
        {
            var edges   = this.SelectMany(x => x.GetEdges());
            var storage = FlatRhombGrid <TNewCell> .CalculateStorage(edges);

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

            var oddPoint = new FlatHexPoint(
                GLMathf.FloorMod(offset.X, 2),
                GLMathf.FloorMod(offset.Y, 2));

            var evenPoint = offset.Subtract(oddPoint);

            return(new FlatRhombGrid <TNewCell>(storage.dimensions.X + 2, storage.dimensions.Y + 2, IsInsideEdgeGrid, evenPoint));
        }
Ejemplo n.º 5
0
        public static bool __CompilerHint__FlatRhomb__MeshTileCell()
        {
            var grid1 = new FlatHexGrid <MeshTileCell[]>(1, 1);

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

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

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

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

            return(grid1[grid1.First()][0] == null || grid2[grid2.First()] == null || shapeInfo.IncIndex(0) != null);
        }
Ejemplo n.º 6
0
 protected override ArrayPoint ArrayPointFromGridPoint(FlatHexPoint point)
 {
     return(FlatRhombGrid <TCell> .ArrayPointFromGridPoint(point));
 }
Ejemplo n.º 7
0
 protected override FlatHexPoint GridPointFromArrayPoint(ArrayPoint point)
 {
     return(FlatRhombGrid <TCell> .GridPointFromArrayPoint(point));
 }
Ejemplo n.º 8
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 FlatRhombShapeInfo<TCell> MyCustomShape(this FlatRhombOp<TCell> op)
  *              {
  *                      return
  *                              BeginGroup()
  *                                      .Shape1()
  *                                      .Union()
  *                                      .Shape2()
  *                              .EndGroup(op);
  *              }
  *
  *      @since 1.1
  */
 public FlatRhombOp <TCell> BeginGroup()
 {
     return(FlatRhombGrid <TCell> .BeginShape());
 }