Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 KB | None | 0 0
  1. public class NumWiz_UI_2 : MonoBehaviour
  2.  
  3. {
  4.  
  5.     int max = 1000;
  6.  
  7.     int min = 1;
  8.  
  9.     int guess = 500;
  10.  
  11.     public void NextGuess()
  12.  
  13.     {
  14.  
  15.         guess = (min + max) / 2;
  16.  
  17.         Debug.Log(guess);
  18.  
  19.     }
  20.  
  21.     // Start is called before the first frame update
  22.  
  23.     void Start()
  24.  
  25.     {
  26.  
  27.         Debug.Log("Welcome to Number Wizard");
  28.  
  29.         Debug.Log("Pick a number from 1-1000");
  30.  
  31.         Debug.Log("Don't tell me your number because I can't hear you and you can't hear me, plus your probably crazy");
  32.  
  33.         Debug.Log("Oh and before I forget here are the controls:");
  34.  
  35.         Debug.Log("up arrow means the number is higher, down arrow means the Number is lower, and enter means that I got it right");
  36.  
  37.         Debug.Log("Is your number 500");
  38.  
  39.     }
  40.  
  41.  
  42.  
  43.     // Update is called once per frame
  44.  
  45.     void Update()
  46.  
  47.     {
  48.  
  49.         if (Input.GetKeyDown(KeyCode.UpArrow))
  50.         {
  51.  
  52.             Debug.Log("Up arrow was pressed");
  53.  
  54.             //changed!!
  55.             min = guess;
  56.             //old guess = min;
  57.  
  58.  
  59.             NextGuess();
  60.  
  61.         }
  62.         else if (Input.GetKeyDown(KeyCode.DownArrow))
  63.         {
  64.  
  65.             Debug.Log("Down arrow key was pressed");
  66.  
  67.             //changed!!
  68.             max = guess;
  69.             //old guess = max;
  70.  
  71.             NextGuess();
  72.  
  73.         }
  74.         else if (Input.GetKeyDown(KeyCode.Return))
  75.         {
  76.  
  77.             Debug.Log("Yeah I got it right :)");
  78.  
  79.         }
  80.  
  81.     }
  82.  
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement