예제 #1
0
 public HexGrid(HexagonOrientation orientation, Vector2 size, Vector2 origin, OffsetRaw offset = OffsetRaw.Right)
 {
     HexOrientation = orientation;
     Offset         = offset;
     _orientation   = orientation == HexagonOrientation.Pointy ? Orientation.pointyOrientation : Orientation.flatOrientation;
     m_size         = size;
     m_origin       = origin;
 }
예제 #2
0
    public Hex(float a, HexagonOrientation orientation, HexagonOddity oddity)
    {
        this.a           = a;
        this.orientation = orientation;
        this.oddity      = oddity;

        if (orientation == HexagonOrientation.FlatTopped)
        {
            width  = a * 2f;
            horiz  = width * 3f / 4f;
            height = Mathf.Sqrt(3f) / 2f * width;
            vert   = height;
        }
        else
        {
            height = a * 2f;
            vert   = height * 3f / 4f;
            width  = Mathf.Sqrt(3f) / 2f * height;
            horiz  = height;
        }
    }
예제 #3
0
        /// <summary>
        /// Draws a hexagon with given paramaters
        /// </summary>
        /// <param name="sb"></param>
        /// <param name="centre"></param>
        /// <param name="size"></param>
        /// <param name="thickness"></param>
        /// <param name="c"></param>
        /// <param name="orientation"></param>
        public static void DrawHexagon(SpriteBatch sb, Vector2 centre, int size, int thickness, Color c, HexagonOrientation orientation = HexagonOrientation.Pointy)
        {
            switch (orientation)
            {
            case HexagonOrientation.Pointy:
                DrawCircle(sb, centre, size, 6, thickness, c);
                break;

            case HexagonOrientation.Flat:
                break;
            }
        }