private HexDirection GetNearestEdgeOfCellFromPoint(IHexCell cell, Vector3 mouseRayHit) { var directions = EnumUtil.GetValues <HexDirection>().ToList(); directions.Sort(delegate(HexDirection directionOne, HexDirection directionTwo) { var edgeOneMiddle = cell.AbsolutePosition + RenderConfig.GetEdgeMidpoint(directionOne); var edgeTwoMiddle = cell.AbsolutePosition + RenderConfig.GetEdgeMidpoint(directionTwo); return(Vector3.Distance(mouseRayHit, edgeOneMiddle) .CompareTo(Vector3.Distance(mouseRayHit, edgeTwoMiddle))); }); return(directions.First()); }
private BezierSpline BuildSplineBetween(IHexCell cell, HexDirection directionOne, HexDirection directionTwo) { Vector3 controlOne = cell.AbsolutePosition + ( RenderConfig.GetEdgeMidpoint(directionOne) + RenderConfig.GetFirstCorner(directionOne.Previous()) ) / 3f; Vector3 controlTwo = cell.AbsolutePosition + ( RenderConfig.GetEdgeMidpoint(directionTwo) + RenderConfig.GetFirstCorner(directionTwo.Previous()) ) / 3f; var spline = new BezierSpline(cell.AbsolutePosition + RenderConfig.GetEdgeMidpoint(directionOne)); spline.AddCubicCurve(controlOne, controlTwo, cell.AbsolutePosition + RenderConfig.GetEdgeMidpoint(directionTwo)); return(spline); }