Esempio n. 1
0
        public void BlockSizesChangesCube()
        {
            var cube = CubeFactory.GetCube(3, 0, 0, 0);

            AssertCubeBounds(new Vector3(-3, -3, -3),
                             new Vector3(3, 3, 3), cube);
        }
Esempio n. 2
0
        public void CubeAtOffset()
        {
            var cube = CubeFactory.GetCube(BlockSize, 1, 2, 0);

            AssertCubeBounds(new Vector3(1 - BlockSize, 2 - BlockSize, -BlockSize),
                             new Vector3(1 + BlockSize, 2 + BlockSize, BlockSize), cube);
        }
Esempio n. 3
0
        /// <summary>
        ///  _+ size__
        /// |         |
        /// |    _    |
        /// |         |
        /// |__- size_|
        /// </summary>
        public void CubeAtOrigin()
        {
            var cube = CubeFactory.GetCube(BlockSize, 0, 0, 0);

            AssertCubeBounds(new Vector3(-BlockSize, -BlockSize, -BlockSize),
                             new Vector3(BlockSize, BlockSize, BlockSize), cube);
        }
Esempio n. 4
0
    public CubesLayer CreateLayer(int width, LayerType layerType, float margin, Dictionary <CubeSide, int> sideToColorIndex, RubikCube parentCube)
    {
        var layer = Instantiate(layerPrefab);

        for (var i = 0; i < width * width; i++)
        {
            var rowNumber  = Mathf.Floor(i / width);
            var isEdgeRow  = rowNumber % (width - 1) == 0;
            var isFirstRow = isEdgeRow && rowNumber == 0;
            var isLastRow  = isEdgeRow && !isFirstRow;

            var isFirstInRow = i % (width) == 0;
            var isLastInRow  = (i + 1) - (width * (rowNumber + 1)) == 0;

            var cubeSides = new List <CubeSide>();

            if (isFirstInRow)
            {
                cubeSides.Add(CubeSide.Left);
            }
            else if (isLastInRow)
            {
                cubeSides.Add(CubeSide.Right);
            }

            if (isFirstRow)
            {
                cubeSides.Add(CubeSide.Top);
            }
            else if (isLastRow)
            {
                cubeSides.Add(CubeSide.Bottom);
            }

            if (layerType == LayerType.Front)
            {
                cubeSides.Add(CubeSide.Front);
            }
            else if (layerType == LayerType.Back)
            {
                cubeSides.Add(CubeSide.Back);
            }

            var coloredSides = new Dictionary <CubeSide, int>();
            foreach (var side in cubeSides)
            {
                coloredSides.Add(side, sideToColorIndex[side]);
            }

            var cube = cubeFactory.GetCube(coloredSides);

            cube.transform.SetParent(layer.transform);
            cube.transform.Translate((i - (width * rowNumber)) * (1 + MarginBetweenCubes), -rowNumber - (MarginBetweenCubes * rowNumber), margin);
            layer.LayerCubes.Add(cube);
        }

        layer.ParentCube = parentCube;
        return(layer);
    }
Esempio n. 5
0
        public void CubeHasCorrectNumberOfVertices()
        {
            const int verticesInAFace = 6;
            const int facesInACube    = 6;

            var cube = CubeFactory.GetCube(BlockSize, 0, 0, 0);

            cube.Length.ShouldBe(verticesInAFace * facesInACube);
        }
Esempio n. 6
0
        public Block(GraphicsDevice graphicsDevice, IntPoint3D position)
        {
            this.graphicsDevice = graphicsDevice;

            Position = position.ToVector() * BlockSize;

            vertices = CubeFactory.GetCube(BlockSize, IntPoint3D.GetNeighbourPositions());

            effect = new BasicEffect(graphicsDevice);
        }
Esempio n. 7
0
        public Block(GraphicsDevice graphicsDevice, int x, int y, int z)
        {
            this.graphicsDevice = graphicsDevice;
            var vertices = CubeFactory.GetCube(1, x, y, z);

            buffer = new VertexBuffer(graphicsDevice, typeof(VertexPositionColor), vertices.Length, BufferUsage.WriteOnly);

            buffer.SetData(vertices);

            effect = new BasicEffect(graphicsDevice)
            {
                World = Matrix.Identity
            };
        }