Just another American wizard here

using System.Collections;
using System.Collections.Generic;
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("Ni! Welcome to Number Wizard!");
        Debug.Log("Please pick a number between " + min + "and " + max + " and keep it to yourself.");
        Debug.Log("Tell me, is your number higher or lower than " + guess);
        Debug.Log("Push Up if Higher, Push Down if Lower. Push Enter if correct.");
        max = max + 1;
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            Debug.Log("Guessing a higher number...");
            min = guess;
            guess = (max + min) / 2;
            Debug.Log("Tell me, is your number higher or lower than " + guess);
        }
        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            Debug.Log("Guessing a lower number...");
            max = guess;
            guess = (max + min) / 2;
            Debug.Log("Tell me, is your number higher or lower than " + guess);
        }
        else if (Input.GetKeyDown(KeyCode.Return))
        {
            Debug.Log("Your number is " + guess + " and it has been guessed! Wizardry has been performed! Huzzah!");
        }
    }
}

Privacy & Terms