Hello there, thanks for passing by and beware my first code! Here in Curitiba, “piazada” means something like “guys”. Have a nice day!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NumberWizard : MonoBehaviour {
int max = 1000;
int min = 1;
int guess = 500;
// Use this for initialization
void Start () {
Debug.Log("Dai, piazada, welcome to Number Wizard");
Debug.Log("Please, pick a number! I will guess it...");
Debug.Log("The lowest number is:" + min);
Debug.Log("And the highest is:"+ max);
Debug.Log("Tell me if your number is higher or lower than 500");
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("So it's higher, hum...");
min = guess;
guess = (max + min)/2;
Debug.Log("Is it..." + guess);
}
else if (Input.GetKeyDown(KeyCode.DownArrow))
{
Debug.Log("So it's lower, hum...");
max = guess;
guess = (max + min)/2;
Debug.Log("Is it..." + guess);
}
else if(Input.GetKeyDown(KeyCode.Return))
{
Debug.Log("YEAH FINALLY- I mean, I knew it from the start...");
}
}
}