protected override IMap <Vector3, Vector3> Transform(IMap <Vector3, Vector3> input) { var matrix = Matrixf33.Scale(scaleFactor); var map = Map.Linear(matrix); return((input == null) ? map : input.ComposeWith(map)); }
private GridMap <GridPoint2> CreateMap(IExplicitShape <GridPoint2> grid) { var cellDimensions = cellPrefab.Sprite.rect.size; var scale = new Vector3(1, .85f, 1); //VectorExtensions.To3DXY(cellDimensions, 1); var spaceMap = Map .Translate(new Vector3(0, 3.2f, 0)) .ComposeWith(Map.Linear(Matrixf33.Scale(scale))) .ComposeWith(Map.Polar(cellDimensions.y, 1.0f / gridDimensions.x)); var roundMap = Map.RectRound(); var parallelogramMap = Map.ParallelogramWrapX(gridDimensions.x); var composeMap = parallelogramMap.ComposeWith(roundMap); var spaceAlignMap = spaceMap.AlignGridInRect(grid, p => scale, new Bounds(ScreenRect.center, ScreenRect.size), horizontalAlignment, verticalAlignment); var spaceAlignAnchorMap = spaceAlignMap.AnchorPivotInRect(grid, p => scale, horizontalAnchorPivot, verticalAnchorPivot); var gridMap = new GridMap <GridPoint2>(spaceAlignAnchorMap, composeMap); return(gridMap); }
public Vector3 rotation = Vector3.zero; //Degrees protected override IMap <Vector3, Vector3> Transform(IMap <Vector3, Vector3> input) { var matrix = Matrixf33.RotateXYZ(rotation * Mathf.Deg2Rad); var map = Map.Linear(matrix); return((input == null) ? map : input.ComposeWith(map)); }
private GridMap <GridPoint2> CreateMap(IExplicitShape <GridPoint2> grid) { var cellDimensions = cellPrefab.Sprite.rect.size; //static invocation is used here because the Unity compiler //gets confused otherwise. var scale = cellDimensions.To3DXY(1); var scaleSpaceMap = Map.Linear(Matrixf33.Scale(scale)); var spaceMap = Map.Linear(PointyHexPoint.SpaceMapTransform.Mul(Matrixf33.RotateZ(-30 * Mathf.Deg2Rad))); spaceMap = spaceMap.ComposeWith(scaleSpaceMap); var roundMap = Map.HexRound(); var spaceAlignMap = spaceMap.AlignGridInRect( grid, p => scale, p => p.ToVector2().To3DXY(), new Bounds(ScreenRect.center, ScreenRect.size), horizontalAlignment, verticalAlignment); var spaceAlignAnchorMap = spaceAlignMap.AnchorPivotInRect(grid, p => scale, horizontalAnchorPivot, verticalAnchorPivot); var gridMap = new GridMap <GridPoint2>(spaceAlignAnchorMap, roundMap); return(gridMap); }
private IMap <Vector3, GridPoint2> CreateMap() { var cellDimensions = cellPrefab.SharedMesh.bounds.size; var spaceMap = Map.Linear(Matrixf33.Scale(cellDimensions)); var roundMap = Map.RectRound(); return(spaceMap.ComposeWith(roundMap)); }
protected override IMap <Vector3, Vector3> Transform(IMap <Vector3, Vector3> input) { var linearMap = Map.Linear( Matrixf33 .RotateZ(45 * Mathf.Deg2Rad) .Mul(Matrixf33.Scale(new Vector3(PointyHexPoint.Sqrt3, 1, 1)))); return((input == null) ? linearMap : input.ComposeWith(linearMap)); }
private GridMap <GridPoint3> CreateMap() { var cellDimensions = cellPrefab.SharedMesh.bounds.size; var spaceMap = Map.Linear(Matrixf33.Scale(cellDimensions)); var roundMap = Map.BlockRound(); var gridMap = new GridMap <GridPoint3>(spaceMap, roundMap); return(gridMap); }
private GridMap <int> CreateMap() { var cellDimensions = cellPrefab.Sprite.rect.size; var scale = VectorExtensions.To3DXY(cellDimensions, 1); var spaceMap = Map .Translate(new Vector3(0, 1, 0)) .ComposeWith(Map.Polar(3, 1.0f / gridSize)) .ComposeWith(Map.Linear(Matrixf33.Scale(scale))); var roundMap = Map.PointRound(); var gridMap = new GridMap <int>(spaceMap, roundMap); return(gridMap); }
private GridMap <GridPoint2> CreateMap(IExplicitShape <GridPoint2> grid) { var cellDimensions = cellPrefab.Sprite.rect.size; var scale = cellDimensions.To3DXY(1); var spaceMap = Map.Linear(PointyHexPoint.RawSpaceMapTransform * Matrixf33.Scale(scale * 0.992f)); var roundMap = Map.HexRound(); var spaceAlignMap = spaceMap.AlignGridInRect(grid, p => scale, new Bounds(ScreenRect.center, ScreenRect.size), horizontalAlignment, verticalAlignment); var spaceAlignAnchorMap = spaceAlignMap.AnchorPivotInRect(grid, p => scale, horizontalAnchorPivot, verticalAnchorPivot); var gridMap = new GridMap <GridPoint2>(spaceAlignAnchorMap, roundMap); return(gridMap); }
/// <summary> /// Creates a Mesh grid using the mesh data provided for each cell. /// </summary> /// <param name="mesh">Mesh to use to place the generated mesh grid.</param> /// <param name="width">Width of the grid.</param> /// <param name="height">Height of the grid.</param> /// <param name="prefab">Prefab to use for the cells on the grid.</param> /// <param name="meshData">The mesh data information to use for the cells.</param> /// <param name="cellDimensions">The cell's dimensions.</param> public static IGrid <GridPoint2, T> RectXY <T>( Mesh mesh, int width, int height, MeshData meshData, Vector2 cellDimensions) { var spaceMap = Map.Linear(Matrixf33.Scale(cellDimensions.To3DXY(1))); var center = new Vector2(width, height) / 2 - Vector2.one * 0.5f; spaceMap = spaceMap.PreTranslate(-center); var roundMap = Map.RectRound(); var map = new GridMap <GridPoint2>(spaceMap, roundMap); var grid = Rect <T>(width, height); GridBuilderUtils.InitMesh(mesh, grid, map, meshData, false, true); return(grid); }
private GridMap <GridPoint2> CreateMap(IExplicitShape <GridPoint2> grid) { var cellDimensions = cellPrefab.Sprite.rect.size; //static invocation is used here because the Unity compiler //gets confused otherwise. var scale = cellDimensions.To3DXY(1); var spaceMap = Map.Linear(Matrixf33.Scale(scale)); var roundMap = Map.RectRound(); var spaceAlignMap = spaceMap.AlignGridInRect(grid, p => scale, new Bounds(ScreenRect.center, ScreenRect.size), horizontalAlignment, verticalAlignment); var spaceAlignAnchorMap = spaceAlignMap.AnchorPivotInRect(grid, p => scale, horizontalAnchorPivot, verticalAnchorPivot); var gridMap = new GridMap <GridPoint2>(spaceAlignAnchorMap, roundMap); return(gridMap); }
/// <summary> /// Creates a Pysical Grid. /// </summary> /// <param name="root">GameObject where all the cells are going to be stored.</param> /// <param name="width">Width of the grid.</param> /// <param name="height">Height of the grid.</param> /// <param name="prefab">Prefab to use for the cells on the grid.</param> /// <param name="cellDimensions">The cell's dimensions.</param> public static PhysicalGrid <GridPoint2, T> RectXY <T>( GameObject root, int width, int height, T prefab, Vector2 cellDimensions) where T : Component { var spaceMap = Map.Linear(Matrixf33.Scale(cellDimensions.To3DXY(1))); var center = new Vector2(width, height) / 2 - Vector2.one * 0.5f; spaceMap = spaceMap.PreTranslate(-center); var grid = Rect <T>(width, height); var roundMap = Map.RectRound(); var map = new GridMap <GridPoint2>(spaceMap, roundMap); GridBuilderUtils.InitTileGrid(grid, map, prefab, root, (point, cell) => { }); //root.AddComponent<PhysicalGrid<GridPoint2, T>>(); return(new PhysicalGrid <GridPoint2, T>(grid, map, root)); }
protected override IMap <Vector3, Vector3> Transform(IMap <Vector3, Vector3> input) { var linearMap = Map.Linear(Matrixf33.RotateZ(45 * Mathf.Deg2Rad)); return((input == null) ? linearMap : input.ComposeWith(linearMap)); }
protected override IMap <Vector3, Vector3> Transform(IMap <Vector3, Vector3> input) { var linearMap = Map.Linear(PointyHexPoint.SpaceMapTransform.Mul(Matrixf33.RotateZ(-30 * Mathf.Deg2Rad))); return((input == null) ? linearMap : input.ComposeWith(linearMap)); }