Exemple #1
0
        private void RollButton_Click(object sender, RoutedEventArgs e)
        {
            // Generate a random number between 1 and 6 per button click
            // Use system time as random seed
            Random rnd = new Random(System.DateTime.Now.Second);

            for (int i = 0; i < diceNum.Length; i++)
            {
                diceNum[i] = rnd.Next(1, 7);
            }

            DieValueText.Text = $"The values are {diceNum[0]}, {diceNum[1]}, {diceNum[2]}";

            Die1.DisplayFace(diceNum[0]);
            Die2.DisplayFace(diceNum[1]);
            Die3.DisplayFace(diceNum[2]);

            score         += Play_Game();
            ScoreText.Text = $"{score}";

            if (ScoreText.Visibility == Visibility.Collapsed || WinText.Visibility == Visibility.Collapsed)
            {
                ScoreText.Visibility    = Visibility.Visible;
                PreScoreText.Visibility = Visibility.Visible;
                WinText.Visibility      = Visibility.Visible;
            }
        }
        private void RollButton_Click(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < Dice.Length; i++)
            {
                int DieValue = RandomGenerator.Next(1, 7);
                Dice[i] = DieValue;
            }

            Die1.DisplayFace(Dice[0]);
            Die2.DisplayFace(Dice[1]);
            Die3.DisplayFace(Dice[2]);

            ApplyGameRules();
        }
Exemple #3
0
        private void RollButton_Click(object sender, RoutedEventArgs e)
        {
            // DieValueText.Text = "Button clicked!";

            for (int i = 0; i < Dice.Length; i++)
            {
                int DieValue = RandomGenerator.Next(1, 7);
                Dice[i] = DieValue;
            }

            DieValueText.Text = $"The values are {Dice[0]}, {Dice[1]}, and {Dice[2]}.";

            Die1.DisplayFace(Dice[0]);
            Die2.DisplayFace(Dice[1]);
            Die3.DisplayFace(Dice[2]);

            ApplyGameRules();
        }