Beispiel #1
0
        /// <summary>
        /// Constructor used for creating a new cube that looks the same as the given cube
        /// </summary>
        /// <param name="cube">The cube base the new cube off</param>
        public Cube(Cube cube)
        {
            int piecesInASide = Size * Size;

            top    = new Piece[piecesInASide];
            bottom = new Piece[piecesInASide];
            front  = new Piece[piecesInASide];
            back   = new Piece[piecesInASide];
            right  = new Piece[piecesInASide];
            left   = new Piece[piecesInASide];

            centres = new Centre[6];
            edges   = new Edge[12];
            corners = new Corner[8];

            // Get the pieces of the other cube
            Centre[] otherCentres = cube.GetCentres();
            Edge[]   otherEdges   = cube.GetEdges();
            Corner[] otherCorners = cube.GetCorners();

            // Create each piece with the same colour as the pieces of the sample cube
            // and set the position to be the same as the sample cube
            for (int i = 0; i < centres.Length; i++)
            {
                centres[i] = new Centre(otherCentres[i].colour);
                centres[i].SetPosition(otherCentres[i].Position());
            }

            for (int i = 0; i < edges.Length; i++)
            {
                edges[i] = new Edge(otherEdges[i].GetColours());
                edges[i].SetPosition(otherEdges[i].GetPosition());
            }

            for (int i = 0; i < corners.Length; i++)
            {
                corners[i] = new Corner(otherCorners[i].GetColours());
                corners[i].SetPosition(otherCorners[i].GetPosition());
            }

            UpdateSides();
        }