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

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

                break;

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

                break;

            case Shape.UpTriangle:
                base.Grid = FlatTriGrid <TileCell> .UpTriangle(size);

                break;

            case Shape.DownTriangle:
                base.Grid = FlatTriGrid <TileCell> .DownTriangle(size);

                break;

            case Shape.Hexagon:
                base.Grid = FlatTriGrid <TileCell> .Hexagon(size);

                break;

            case Shape.Star:
                base.Grid = FlatTriGrid <TileCell> .Star(size);

                break;

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

                break;

            case Shape.SingleGroup:
                base.Grid = FlatTriGrid <TileCell> .SingleGroup();

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #2
0
        /**
         *      @param n Must be positive
         */
        public FlatTriHexagonWrapper(int side)
        {
            if (side <= 0)
            {
                throw new Exception("n Must be a positive integer.");
            }

            int colorCount = 3 * side * side;

            colorFunc = x => x.GetColor(colorCount / side, side, side);

            wrappedPoints = new FlatTriPoint[colorCount * 2];
            var grid = FlatTriGrid <int> .Hexagon(side);

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