mercredi 4 décembre 2019

Is there a way to tell an if statement if a condition is true do nothing

Creating a dice roll game in c# WPF using a random number generator for each dice. If a dice is clicked I want to protect that value so that when the user rolls the dice it does not change. I have implemented a button click for each dice button that on click disables the button.

 private void Dicebtn3_Click(object sender, RoutedEventArgs e)
    {
        Dicebtn3.IsEnabled = false;
    }

That works perfectly. The part I am not sure of is how to tell my dicerollBtn to not generate a number if the button was clicked. Roll code is here

private void rollBtn_Click(object sender, RoutedEventArgs e)
    {
        if (Dicebtn1_Click) rndNum1 = rndNumbers.Next(1, 6);
        else 
        rndNum2 = rndNumbers.Next(1, 6);
        rndNum3 = rndNumbers.Next(1, 6);
        rndNum4 = rndNumbers.Next(1, 6);
        rndNum5 = rndNumbers.Next(1, 6);
        rndNum6 = rndNumbers.Next(1, 6);

Aucun commentaire:

Enregistrer un commentaire