Example #1
0
        /// <summary>
        /// Declares that the tiles in dest can be placed adjacent to the tiles in src, in the direction specified by (x, y, z).
        /// Then it adds similar declarations for other rotations and reflections, as specified by rotations.
        /// </summary>
        public void AddAdjacency(IList <Tile> src, IList <Tile> dest, int x, int y, int z, TileRotation tileRotation = null)
        {
            RequireDirections();

            tileRotation = tileRotation ?? new TileRotation();

            foreach (var rotation in tileRotation.RotationGroup)
            {
                var(x2, y2) = TopoArrayUtils.RotateVector(directions.Type, x, y, rotation);

                AddAdjacency(
                    tileRotation.Rotate(src, rotation).ToList(),
                    tileRotation.Rotate(dest, rotation).ToList(),
                    x2, y2, z);
            }
        }
Example #2
0
        /// <summary>
        /// Declares that the tiles in dest can be placed adjacent to the tiles in src, in the direction specified by (x, y, z).
        /// Then it adds similar declarations for other rotations and reflections, as specified by rotations.
        /// </summary>
        public void AddAdjacency(IList <Tile> src, IList <Tile> dest, int x, int y, int z, TileRotation tileRotation = null)
        {
            tileRotation = tileRotation ?? new TileRotation();

            foreach (var rotation in tileRotation.RotationGroup)
            {
                int x2, y2;
                if (directions.Type == DirectionsType.Hexagonal2d)
                {
                    (x2, y2) = TopoArrayUtils.HexRotateVector(x, y, rotation);
                }
                else
                {
                    (x2, y2) = TopoArrayUtils.RotateVector(x, y, rotation);
                }

                AddAdjacency(
                    tileRotation.Rotate(src, rotation).ToList(),
                    tileRotation.Rotate(dest, rotation).ToList(),
                    x2, y2, z);
            }
        }
Example #3
0
        /// <summary>
        /// Declares that the tiles in dest can be placed adjacent to the tiles in src, in the direction specified by (x, y, z).
        /// Then it adds similar declarations for other rotations and reflections, as specified by rotations.
        /// </summary>
        public void AddAdjacency(IList <Tile> src, IList <Tile> dest, int x, int y, int z, int rotationalSymmetry, bool reflectionalSymmetry, TileRotation rotations = null)
        {
            rotations = rotations ?? new TileRotation();
            int totalRotationalSymmetry;

            if (directions.Type == DirectionsType.Hexagonal2d)
            {
                totalRotationalSymmetry = 6;
            }
            else
            {
                totalRotationalSymmetry = 4;
            }

            int reflections = reflectionalSymmetry ? 2 : 1;

            for (var r = 0; r < reflections; r++)
            {
                var reflectX = r > 0 ? true : false;
                for (var rotateCw = 0; rotateCw < totalRotationalSymmetry; rotateCw += (totalRotationalSymmetry / rotationalSymmetry))
                {
                    int x2, y2;
                    if (directions.Type == DirectionsType.Hexagonal2d)
                    {
                        (x2, y2) = TopoArrayUtils.HexRotateVector(x, y, rotateCw, reflectX);
                    }
                    else
                    {
                        (x2, y2) = TopoArrayUtils.RotateVector(x, y, rotateCw, reflectX);
                    }

                    AddAdjacency(
                        rotations.Rotate(src, rotateCw, reflectX).ToList(),
                        rotations.Rotate(dest, rotateCw, reflectX).ToList(),
                        x2, y2, z);
                }
            }
        }