Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class NumberWizard : MonoBehaviour {
- int max;
- int min;
- int guess;
- // Use this for initialization
- void Start ()
- {
- StartGame();
- }
- void StartGame()
- {
- max = 1000;
- min = 1;
- guess = 500;
- Debug.Log("Hello Fuhrerbunker, Welcome to Number Wizard");
- Debug.Log("Please pick a number");
- Debug.Log("The highest number you may pick is: " + max);
- Debug.Log("The lowest number you may pick is: " + min);
- Debug.Log("Is your guess higher or lower than " + guess);
- 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))
- {
- min = guess;
- NextGuess();
- }
- else if (Input.GetKeyDown(KeyCode.DownArrow))
- {
- max = guess;
- NextGuess();
- }
- else if (Input.GetKeyDown(KeyCode.Return))
- {
- Debug.Log("Correct");
- }
- }
- void NextGuess()
- {
- guess = (max + min) / 2;
- Debug.Log("Is your guess higher or lower than " + guess);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement