Greetings from the United States! Our greeting just a standard, “hello,” so I added a little Simpsons twist to my Number Wizard code.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NumberWizard : MonoBehaviour
{
int high = 1000, low = 1, guess;
// Start is called before the first frame update
void Start()
{
Debug.Log("Welcome to Number Wizard!" +
"\nAnd I'm your host, Homer Simpson *buuurp*");
Debug.Log("Pick a number between " + low + " and " + high +"!");
Debug.Log("Highest possible pick: " + high +
"\nLowest possible pick: " + low);
guess = (low + high) / 2;
Debug.Log("Is your number: " + guess + "?");
Debug.Log("Push UP arrow if your number is higher.");
Debug.Log("Push DOWN arrow if your number is lower.");
Debug.Log("Push ENTER/RETURN if it is your number!");
high += 1;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.UpArrow))
{
low = guess;
guess = (low + high) / 2;
Debug.Log("D'OH!\nHow 'bout " + guess + "?");
}
else if (Input.GetKeyDown(KeyCode.DownArrow))
{
high = guess;
guess = (low + high) / 2;
Debug.Log("D'OH!\nHow 'bout " + guess + "?");
}
else if (Input.GetKeyDown(KeyCode.Return))
{
Debug.Log("WOOHOO! Your number is " + guess + "." +
"\nThanks for playing!");
}
}
}