My Number wizard!

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

public class NumberWizard : MonoBehaviour
{
// Variables in class section are available for various methods within class.
int max = 1000;
int min = 1;
int guess = 500;

// Start is called before the first frame update
void Start()
{  
    Debug.Log("Welcome to Oscar's Number Wizzard!");
    Debug.Log("Pick a number between " + min + " and " + max + " , don't tell me what it is!");
    Debug.Log("But do let me know if your number is lower or higher than " + guess);
    Debug.Log("CONTROLS: Press UP if higher, DOWN if lower, Enter if correct");
    max = max + 1;
}

// Update is called once per frame
void Update()
{
    if (Input.GetKeyDown(KeyCode.UpArrow))
    {
        Debug.Log("Higher than " + guess + " , eh?");
        min = guess;
        guess = (max + min) / 2;
        Debug.Log("So, is it " + guess + "?");
    }

    else if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        Debug.Log("Lower than " + guess + " , then?");
        max = guess;
        guess = (max + min) / 2;
        Debug.Log("Is it " + guess + "?");
    }

    else if (Input.GetKeyDown(KeyCode.Return))
    {
        Debug.Log("Correct answer");
    }

}

}

Privacy & Terms