protected override void InitGrid() { VectorPoint rectDimensions = Dimensions; switch (shape) { case Shape.Rectangle: base.Grid = FlatHexGrid <TileCell> .Rectangle(rectDimensions.X, rectDimensions.Y); break; case Shape.Parallelogram: base.Grid = FlatHexGrid <TileCell> .Parallelogram(rectDimensions.X, rectDimensions.Y); break; case Shape.FatRectangle: base.Grid = FlatHexGrid <TileCell> .FatRectangle(rectDimensions.X, rectDimensions.Y); break; case Shape.ThinRectangle: base.Grid = FlatHexGrid <TileCell> .ThinRectangle(rectDimensions.X, rectDimensions.Y); break; case Shape.Hexagon: base.Grid = FlatHexGrid <TileCell> .Hexagon(Size); break; case Shape.LeftTriangle: base.Grid = FlatHexGrid <TileCell> .LeftTriangle(Size); break; case Shape.RightTriangle: base.Grid = FlatHexGrid <TileCell> .RightTriangle(Size); break; case Shape.Diamond: base.Grid = FlatHexGrid <TileCell> .Diamond(Size); break; case Shape.Single: base.Grid = FlatHexGrid <TileCell> .Single(); break; case Shape.Custom: var shapeBuilder = GetComponent <CustomGridBuilder>(); base.Grid = shapeBuilder.MakeGrid <TileCell, FlatHexPoint>(); break; default: throw new ArgumentOutOfRangeException(); } }
protected override void InitGrid() { VectorPoint rectDimensions = Dimensions; switch (shape) { case Shape.Rectangle: Grid = FlatHexGrid <MeshCell> .Rectangle(rectDimensions.X, rectDimensions.Y); break; case Shape.Parallelogram: Grid = FlatHexGrid <MeshCell> .Parallelogram(rectDimensions.X, rectDimensions.Y); break; case Shape.FatRectangle: Grid = FlatHexGrid <MeshCell> .FatRectangle(rectDimensions.X, rectDimensions.Y); break; case Shape.ThinRectangle: Grid = FlatHexGrid <MeshCell> .ThinRectangle(rectDimensions.X, rectDimensions.Y); break; case Shape.Hexagon: Grid = FlatHexGrid <MeshCell> .Hexagon(Size); break; case Shape.LeftTriangle: Grid = FlatHexGrid <MeshCell> .LeftTriangle(Size); break; case Shape.RightTriangle: Grid = FlatHexGrid <MeshCell> .RightTriangle(Size); break; case Shape.Diamond: Grid = FlatHexGrid <MeshCell> .Diamond(Size); break; case Shape.Single: Grid = FlatHexGrid <MeshCell> .Single(); break; case Shape.Custom: Grid = GetCustomGrid(); break; default: throw new ArgumentOutOfRangeException(); } }
public IGrid <TNewCell, FlatHexPoint> MakeVertexGrid <TNewCell>() { var vertices = this.SelectMany(x => x.GetVertices()); var storage = FlatHexGrid <TNewCell> .CalculateStorage(vertices); var offset = FlatHexGrid <TNewCell> .GridPointFromArrayPoint(storage.offset); return(new FlatHexGrid <TNewCell>(storage.dimensions.X, storage.dimensions.Y, x => IsInsideVertexGrid(x + offset), offset)); }
public FlatHexShapeInfo <TCell> Default(int width, int height) { var rawInfow = MakeShapeStorageInfo <FlatHexPoint>( width, height, x => FlatHexGrid <TCell> .DefaultContains(x, width, height)); return(new FlatHexShapeInfo <TCell>(rawInfow)); }
public static bool __CompilerHint2__FlatHex__MeshTileCell() { //Ensures abstract super classes for base grids gets created var grid = new FlatHexGrid <MeshTileCell>(1, 1, p => p == FlatHexPoint.Zero, x => x, x => x, new List <FlatHexPoint>()); //Ensures shape infpo classes get created var shapeStorageInfo = new ShapeStorageInfo <FlatHexPoint>(new IntRect(), p => true); var shapeInfo = new FlatHexShapeInfo <MeshTileCell>(shapeStorageInfo); return(grid[grid.First()] == null || shapeInfo.Translate(FlatHexPoint.Zero) != null); }
public static bool __CompilerHint__FlatHex__MeshTileCell() { var grid = new FlatHexGrid <MeshTileCell[]>(1, 1); foreach (var point in grid) { grid[point] = new MeshTileCell[1]; } var shapeStorageInfo = new ShapeStorageInfo <FlatHexPoint>(new IntRect(), p => true); var shapeInfo = new FlatHexShapeInfo <MeshTileCell>(shapeStorageInfo); return(grid[grid.First()][0] == null || shapeInfo.Translate(FlatHexPoint.Zero) != null); }
public FlatHexHexagonWrapper(int n) { int colorCount = 3 * n * n - 3 * n + 1; int x1 = 3 * n - 2; wrappedPoints = new FlatHexPoint[colorCount]; var grid = FlatHexGrid <int> .Hexagon(n); colorFunc = x => x.GetColor(colorCount, x1, 1); foreach (var point in grid) { int color = colorFunc(point); wrappedPoints[color] = point; } }
/** * Call this method if you use a FlatRhombGrid. * Replace the type __CellType to whatever type you have in your grid. * * You can call the method anywhere in your code. * * if(!__CompilerHint__FlatRhomb()) return; * * This methods always returns true. * * @since 1.6 */ public static bool __CompilerHint__FlatRhomb() { //Ensures abstract super classes for base grids gets created var grid = new FlatHexGrid <__CellType[]>(1, 1); foreach (var point in grid) { grid[point] = new __CellType[1]; } //Ensures shape infpo classes get created var shapeStorageInfo = new ShapeStorageInfo <FlatRhombPoint>(new IntRect(), p => true); var shapeInfo = new FlatRhombShapeInfo <__CellType>(shapeStorageInfo); return(grid[grid.First()][0] == null || shapeInfo.IncIndex(0) != null); }
/** * 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(); }
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); }
public static bool __CompilerHint__PointyTri__TextureCell() { var grid1 = new FlatHexGrid <TextureCell[]>(1, 1); foreach (var point in grid1) { grid1[point] = new TextureCell[1]; } var grid2 = new PointyTriGrid <TextureCell>(1, 1); foreach (var point in grid2) { grid2[point] = null; } var shapeStorageInfo = new ShapeStorageInfo <PointyTriPoint>(new IntRect(), p => true); var shapeInfo = new PointyTriShapeInfo <TextureCell>(shapeStorageInfo); return(grid1[grid1.First()][0] == null || grid2[grid2.First()] == null || shapeInfo.IncIndex(0) != null); }
protected override void InitGrid() { int width = Dimensions.X; int height = Dimensions.Y; switch (shape) { case Shape.Parallelogram: base.Grid = FlatHexGrid <MeshTileCell> .HorizontallyWrappedParallelogram(width, height); break; case Shape.Rectangle: base.Grid = FlatHexGrid <MeshTileCell> .HorizontallyWrappedRectangle(width, height); break; default: throw new ArgumentOutOfRangeException(); } }
/** * 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 FlatHexShapeInfo<TCell> MyCustomShape(this FlatHexOp<TCell> op) * { * return * BeginGroup() * .Shape1() * .Union() * .Shape2() * .EndGroup(op); * } * * @since 1.1 */ public FlatHexOp <TCell> BeginGroup() { return(FlatHexGrid <TCell> .BeginShape()); }
protected override ArrayPoint ArrayPointFromGridPoint(FlatHexPoint point) { return(FlatHexGrid <TCell> .ArrayPointFromGridPoint(point)); }
protected override FlatHexPoint GridPointFromArrayPoint(ArrayPoint point) { return(FlatHexGrid <TCell> .GridPointFromArrayPoint(point)); }
public static ArrayPoint ArrayPointFromGridPoint(FlatHexPoint point) { return(FlatHexGrid <TCell> .ArrayPointFromGridPoint(point)); }
public static FlatHexPoint GridPointFromArrayPoint(ArrayPoint point) { return(FlatHexGrid <TCell> .GridPointFromArrayPoint(point)); }
public PointyTriShapeInfo<TCell> ThinRectangle(int width, int height) { return ShapeFromBase(FlatHexGrid<TCell>.BeginShape().ThinRectangle(width, height)); }