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); }
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)); }
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)); }