Exemple #1
0
        /// <summary>
        /// this function rotates a face of the cube.(fully commented)
        /// </summary>
        /// <param name="color">this parameter is the face that will be rotated</param>
        /// <param name="direction">this parameter is the the direction that is rotated</param>
        public void Rotate(Color color, Direction direction)
        {
            
            List<Block> slice = GetSlice(color);//takes a slice of the cube depending on the color
            Orientor orientation = GetOrientation(color);//takes a orientor of the cube

            Edge leftmid = (Edge)GetBlock(0, 1, color);//makes copys of an edge block
            Edge topmid = (Edge)GetBlock(1, 2, color);//makes copys of an edge block
            Edge rightmid = (Edge)GetBlock(2, 1, color);//makes copys of an edge block
            Edge botmid = (Edge)GetBlock(1, 0, color);//makes copys of an edge block

            Corner topleft = (Corner)GetBlock(0, 2, color);//makes copys of an corner block
            Corner topright = (Corner)GetBlock(2, 2, color);//makes copys of an corner block
            Corner botleft = (Corner)GetBlock(0, 0, color);//makes copys of an corner block
            Corner botright = (Corner)GetBlock(2, 0, color);//makes copys of an corner block

            if (direction == Direction.Clockwise)//checks if direction is clockwise
            {
                Edge edge_bucket = leftmid;//makes a temp variable to be used in rotaing 
                leftmid = (Edge)botmid.Rotate(direction, color);//moves a block to another posision 
                botmid = (Edge)rightmid.Rotate(direction, color);//moves a block to another posision 
                rightmid = (Edge)topmid.Rotate(direction, color);//moves a block to another posision 
                topmid = (Edge)edge_bucket.Rotate(direction, color);//puts temp to a position

                Corner corner_bucket = topleft;//makes a temp variable to be used in rotaing 
                topleft = (Corner)botleft.Rotate(direction, color);//moves a block to another posision 
                botleft = (Corner)botright.Rotate(direction, color);//moves a block to another posision 
                botright = (Corner)topright.Rotate(direction, color);//moves a block to another posision 
                topright = (Corner)corner_bucket.Rotate(direction, color);//puts temp to a position
            }
            else//if it is direction is anti-clockwise
            {
                Edge edge_bucket = leftmid;//makes a temp variable to be used in rotaing 
                leftmid = (Edge)topmid.Rotate(direction, color);//moves a block to another posision 
                topmid = (Edge)rightmid.Rotate(direction, color);//moves a block to another posision 
                rightmid = (Edge)botmid.Rotate(direction, color);//moves a block to another posision 
                botmid = (Edge)edge_bucket.Rotate(direction, color);//puts temp to a position

                Corner corner_bucket = topleft;//makes a temp variable to be used in rotaing 
                topleft = (Corner)topright.Rotate(direction, color);//moves a block to another posision 
                topright = (Corner)botright.Rotate(direction, color);//moves a block to another posision 
                botright = (Corner)botleft.Rotate(direction, color);//moves a block to another posision 
                botleft = (Corner)corner_bucket.Rotate(direction, color);//puts temp to a position
            }
            Console.WriteLine("Rotated " + color + " to " + direction);
        }
Exemple #2
0
        /**
         * Moves all of the blocks in the specified color slice
         * the direction specified.
         */
        public void Rotate(Color color, Direction direction)
        {
            List <Block> slice       = GetSlice(color);
            Orientor     orientation = GetOrientation(color);

            Edge leftmid  = (Edge)GetBlock(0, 1, color);
            Edge topmid   = (Edge)GetBlock(1, 2, color);
            Edge rightmid = (Edge)GetBlock(2, 1, color);
            Edge botmid   = (Edge)GetBlock(1, 0, color);

            Corner topleft  = (Corner)GetBlock(0, 2, color);
            Corner topright = (Corner)GetBlock(2, 2, color);
            Corner botleft  = (Corner)GetBlock(0, 0, color);
            Corner botright = (Corner)GetBlock(2, 0, color);

            if (direction == Direction.Clockwise)
            {
                Edge edge_bucket = leftmid;
                leftmid  = (Edge)botmid.Rotate(direction, color);
                botmid   = (Edge)rightmid.Rotate(direction, color);
                rightmid = (Edge)topmid.Rotate(direction, color);
                topmid   = (Edge)edge_bucket.Rotate(direction, color);

                Corner corner_bucket = topleft;
                topleft  = (Corner)botleft.Rotate(direction, color);
                botleft  = (Corner)botright.Rotate(direction, color);
                botright = (Corner)topright.Rotate(direction, color);
                topright = (Corner)corner_bucket.Rotate(direction, color);
            }
            else
            {
                Edge edge_bucket = leftmid;
                leftmid  = (Edge)topmid.Rotate(direction, color);
                topmid   = (Edge)rightmid.Rotate(direction, color);
                rightmid = (Edge)botmid.Rotate(direction, color);
                botmid   = (Edge)edge_bucket.Rotate(direction, color);

                Corner corner_bucket = topleft;
                topleft  = (Corner)topright.Rotate(direction, color);
                topright = (Corner)botright.Rotate(direction, color);
                botright = (Corner)botleft.Rotate(direction, color);
                botleft  = (Corner)corner_bucket.Rotate(direction, color);
            }
            //Console.WriteLine("Rotated " + color + " to " + direction);
        }