Here is my code for lesson 13.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NumberWizard : MonoBehaviour
{
int max = 1000;
int min = 1;
int guess = 500;
int tries = 0;
// Start is called before the first frame update
void Start()
{
Debug.Log("Sorry. Im the Number Wizard, eh.");
Debug.Log("What Say you Adventurer");
Debug.Log("Think you can beat me in a number game?");
Debug.Log("Pick a number, don't tell me what it is");
Debug.Log("The highest number you can pick is: " + max + " and the lowest 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))
{
Debug.Log("Hmmmm... Guess I was too low.");
min = guess;
guess = (min + max) / 2;
tries = ++tries;
Debug.Log("Is it higher or lower than " + guess);
}
else if (Input.GetKeyDown(KeyCode.DownArrow))
{
Debug.Log("Damn. I was too high.");
max = guess;
guess = (min + max) / 2;
tries = ++tries;
Debug.Log("Is it higher or lower than " + guess);
}
else if (Input.GetKeyDown(KeyCode.Return))
{
Debug.Log("Wait... I got it? Only took " + tries + "tries. But we all know it was really only 1.");
}
}
}