using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NumberWizard : MonoBehaviour
{
[SerializeField] int _maxNumber = 1000;
[SerializeField] int _minNumber = 1;
[SerializeField] int _guessNumber = 500;
int _rMaxNumber;
int _rMinNumber;
int _rguessNumber;
// Start is called before the first frame update
void Start()
{
SetResetValues();
IntroChat();
}
private void SetResetValues()
{
_rMaxNumber = _maxNumber;
_rMinNumber = _minNumber;
_rguessNumber = _guessNumber;
}
private void IntroChat()
{
Debug.Log("Welcome to number wizard");
Debug.Log("Pick a number");
Debug.Log("The highest number is: " + _maxNumber);
Debug.Log("The lowest number is: " + _minNumber);
Debug.Log("Up Key = Higher, Down Key = Lower, Enter Key = Correct");
Debug.Log("Tell me if your number is higher or lower than " + _guessNumber);
_maxNumber = _maxNumber + 1;
}
// Update is called once per frame
void Update()
{
RunGame();
}
private void RunGame()
{
//Detect when the up arrow key is pressed down
if (Input.GetKeyDown(KeyCode.UpArrow))
{
_minNumber = _guessNumber;
NextGuess();
}
//Detect when the down arrow key is pressed down
else if (Input.GetKeyDown(KeyCode.DownArrow))
{
_maxNumber = _guessNumber;
NextGuess();
}
//Detect when the Return key is pressed down
else if (Input.GetKeyDown(KeyCode.Return))
{
Debug.Log(_guessNumber + "? Thats a pretty sick number");
ResetNumber();
IntroChat();
}
void NextGuess()
{
_guessNumber = (_maxNumber + _minNumber) / 2;
Debug.Log("is your number " + _guessNumber + "?");
}
void ResetNumber()
{
_guessNumber = _rguessNumber;
_maxNumber = _rMaxNumber;
_minNumber = _rMinNumber;
}
}
}