using UnityEngine;
public class NumberWizard : MonoBehaviour
{
int max = 1000;
int min = 1;
int guess = 500;
// Start is called before the first frame update
void Start()
{
Debug.Log("Alright lad, welcome to number wizid!");
Debug.Log(string.Format("Giz a number der between {0} and {1}.", min, max));
Debug.Log(string.Format("I reckon you picked {0}, ya know?", guess));
Debug.Log("If I'm wrong and your number is higher then press UP, if it's lower, you know what to do kid, press DOWN.");
Debug.Log("But if I'm bang on, smash the enter key for us, cheers 'r kid.");
max = max + 1;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.UpArrow))
{
min = guess;
guess = (max + min) / 2;
Debug.Log(string.Format("Higher! Is it, really? Go on then, I reckon it could be {0}.", guess));
}
else if (Input.GetKeyDown(KeyCode.DownArrow))
{
max = guess;
guess = (max + min) / 2;
Debug.Log(string.Format("Argh no, lower! How about {0} then, is that right?", guess));
}
else if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
{
Debug.Log(string.Format("Smashed it lad. I knew it was {0} all along, I was just pulling your leg.", guess));
}
}
}