private void BuildGrid() { const int width = 7; const int height = 9; grid = FlatHexGrid<SpriteCell>.FatRectangle(width, height); map = new FlatBrickMap(cellPrefab.Dimensions) .AnchorCellMiddleCenter() .WithWindow(ExampleUtils.ScreenRect) .AlignMiddleCenter(grid) .To3DXY() ; foreach (FlatHexPoint point in grid) { SpriteCell cell = Instantiate(cellPrefab); Vector2 worldPoint = map[point]; cell.transform.parent = root.transform; cell.transform.localScale = Vector3.one; cell.transform.localPosition = worldPoint; cell.Color = ExampleUtils.Colors[point.GetColor3_7()]; cell.name = point.ToString(); grid[point] = cell; } }
public void BuildGrid() { var spacing = battleCellPrefab.Dimensions; spacing.Scale(padding); Grid = FlatHexGrid <SectorCell> .Hexagon(size); Map = new FlatHexMap(spacing).AnchorCellMiddleCenter().To3DXZ(); // Battle.Manager.state.allCells = new List<BattleCellState> (); // Battle.Manager.state.occupiedCells = new List<BattleCellState> (); foreach (var point in Grid) { var cell = Instantiate(battleCellPrefab); // cell.state.coordinates.x = point.X; // cell.state.coordinates.y = point.Y; Vector3 worldPoint = Map [point]; cell.transform.parent = this.transform; cell.transform.localScale = Vector3.one; cell.transform.localPosition = worldPoint; cell.name = point.ToString(); Grid [point] = cell; // Battle.Manager.state.allCells.Add (cell.state); } positionCollider(); createSpawnpoints(); }
private void BuildGrid() { root.transform.DestroyChildren(); grid = FlatHexGrid <SpriteCell> .Hexagon(4); map = new FlatHexMap(HexDimensions) .AnchorCellMiddleCenter() .WithWindow(ExampleUtils.ScreenRect) .AlignMiddleCenter(grid) .To3DXY() ; foreach (FlatHexPoint point in grid) { SpriteCell cell = Instantiate(cellPrefab); Vector3 worldPoint = map[point]; cell.transform.parent = root.transform; cell.transform.localScale = Vector3.one; cell.transform.localPosition = worldPoint; cell.Color = ExampleUtils.Colors[point.GetColor3_7()]; cell.name = point.ToString(); grid[point] = cell; } }
private void BuildGrid() { const int width = 6; const int height = 3; const float border = 0; const int quadCount = 15; grid = FlatHexGrid <MeshTileCell> .HorizontallyWrappedRectangle(width, height); map = new PolarFlatBrickMap(Vector2.zero, 50, 300, new VectorPoint(width, height)); foreach (var point in grid) { var cell = Instantiate(cellPrefab); cell.transform.parent = gridRoot.transform; Mesh mesh = cell.GetComponent <MeshFilter>().mesh; float innerRadius = map.GetInnerRadius(point) + border / 2; float outerRadius = map.GetOuterRadius(point) - border / 2; float startAngle = map.GetStartAngleZ(point); float endAngle = map.GetEndAngleZ(point) - border * Mathf.Rad2Deg / outerRadius; MeshUtils.MakeBandedSector(mesh, startAngle, endAngle, innerRadius, outerRadius, quadCount, v => v); cell.Color = ExampleUtils.Colors[point.GetColor1_3()]; cell.HighlightOn = false; cell.__CenterOffset = map[point].XYTo3D(); grid[point] = cell; } }
private void BuildGrid() { const int width = 7; const int height = 9; grid = FlatHexGrid <SpriteCell> .FatRectangle(width, height); map = new FlatBrickMap(cellPrefab.Dimensions) .AnchorCellMiddleCenter() .WithWindow(ExampleUtils.ScreenRect) .AlignMiddleCenter(grid) .To3DXY() ; foreach (FlatHexPoint point in grid) { SpriteCell cell = Instantiate(cellPrefab); Vector2 worldPoint = map[point]; cell.transform.parent = root.transform; cell.transform.localScale = Vector3.one; cell.transform.localPosition = worldPoint; cell.Color = ExampleUtils.Colors[point.GetColor3_7()]; cell.name = point.ToString(); grid[point] = cell; } }
private void BuildGrid() { grid = (FlatHexGrid <CellScript>) FlatHexGrid <CellScript> .FatRectangle((int)gridSize.x, (int)gridSize.y); map = new FlatHexMap(CellDimensions) .AnchorCellTopLeft() .WithWindow(ExampleUtils.ScreenRect) .AlignMiddleCenter(grid) .To3DXY(); gridCount = grid.Count(); foreach (FlatHexPoint point in grid) { if (Random.value < 0.5f) { SpawnCell(healthyCellPrefab, point); } } FlatHexPoint cancerSpawnPoint = grid.ToArray <FlatHexPoint> ()[(int)Random.Range(0, grid.ToArray <FlatHexPoint>().Count())]; if (grid[cancerSpawnPoint] != null) { Destroy(grid[cancerSpawnPoint].gameObject); } SpawnCell(cancerCellPrefab, cancerSpawnPoint); }
private void BuildGrid() { root.transform.DestroyChildren(); grid = FlatHexGrid<SpriteCell>.Hexagon(4); map = new FlatHexMap(HexDimensions) .AnchorCellMiddleCenter() .WithWindow(ExampleUtils.ScreenRect) .AlignMiddleCenter(grid) .To3DXY() ; foreach(FlatHexPoint point in grid) { SpriteCell cell = Instantiate(cellPrefab); Vector3 worldPoint = map[point]; cell.transform.parent = root.transform; cell.transform.localScale = Vector3.one; cell.transform.localPosition = worldPoint; cell.Color = ExampleUtils.Colors[point.GetColor3_7()]; cell.name = point.ToString(); grid[point] = cell; } }
public static bool __CompilerHint__FlatHex__TileCell() { var grid = new FlatHexGrid<TileCell[]>(1, 1); foreach(var point in grid) { grid[point] = new TileCell[1]; } var shapeStorageInfo = new ShapeStorageInfo<FlatHexPoint>(new IntRect(), p => true); var shapeInfo = new FlatHexShapeInfo<TileCell>(shapeStorageInfo); return grid[grid.First()][0] == null || shapeInfo.Translate(FlatHexPoint.Zero) != null; }
/** Call this method if you use a FlatHexGrid. Replace the type __CellType to whatever type you have in your grid. You can call the method anywhere in your code. if(!__CompilerHint__FlatHex()) return; This methods always returns true. @since 1.6 */ public static bool __CompilerHint1__FlatHex() { //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<FlatHexPoint>(new IntRect(), p => true); var shapeInfo = new FlatHexShapeInfo<__CellType>(shapeStorageInfo); return grid[grid.First()][0] == null || shapeInfo.Translate(FlatHexPoint.Zero) != 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 virtual void Assemble() { // allow selection of player characters and ship // build the space map GameObject cellPrefab = Resources.Load <GameObject>("SpaceCell"); grid = FlatHexGrid <GameObject> .WrappedHexagon(15); map = new FlatHexMap(cellPrefab.GetComponent <SpriteCell>().Dimensions) .WithWindow(new Rect(0, 0, 0, 0)) .AlignMiddleCenter(grid) .To3DXY(); grid.Fill(MakeCell); // add and configure camera? }
public void BuilkdGrid() { var spacing = cellPrefab.Dimensions; spacing.Scale(padding); Grid = FlatHexGrid <Cell> .Hexagon(size); Map = new FlatHexMap(spacing).AnchorCellMiddleCenter().To3DXZ(); foreach (var point in Grid) { var cell = Instantiate(cellPrefab); Vector3 worldPoint = Map [point]; cell.transform.parent = this.transform; cell.transform.localScale = Vector3.one; cell.transform.localPosition = worldPoint; cell.name = point.ToString(); Grid [point] = cell; } }
public FlatRhombShapeInfo <TCell> Parallelogram(int width, int height) { return(ShapeFromBase(FlatHexGrid <TCell> .BeginShape().Parallelogram(width, height))); }
public static bool __CompilerHint__FlatRhomb__SpriteCell() { var grid1 = new FlatHexGrid<SpriteCell[]>(1, 1); foreach(var point in grid1) { grid1[point] = new SpriteCell[1]; } var grid2 = new FlatRhombGrid<SpriteCell>(1, 1); foreach(var point in grid2) { grid2[point] = null; } var shapeStorageInfo = new ShapeStorageInfo<FlatRhombPoint>(new IntRect(), p => true); var shapeInfo = new FlatRhombShapeInfo<SpriteCell>(shapeStorageInfo); return grid1[grid1.First()][0] == null || grid2[grid2.First()] == null || shapeInfo.IncIndex(0) != null; }
public static bool __CompilerHint__PointyTri__TileCell() { var grid1 = new FlatHexGrid<TileCell[]>(1, 1); foreach(var point in grid1) { grid1[point] = new TileCell[1]; } var grid2 = new PointyTriGrid<TileCell>(1, 1); foreach(var point in grid2) { grid2[point] = null; } var shapeStorageInfo = new ShapeStorageInfo<PointyTriPoint>(new IntRect(), p => true); var shapeInfo = new PointyTriShapeInfo<TileCell>(shapeStorageInfo); return grid1[grid1.First()][0] == null || grid2[grid2.First()] == null || shapeInfo.IncIndex(0) != null; }
public FlatRhombShapeInfo <TCell> Hexagon(int side) { return(ShapeFromBase(FlatHexGrid <TCell> .BeginShape().Hexagon(side))); }
public static bool __CompilerHint2__FlatHex() { //Ensures abstract super classes for base grids gets created var grid = new FlatHexGrid<__CellType>(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<__CellType>(shapeStorageInfo); return grid[grid.First()] == null || shapeInfo.Translate(FlatHexPoint.Zero) != null; }
public FlatRhombShapeInfo <TCell> ThinRectangle(int width, int height) { return(ShapeFromBase(FlatHexGrid <TCell> .BeginShape().ThinRectangle(width, height))); }
public PointyTriShapeInfo <TCell> FatRectangle(int width, int height) { return(ShapeFromBase(FlatHexGrid <TCell> .BeginShape().FatRectangle(width, height))); }