So I took the challenge in #43 and came up with this. Initial ‘guess’ value is randomized, so further values also get randomized each time the player plays the game again.
void StartGame()
{
FirstGuess();
}
void FirstGuess()
{
guess = Random.Range(min, max + 1);
guessText.text = guess.ToString();
}
void NextGuess()
{
guess = (min + max) / 2;
guessText.text = guess.ToString();
}
Further through the video, I saw Rick preventing max constraint going over 1000, I wasn’t able to make heads over it, so the forum discussions helped me in this part.
public void OnPressHigher()
{
min = guess + 1;
if (min > max)
{
min = max;
}
NextGuess();
}
public void OnPressLower()
{
max = guess;
NextGuess();
}