Esempio n. 1
0
        private Brush GetColor(CubeletColor color)
        {
            switch (color)
            {
            case CubeletColor.White:
                return(new SolidBrush(Color.White));

            case CubeletColor.Yellow:
                return(new SolidBrush(Color.Yellow));

            case CubeletColor.Orange:
                return(new SolidBrush(Color.Orange));

            case CubeletColor.Red:
                return(new SolidBrush(Color.Red));

            case CubeletColor.Green:
                return(new SolidBrush(Color.Green));

            case CubeletColor.Blue:
                return(new SolidBrush(Color.Blue));

            default:
                throw new System.Exception("Invalid cubelet color!");
            }
        }
Esempio n. 2
0
        public Cubelet(CubeletColor front, CubeletColor back, CubeletColor left, CubeletColor right, CubeletColor top, CubeletColor bottom)
        {
            if ((front != CubeletColor.Empty && back != CubeletColor.Empty) || (left != CubeletColor.Empty && right != CubeletColor.Empty) || (top != CubeletColor.Empty && bottom != CubeletColor.Empty))
            {
                throw new Exception("Opposite sides of a cubelet can't both be colored!");
            }

            Front  = front;
            Back   = back;
            Left   = left;
            Right  = right;
            Top    = top;
            Bottom = bottom;
        }
Esempio n. 3
0
        public void RotateZ(Rotation r)
        {
            CubeletColor tmpTop = Top;

            if (r == Rotation.Clockwise)
            {
                Top    = Left;
                Left   = Bottom;
                Bottom = Right;
                Right  = tmpTop;
            }
            else
            {
                Top    = Right;
                Right  = Bottom;
                Bottom = Left;
                Left   = tmpTop;
            }
        }
Esempio n. 4
0
        public void RotateY(Rotation r)
        {
            CubeletColor tmpFront = Front;

            if (r == Rotation.Clockwise)
            {
                Front = Right;
                Right = Back;
                Back  = Left;
                Left  = tmpFront;
            }
            else
            {
                Front = Left;
                Left  = Back;
                Back  = Right;
                Right = tmpFront;
            }
        }
Esempio n. 5
0
        public void RotateX(Rotation r)
        {
            CubeletColor tmpTop = Top;

            if (r == Rotation.Clockwise)
            {
                Top    = Back;
                Back   = Bottom;
                Bottom = Front;
                Front  = tmpTop;
            }
            else
            {
                Top    = Front;
                Front  = Bottom;
                Bottom = Back;
                Back   = tmpTop;
            }
        }
Esempio n. 6
0
        /**
         * Reset the cube to it's solved state
         */
        public void Reset()
        {
            for (int row = 0; row < 3; row++)
            {
                for (int col = 0; col < 3; col++)
                {
                    for (int depth = 0; depth < 3; depth++)
                    {
                        CubeletColor front  = (depth == 0 ? CubeletColor.Red : CubeletColor.Empty);
                        CubeletColor back   = (depth == 2 ? CubeletColor.Orange : CubeletColor.Empty);
                        CubeletColor left   = (col == 0 ? CubeletColor.Blue : CubeletColor.Empty);
                        CubeletColor right  = (col == 2 ? CubeletColor.Green : CubeletColor.Empty);
                        CubeletColor top    = (row == 0 ? CubeletColor.Yellow : CubeletColor.Empty);
                        CubeletColor bottom = (row == 2 ? CubeletColor.White : CubeletColor.Empty);

                        cubelets[col, row, depth] = new Cubelet(front, back, left, right, top, bottom);
                    }
                }
            }
        }
Esempio n. 7
0
        private CubeletColor[,] GetFaceArray(CubeFace face)
        {
            CubeletColor[,] colors = new CubeletColor[3, 3];
            switch (face)
            {
            case CubeFace.Front:
                for (int y = 0; y < 3; y++)
                {
                    for (int x = 0; x < 3; x++)
                    {
                        colors[x, y] = cubelets[x, y, 0].Front;
                    }
                }
                break;

            case CubeFace.Back:
                for (int y = 0; y < 3; y++)
                {
                    for (int x = 0; x < 3; x++)
                    {
                        colors[x, y] = cubelets[2 - x, y, 2].Back;
                    }
                }
                break;

            case CubeFace.Left:
                for (int y = 0; y < 3; y++)
                {
                    for (int z = 0; z < 3; z++)
                    {
                        colors[z, y] = cubelets[0, y, 2 - z].Left;
                    }
                }
                break;

            case CubeFace.Right:
                for (int y = 0; y < 3; y++)
                {
                    for (int z = 0; z < 3; z++)
                    {
                        colors[z, y] = cubelets[2, y, z].Right;
                    }
                }
                break;

            case CubeFace.Top:
                for (int z = 0; z < 3; z++)
                {
                    for (int x = 0; x < 3; x++)
                    {
                        colors[x, z] = cubelets[x, 0, 2 - z].Top;
                    }
                }
                break;

            case CubeFace.Bottom:
                for (int z = 0; z < 3; z++)
                {
                    for (int x = 0; x < 3; x++)
                    {
                        colors[x, z] = cubelets[x, 2, z].Bottom;
                    }
                }
                break;
            }

            return(colors);
        }