public class NumberWizard : MonoBehaviour
{
int max = 1000;
int min = 1;
int guess = 500;
// Start is called before the first frame update
void Start()
{
StartGame();
}
void StartGame()
{
Debug.Log("I am a psychic and I will guess the number in your mind");
Debug.Log("Think of a number and I will guess it");
Debug.Log("If I fail to guess it for too many times then I might be mad and kill you with telekinesis");
Debug.Log("You cannot choose number bigger than: " + max);
Debug.Log("Your minimum chooseable number is: " + min);
Debug.Log("Is your number higher or lower than " + guess);
Debug.Log("Push up = Higher, Push down = Lower, Push enter = Correct");
max = max + 1;
}
void RestartGame()
{
max = 1500;
min = 1;
guess = 750;
Debug.Log("Wanna go again? I can do this all day");
Debug.Log("Let's do 1 to 1500 this time");
Debug.Log("If I fail to guess it for too many times then I might be mad and kill you with pyrokinesis");
Debug.Log("You cannot choose number bigger than: " + max);
Debug.Log("Your minimum chooseable number is: " + min);
Debug.Log("Is your number higher or lower than " + guess);
Debug.Log("Push up = Higher, Push down = Lower, Push enter = Correct");
max = max + 1;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.UpArrow))
{
min = guess;
NextGuess();
}
else if (Input.GetKeyDown(KeyCode.DownArrow))
{
max = guess;
NextGuess2();
}
else if (Input.GetKeyDown(KeyCode.Return))
{
Debug.Log("Told you I am a psychic. Now kneel before your lord and savior");
RestartGame();
}
}
void NextGuess ()
{
if (Input.GetKeyDown(KeyCode.UpArrow))
{
guess = (max + min) / 2;
Debug.Log("So its higher than that. I totally see that coming. What about " + guess);
}
}
void NextGuess2()
{
guess = (max + min) / 2;
Debug.Log("As I thought, its lower than this. Then is it " + guess);
}
}