/// <summary> /// returns the periodic corner coordinate of the input cartesian coordinate /// </summary> public Vector3Int FromCartesianCoordinate(Vector3 cartesianCoordinate) { if (coordinateWrapper != null) { cartesianCoordinate = coordinateWrapper.WrapCartesianCoordinate(cartesianCoordinate); } Vector3Int coord = HexConverter.CartesianCoordToClosestCornerCoord(cartesianCoordinate); return(coord); }
/// <summary> /// returns the periodic corner coordinate of the input cartesian coordinate, the out parameter specifies if that coordinate belongs to the map /// </summary> public Vector3Int FromCartesianCoordinate(Vector3 cartesianCoordinate, out bool cornerIsOnMap) { if (coordinateWrapper != null) { cartesianCoordinate = coordinateWrapper.WrapCartesianCoordinate(cartesianCoordinate); } Vector3Int coord = HexConverter.CartesianCoordToClosestCornerCoord(cartesianCoordinate); cornerIsOnMap = false; if (cornerIndexByPosition.ContainsKey(coord)) { cornerIsOnMap = true; } return(coord); }
/// <summary> /// updates all the mouse position data /// </summary> private void UpdatePlayerPositionData() { CursorIsOnMap = false; CartesianCoordInfiniteGrid = transform.position; CartesianCoordWrapped = transform.position; CubeCoordRaw = HexConverter.CartesianCoordToTileCoord(CartesianCoordInfiniteGrid); TileCoord = CubeCoordRaw; OffsetCoordInfiniteGrid = HexConverter.CartesianCoordToOffsetCoord(CartesianCoordInfiniteGrid); OffsetCoord = OffsetCoordInfiniteGrid; ClosestEdgeCoordInfiniteGrid = HexConverter.CartesianCoordToClosestEdgeCoord(CartesianCoordInfiniteGrid); ClosestEdgeCoord = ClosestEdgeCoordInfiniteGrid; ClosestCornerCoordInfiniteGrid = HexConverter.CartesianCoordToClosestCornerCoord(CartesianCoordInfiniteGrid); ClosestCornerCoord = ClosestCornerCoordInfiniteGrid; //SelectionRay = Camera.main.ScreenPointToRay(Input.mousePosition); if (hexMap != null) { if (hexMap.CoordinateWrapper != null) { CartesianCoordWrapped = hexMap.CoordinateWrapper.WrapCartesianCoordinate(CartesianCoordInfiniteGrid); } CursorIsOnMap = hexMap.GetTilePosition.IsInputCoordinateOnMap(CartesianCoordWrapped); TileCoord = HexConverter.CartesianCoordToTileCoord(CartesianCoordWrapped); OffsetCoord = HexConverter.TileCoordToOffsetTileCoord(TileCoord); ClosestEdgeCoord = HexConverter.CartesianCoordToClosestEdgeCoord(CartesianCoordWrapped); ClosestCornerCoord = HexConverter.CartesianCoordToClosestCornerCoord(CartesianCoordWrapped); } }
/// <summary> /// returns the corner coordinate closest to the input cartesian coordinate /// </summary> public static Vector3Int ClosestToCartesianCoordinate(Vector3 cartesianCoordinate) { return(HexConverter.CartesianCoordToClosestCornerCoord(cartesianCoordinate)); }