using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NumberWizard : MonoBehaviour
{
int max;
int min;
int guess;
// Start is called before the first frame update
void Start()
{
StartGame();
}
void StartGame()
{
max = 1000;
min = 1;
guess = 500;
Debug.Log("Welcome child, step into the Oracle's chamber");
Debug.Log("Think of a number, let it take form in your mind and do not tell me what it is");
Debug.Log("Your number must not exceed " + max);
Debug.Log("And your number must not be less than " + min);
Debug.Log("Is the number you are thinking of... " + guess + "?");
Debug.Log("Press the Up Arrow if your number is higher, Down Arrow if it is lower or press Enter if my guess is Correct");
max = max + 1;
}
// Update is called once per frame
void Update()
{
//Detect when the Up Arrow key is pressed down
if (Input.GetKeyDown(KeyCode.UpArrow))
{
Debug.Log("Higher you say?");
min = guess;
NextGuess();
}
//Detect when the Down Arrow key is pressed down
else if (Input.GetKeyDown(KeyCode.DownArrow))
{
Debug.Log("Lower you say?");
max = guess;
NextGuess();
}
//Detect when the Return key is pressed down
else if (Input.GetKeyDown(KeyCode.Return))
{
Debug.Log("Ha! I knew your number was " + guess + " all along, I was just testing you ;-)");
Debug.Log("Would you like to play again? Press Spacebar if you do");
}
else if (Input.GetKeyDown(KeyCode.Space))
{
StartGame();
}
}
void NextGuess()
{
guess = (max + min) / 2;
Debug.Log("Is the number you are thinking of..." + guess + "?");
}
}