Example #1
0
        protected override void InitGrid()
        {
            VectorPoint rectDimensions = Dimensions;

            switch (shape)
            {
            case Shape.Rectangle:
                base.Grid = PointyHexGrid <TileCell> .Rectangle(rectDimensions.X, rectDimensions.Y);

                break;

            case Shape.Parallelogram:
                base.Grid = PointyHexGrid <TileCell> .Parallelogram(rectDimensions.X, rectDimensions.Y);

                break;

            case Shape.FatRectangle:
                base.Grid = PointyHexGrid <TileCell> .FatRectangle(rectDimensions.X, rectDimensions.Y);

                break;

            case Shape.ThinRectangle:
                base.Grid = PointyHexGrid <TileCell> .ThinRectangle(rectDimensions.X, rectDimensions.Y);

                break;

            case Shape.Hexagon:
                base.Grid = PointyHexGrid <TileCell> .Hexagon(Size);

                break;

            case Shape.UpTriangle:
                base.Grid = PointyHexGrid <TileCell> .UpTriangle(Size);

                break;

            case Shape.DownTriangle:
                base.Grid = PointyHexGrid <TileCell> .DownTriangle(Size);

                break;

            case Shape.Diamond:
                base.Grid = PointyHexGrid <TileCell> .Diamond(Size);

                break;

            case Shape.Single:
                base.Grid = PointyHexGrid <TileCell> .Single();

                break;

            case Shape.Custom:
                base.Grid = GetCustomGrid();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Example #2
0
        public PointyHexHexagonWrapper(int n)
        {
            int colorCount = 3 * n * n - 3 * n + 1;
            int x1         = 3 * n - 2;

            wrappedPoints = new PointyHexPoint[colorCount];
            var grid = PointyHexGrid <int> .Hexagon(n);

            colorFunc = x => x.GetColor(colorCount, x1, 1);

            foreach (var point in grid)
            {
                int color = colorFunc(point);
                wrappedPoints[color] = point;
            }
        }