A modicum of personality for the NW

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("Hi there! You've found the Number Wizard...");
        Debug.Log("Think of a number...");
        Debug.Log("It should be no higher than: " + max);
        Debug.Log("And no lower than: " + 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("Higher? Hmm... Ok, how about...");
            min = guess;
            guess = (max + min) / 2;
            Debug.Log(guess);
        }

        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            Debug.Log("Lower, eh? Let's try...");
            max = guess;
            guess = (max + min) / 2;
            Debug.Log(guess);
        }

        else if (Input.GetKeyDown(KeyCode.Return))
        {
            Debug.Log("The Number Wizard always wins eventually :P");
        }
    }
}

Privacy & Terms