Exemplo n.º 1
0
        private void tmrAnimation_Tick(object sender, EventArgs e)
        {
            // Display true result after one second
            if (animationCounter >= ONE_SECOND)
            {
                this.btnRollDice.Enabled = true;

                // Run the type of roll required
                if (this.firstRoll)
                {
                    this.firstRoll = !SnakeEyesGame.FirstRoll();
                }
                else
                {
                    this.firstRoll = !SnakeEyesGame.AnotherRoll();
                }

                this.UpdateDisplay(false);

                if (this.firstRoll)
                {
                    this.btnRollDice.Enabled        = false;
                    this.btnContinuePlaying.Enabled = true;
                    this.btnContinuePlaying.Visible = true;
                }

                tmrAnimation.Stop();

                return;
            }

            // DateTime.UtcNow.Ticks is a measure of nanoseconds, so values between are different.
            // Makes for slightly more realistic die rolls
            this.imgDie1.Image = Images.GetDieImage(((int)DateTime.UtcNow.Ticks % DIE_RNG_MAX) + 1);
            this.imgDie2.Image = Images.GetDieImage(((int)DateTime.UtcNow.Ticks % DIE_RNG_MAX) + 1);

            // Update animationCounter with how many seconds it has been
            animationCounter += (double)tmrAnimation.Interval / 1000.0f;
        }