My way of writing code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NumberWizard : MonoBehaviour
{
int maxValue = 1000;
int minValue = 1;
int refvalue = 500;

// Start is called before the first frame update
void Start()
{
    Debug.Log(" namaste,welcome to number wizard buddy!!!");
    Debug.Log("please pick a number and if you tell me what it is then i won't talk to you");
    Debug.Log("the higest number which you can choose is 1000"+ maxValue);
    Debug.Log("the lowest number which you can choose is 1" +minValue);
    Debug.Log("is your value is higher or lower than 500 ");
    Debug.Log("push UpArrow= higer \n push DownArrow= lower \n hit Enter = correct");
    maxValue = 1000 + 1;
}

// Update is called once per frame
void Update()
{
    if (Input.GetKeyDown(KeyCode.UpArrow))
    {
        Debug.Log("your value is higher");
        minValue = refvalue;
        refvalue = (maxValue + minValue) / 2;
        Debug.Log(refvalue);
    }
    else if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        Debug.Log("your value is lower");
        maxValue = refvalue;
        refvalue = (minValue + maxValue) / 2;
        Debug.Log(refvalue);
    }
    else if (Input.GetKeyDown(KeyCode.Return))
    {
        Debug.Log("our guess is correct");
    }
}

}

Privacy & Terms