Hi guys, so I wanted to just add another thing to the number wizard for the hell of it, a simple warning if there was one guess left, not really in the context of the game because it assumes the user is doing the guessing. That’s beside the point, I wondered if the actual coding is a preferred method or not, or is there a better way of doing it? (It works perfectly ok).
I added another function with an if statement, if maxGuessesAllowed == 1 then return message. I then called the function in the next guess function. Am I wasting code, or doing things oddly here? Thanks
void NextGuess (){
guess = Random.Range (min, max + 1);
text.text = guess.ToString();
maxGuessesAllowed = maxGuessesAllowed - 1;
guessesRemaining = maxGuessesAllowed;
triesLeft.text = guessesRemaining.ToString();
WarningMessage ();
if (maxGuessesAllowed <= 0) {
SceneManager.LoadScene ("Win");
}
}
void WarningMessage (){
if (maxGuessesAllowed == 1) {
warnings.text = ("One Guess Remaining!!!");
}
}