Advertisement
Guest User

Help.

a guest
Apr 25th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class NumberWizard : MonoBehaviour {
  5.     int max = 1001;
  6.     int min = 1;
  7.     int guess = 500;
  8.     // Use this for initialization
  9.     void Start () {
  10.         StartGame ();
  11.     }
  12.     void StartGame() {
  13.         int max = 1001;
  14.         int min = 1;
  15.         int guess = 500;
  16.         print ("============");
  17.         print ("Welcome to Number Wizard!");
  18.         print ("Pick a number in your head, but don't tell me!");
  19.        
  20.        
  21.         print ("Highest number that you can go for is, " + max);
  22.         print ("Lowest number that you can go for is, " + min);
  23.        
  24.         print ("Is your number above or under " + guess + "?");
  25.         print ("Press up arrow for Above, Down arrow for Under and return for equals.");
  26.     }
  27.     void NextGuess() {
  28.         guess = (min + max) / 2;
  29.         print ("Higher or lower than " + guess);
  30.     }
  31.     // Update is called once per frame
  32.     void Update () {
  33.         if (Input.GetKeyDown (KeyCode.UpArrow)) {
  34.             // print ("Above 500!");
  35.             min = guess;
  36.             NextGuess ();
  37.         } else if (Input.GetKeyDown (KeyCode.DownArrow)) {
  38.             //print ("Under 500!");
  39.             max = guess;
  40.             NextGuess();
  41.         } else if (Input.GetKeyDown (KeyCode.Return)){
  42.             print ("I got it! You lost!");
  43.             StartGame();
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement