Guest User

Untitled

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