My best greetings from Catalonia… My name is Salvador and I’m enjoying the course very much.
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("Welcome from Catalonia to number wizard... benvinguts");
Debug.Log("Please, pick a number");
Debug.LogFormat($"The highest number you can pick is: {max}");
Debug.LogFormat("The lowest number you can pick is {0}", min);
Debug.Log("Tell me if your number is higher or lower than " +guess);
Debug.Log("Push Up if it is Higher, Down if it's Lower or Enter if my guess is correct");
max++;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.UpArrow))
{
Debug.Log("You have pressed the Up key...");
min = guess;
guess = (max + min) / 2;
Debug.Log("So I supose that the number perhaps can be..." +guess);
Debug.Log("Is it higher or lower?... please help me with the Up or Down arrow keys as usual \n If it's the correct number, press Enter");
}
else if (Input.GetKeyDown(KeyCode.DownArrow))
{
Debug.Log("You have pressed the Down key");
max = guess;
guess = (max + min) / 2;
Debug.Log("So I supose that the number perhaps can be..." + guess);
Debug.Log("Is it higher or lower?... please help me with the Up or Down arrow keys as usual \n If it's the correct number, press Enter");
}
else if (Input.GetKeyDown(KeyCode.Return))
{
Debug.Log("I'M THE BEST!!!!!!");
}
}
}