示例#1
0
        /**
         * The only function of the dice is to simulate dice roll and redraw the "rolled"
         * number in the graphic interface.
         */
        public int Roll(Monopoly window)
        {
            //draw the dice and randomising
            int rolls  = randomizer.Next(5, 10);
            int result = 0;

            for (int i = 0; i < rolls; i++)
            {
                result = randomizer.Next(1, 7);
                window.ShowDiceNumber(result);
                Thread.Sleep(DICE_SLEEP);
            }
            Thread.Sleep(ROLL_OVER_WAIT);
            // roll again
            if (result == 6)
            {
                result += Roll(window);
            }
            return(result);
            //return 7; //for testing only!
        }