예제 #1
0
        /// <summary>
        /// Randomly scrambles cube into one of four difficulties.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnScramble_Click(object sender, EventArgs e)
        {
            // housekeeping
            radDisabled.Checked = true;

            int    difficulty;              // number of random turns
            int    turn;                    // represents turn, which is selected randomly
            Random rand = new Random();     // Random object, used to determine which turns to call

            // determines difficulty level
            if (radEasy.Checked)
            {
                difficulty = 2;
            }
            else if (radNormal.Checked)
            {
                difficulty = 4;
            }
            else if (radHard.Checked)
            {
                difficulty = 8;
            }
            else
            {
                difficulty = 16;
            }

            for (int i = 0; i < difficulty; i++)
            {
                // figures out which turn to call
                turn = rand.Next(1, 13);

                // calls selected turn
                switch (turn)
                {
                case 1:
                    myCube.RightTurn();
                    break;

                case 2:
                    myCube.RightPrimeTurn();
                    break;

                case 3:
                    myCube.LeftTurn();
                    break;

                case 4:
                    myCube.LeftPrimeTurn();
                    break;

                case 5:
                    myCube.UpTurn();
                    break;

                case 6:
                    myCube.UpPrimeTurn();
                    break;

                case 7:
                    myCube.DownTurn();
                    break;

                case 8:
                    myCube.DownPrimeTurn();
                    break;

                case 9:
                    myCube.FrontTurn();
                    break;

                case 10:
                    myCube.FrontPrimeTurn();
                    break;

                case 11:
                    myCube.BackTurn();
                    break;

                case 12:
                    myCube.BackPrimeTurn();
                    break;
                }
            }

            UpdateStickers();
        }