private Vector3 WrapPosition( HexMap hexMap, Vector3 position, float hexOuterRadius ) { float innerDiameter = HexagonPoint.InnerDiameterFromOuterRadius(hexOuterRadius); float thresholdWidth = hexMap.HexOffsetColumns * innerDiameter; while (position.x < 0f) { position.x += thresholdWidth; } while (position.x > thresholdWidth) { position.x -= thresholdWidth; } float thresholdHeight = (hexMap.HexOffsetRows) * (1.5f * hexOuterRadius); position.z = Mathf.Clamp(position.z, 0f, thresholdHeight); hexMap.CenterMap(position.x, hexOuterRadius); return(position); }
public void Raise(HexagonPoint point) { if (point == HexagonPoint.Center) { Height++; } Geometry.Raise(1, point); }
private Vector3 ClampPosition( HexMap grid, Vector3 position, float hexOuterRadius ) { // Get inner diameter of a given hex. float innerDiameter = HexagonPoint.OuterToInnerRadius(hexOuterRadius) * 2f; float xMax = (grid.HexOffsetColumns - 0.5f) * innerDiameter; position.x = Mathf.Clamp(position.x, 0f, xMax); float zMax = (grid.HexOffsetRows - 1) * (1.5f * hexOuterRadius); position.z = Mathf.Clamp(position.z, 0f, zMax); return(position); }