My Code for Number Wizard

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NumberWizard : MonoBehaviour

{
    public int maxNum = 1000;
    public int minNum = 1;
    int guess = 500;

    // Start is called before the first frame update
    void Start()
    {
        guess = (maxNum + minNum) / 2;

        Debug.Log("Yo yo yo mah main man! Welcome to le Number de Wizard");
        Debug.Log("Pick a number between " + minNum + " and " + maxNum);
        Debug.Log("Is your number higher, lower or equal to " + guess + "?");
        Debug.Log("Up = higher, Down = lower, Enter = Correct");
        maxNum = maxNum + 1;
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            minNum = guess;
            guess = (maxNum + minNum) / 2;
            Debug.Log("Is your number higher, lower or equal to " + guess + "?");
        }
        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            maxNum = guess;
            guess = (maxNum + minNum) / 2;
            Debug.Log("Is your number higher, lower or equal to " + guess + "?");
        }
        else if (Input.GetKeyDown(KeyCode.Return))
        {
            Debug.Log("Your number is " + guess + "!");
        }
    }
}

Privacy & Terms