Ejemplo n.º 1
0
    public static void OffsetToCube(ref OffsetCoordinate o, HexCellOrientation orientation, out HexCubeCoordinate c)
    {
        switch (orientation)
        {
        case HexCellOrientation.PointyOdd:
            PointyOddToCube(ref o, out c);
            break;

        case HexCellOrientation.PointyEven:
            PointyEvenToCube(ref o, out c);
            break;

        case HexCellOrientation.FlatOdd:
            FlatOddToCube(ref o, out c);
            break;

        case HexCellOrientation.FlatEven:
            FlatEvenToCube(ref o, out c);
            break;

        default:
            PointyOddToCube(ref o, out c);
            break;
        }
    }
Ejemplo n.º 2
0
    public static void CubeToOffset(ref HexCubeCoordinate c, HexCellOrientation orientation, out OffsetCoordinate o)
    {
        switch (orientation)
        {
        case HexCellOrientation.PointyOdd:
            CubeToPointyOdd(ref c, out o);
            break;

        case HexCellOrientation.PointyEven:
            CubeToPointyEven(ref c, out o);
            break;

        case HexCellOrientation.FlatOdd:
            CubeToFlatOdd(ref c, out o);
            break;

        case HexCellOrientation.FlatEven:
            CubeToFlatEven(ref c, out o);
            break;

        default:
            CubeToPointyOdd(ref c, out o);
            break;
        }
    }
Ejemplo n.º 3
0
    public static Vector3 Corner(Vector3 origin, float radius, int corner, HexCellOrientation cellOrientation, HexGridOrientation gridOrientation)
    {
        float angle = 60 * corner;

        if (cellOrientation == HexCellOrientation.PointyOdd)
        {
            angle += 30;
        }
        angle *= Mathf.PI / 180;

        var cornerPos = new Vector3(origin.x + radius * Mathf.Cos(angle), 0.0f, origin.z + radius * Mathf.Sin(angle));

        if (gridOrientation != HexGridOrientation.Vertical)
        {
            return(cornerPos);
        }

        cornerPos.y = origin.y + radius * Mathf.Sin(angle);
        cornerPos.z = 0;

        return(cornerPos);
    }
Ejemplo n.º 4
0
 public void GetCubeCoordinates(HexCellOrientation orientation, out HexCubeCoordinate c)
 {
     OffsetToCube(ref this, orientation, out c);
 }
Ejemplo n.º 5
0
 public void GetOffsetCoordinates(HexCellOrientation orientation, out OffsetCoordinate o)
 {
     CubeToOffset(ref this, orientation, out o);
 }