private void GenerateMap(HexMap.Data data) { Vector3 coords = data.Origin; float rowOffset = HexDimensions.InnerRadius + HexDimensions.BridgeWidth; for (int row = 0; row < data.Rows; row++) { for (int col = 0; col < data.Columns; col++) { //AxialCoords hexCoords = new AxialCoords(col-row/2, row); AxialCoords hexCoords = AxialCoords.ConvertToAxialCoords(row, col); HexCell cell = new HexCell(hexCoords, this.GetElevation(coords)); this.MapData.Cells.Add(coords, cell); coords = new Vector3( coords.x + HexDimensions.HorizontalSpacing + HexDimensions.BridgeWidth, coords.y, coords.z ); } coords = new Vector3( //(row + 1) * rowOffset, (row + 1) % 2 == 0 ? data.Origin.x : rowOffset + data.Origin.x, coords.y, coords.z + HexDimensions.VerticalSpacing + HexDimensions.BridgeWidth ); } }
public AxialCoords GetNeighborLocalPosition(Vector3 neighborCoords) { return(this.Coords + AxialCoords.ConvertToAxialCoords(neighborCoords)); }
public Vector3 GetNeighborWorldPosition(Vector3 neighborCoords) { AxialCoords localPosition = this.Coords + AxialCoords.ConvertToAxialCoords(neighborCoords); return(AxialCoords.ConvertToWorldCoords(localPosition + AxialCoords.ConvertToAxialCoords(neighborCoords))); }