Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class NumberWizard : MonoBehaviour
- {
- // Use this for initialization
- private int max;
- private int min;
- private int guess;
- private void Start()
- {
- StartGame();
- }
- void StartGame()
- {
- max = 1000;
- min = 1;
- guess = 500;
- max = max + 1;
- print("=========================");
- print("Welcome to Number Wizard!");
- print("Pick a number in your head, but dont tell me!");
- print("The highest number you can pick is " + (max - 1));
- print("The lowest number you can pick is " + min);
- print("Is the number higher or lower than " + guess);
- print("Up = higher, down = lower,return = equal");
- }
- void NextGuess()
- {
- guess = (max + min) / 2;
- print("Higher or lower than" + guess);
- print("Up = higher, down = lower,return = equal");
- }
- // Update is called once per frame
- private void Update()
- {
- if (Input.GetKeyDown(KeyCode.UpArrow))
- {
- min = guess;
- NextGuess();
- }
- else if (Input.GetKeyDown(KeyCode.DownArrow))
- {
- max = guess;
- NextGuess();
- }
- else if (Input.GetKeyDown(KeyCode.Return)) print("I won!");
- StartGame();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement