예제 #1
0
    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

                );
        }
    }
예제 #2
0
 public AxialCoords GetNeighborLocalPosition(Vector3 neighborCoords)
 {
     return(this.Coords + AxialCoords.ConvertToAxialCoords(neighborCoords));
 }
예제 #3
0
    public Vector3 GetNeighborWorldPosition(Vector3 neighborCoords)
    {
        AxialCoords localPosition = this.Coords + AxialCoords.ConvertToAxialCoords(neighborCoords);

        return(AxialCoords.ConvertToWorldCoords(localPosition + AxialCoords.ConvertToAxialCoords(neighborCoords)));
    }