Per the tutorial video, I changed the integer maxGuessesAllowed to public, but it seems to disable the integer altogether. It makes my max guesses 10 regardless of the number there. Removing the ‘public’ fixes it and make the max guesses whatever number I have there. Am I missing something?
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class NumberWizard : MonoBehaviour {
// Use this for initialization
int max;
int min;
int guess;
public int maxGuessesAllowed = 8;
public Text text;
void Start () {
StartGame();
}
void StartGame () {
max = 1000;
min = 1;
guess = 500;
max = max + 1;
}
public void GuessLower(){
max = guess;
NextGuess();
}
public void GuessHigher(){
min = guess;
NextGuess();
}
public void NextGuess () {
guess = (max + min) / 2;
text.text = guess.ToString();
maxGuessesAllowed = maxGuessesAllowed - 1;
if(maxGuessesAllowed <=0){
Application.LoadLevel("Win");
}
}
}