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 = 5000;
min = 50;
guess = 2525;
Debug.Log("Jay Jagannath. Namaste");
Debug.Log("Pick a number and wait for the magic to happen");
Debug.Log("Highest number you can pick is: " + max);
Debug.Log("Lowest number you can pick is: " + min);
Debug.Log("It is higher or lower than " + guess);
Debug.Log("Press up = Higher, Press down = Lower, Press Enter = Correct");
max = max + 1;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.UpArrow))
{
Debug.Log("Higher");
min = guess;
NextGuess();
}
else if (Input.GetKeyDown(KeyCode.DownArrow))
{
Debug.Log("Lower");
max = guess;
NextGuess();
}
else if (Input.GetKeyDown(KeyCode.Return))
{
Debug.Log("Hereby the magic happened");
StartGame();
}
else (StartGame);
}
void NextGuess()
{
guess = (max + min) / 2;
Debug.Log("It is higher or lower than " + guess);
}
}
Check the else statement here.