public static IEnumerable <GridPoint2> GetEdgeFaces(GridPoint2 point) { var color = point.GetColor(2, 2, 2); var faces = new StructList <GridPoint2>(); switch (color) { case 0: //error! break; case 2: faces.Add(point + RectPoint.North); faces.Add(point + RectPoint.South); break; case 1: faces.Add(point + RectPoint.East); faces.Add(point + RectPoint.West); break; /*case 2: * faces.Add(point + RectPoint.NorthEast); * faces.Add(point + RectPoint.NorthWest); * faces.Add(point + RectPoint.SouthEast); * faces.Add(point + RectPoint.SouthWest); * break;*/ } return(faces); }
public static IGrid <GridPoint2, T> Rect <T>(int width, int height) { var dimensions = new GridPoint2(width, height); var grid = ImplicitShape .Parallelogram(dimensions) .ToExplicit(new GridRect(GridPoint2.Zero, dimensions)) .ToGrid <T>(); return(grid); }
public IEnumerator BuildGrid() { totalCellCount = 0; var dimensions = new GridPoint2(width, height); grid = ImplicitShape .Parallelogram(dimensions) .ToExplicit(new GridRect(GridPoint2.Zero, dimensions)) .ToGrid <TileCell>(); map = new GridMap <GridPoint2>( Map.Linear(PointyHexPoint.SpaceMapTransform).PreScale(Vector3.one * 200), Map.HexRound()); int cellCount = 0; foreach (var point in grid.Points) { var cell = Instantiate(cellPrefab); cell.transform.parent = gridRoot.transform; var worldPoint = map.GridToWorld(point); cell.transform.localPosition = worldPoint; cellCount++; totalCellCount++; grid[point] = cell; if (cellCount >= cellsPerIteration) { cellCount = 0; yield return(null); } } }
private void InitCell(GridPoint2 point, SpriteCell cell) { cell.Color = colors[point.GetColor(colorFunction)]; }
public void SnapToGridPosition(GridPoint2 position) { Trans.position = Grid.GridMap.GridToWorld(position); }