Advertisement
Guest User

Untitled

a guest
Dec 11th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class NumberWizard : MonoBehaviour
  4. {
  5. // Use this for initialization
  6. private int max;
  7. private int min;
  8. private int guess;
  9.  
  10. private void Start()
  11. {
  12. StartGame();
  13. }
  14.  
  15. void StartGame()
  16. {
  17. max = 1000;
  18. min = 1;
  19. guess = 500;
  20.  
  21. max = max + 1;
  22.  
  23. print("=========================");
  24. print("Welcome to Number Wizard!");
  25. print("Pick a number in your head, but dont tell me!");
  26.  
  27. print("The highest number you can pick is " + (max - 1));
  28. print("The lowest number you can pick is " + min);
  29.  
  30. print("Is the number higher or lower than " + guess);
  31. print("Up = higher, down = lower,return = equal");
  32.  
  33. }
  34.  
  35. void NextGuess()
  36. {
  37. guess = (max + min) / 2;
  38. print("Higher or lower than" + guess);
  39. print("Up = higher, down = lower,return = equal");
  40. }
  41.  
  42.  
  43. // Update is called once per frame
  44. private void Update()
  45. {
  46.  
  47. if (Input.GetKeyDown(KeyCode.UpArrow))
  48. {
  49. min = guess;
  50. NextGuess();
  51. }
  52.  
  53. else if (Input.GetKeyDown(KeyCode.DownArrow))
  54. {
  55. max = guess;
  56. NextGuess();
  57. }
  58.  
  59. else if (Input.GetKeyDown(KeyCode.Return)) print("I won!");
  60. StartGame();
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement