My Number Wizard Introduction

Greetings m’Lord, welcome to Numbour Wiza-ard…

public class NumberWizard : MonoBehaviour {

int max = 1000;
int min = 1;
int guess = 500;

// Use this for initialization
void Start ()
{
    Debug.Log("Greetings m'Lord, welcome to Numbour Wiza-ard...");
    Debug.Log("Would your highness please pick a number between " + min + " and " + max + ".");
    Debug.Log("Please inform me Sire whether your number is higher or lower than 500.");
    Debug.Log("Push Up = Greater  Push Down = Smaller  Push Enter = Correct!");
    max = max + 1;

}

// Update is called once per frame
void Update ()
{

    if (Input.GetKeyDown(KeyCode.UpArrow))
    {
        Debug.Log("My number is greater than " + guess + ".");
        min = guess;
        guess = (min + max) / 2;
        Debug.Log("Drat! How about " + guess + " sire?");
    }

    else if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        Debug.Log("My number is lesser than " + guess + ".");
        max = guess;
        guess = (min + max) / 2;
        Debug.Log("Drat! How about " + guess + " sire?");
    }

     else if (Input.GetKeyDown(KeyCode.Return))
    {
        Debug.Log("By Jove, " + guess + " is indeed the correct answer!");
        Debug.Log("Good game m'lord!");
    }

}

}

Privacy & Terms