Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class NumberWizard : MonoBehaviour {
  6.  
  7. int max;
  8. int min;
  9. int guess;
  10.  
  11. // Use this for initialization
  12. void Start ()
  13. {
  14. StartGame();
  15. }
  16.  
  17. void StartGame()
  18. {
  19. max = 1000;
  20. min = 1;
  21. guess = 500;
  22. Debug.Log("Hello Fuhrerbunker, Welcome to Number Wizard");
  23. Debug.Log("Please pick a number");
  24. Debug.Log("The highest number you may pick is: " + max);
  25. Debug.Log("The lowest number you may pick is: " + min);
  26. Debug.Log("Is your guess higher or lower than " + guess);
  27. Debug.Log("Push up = Higher, Push down = Lower, Push enter = Correct");
  28. max = max + 1;
  29. }
  30.  
  31. // Update is called once per frame
  32. void Update () {
  33. if (Input.GetKeyDown(KeyCode.UpArrow))
  34. {
  35. min = guess;
  36. NextGuess();
  37. }
  38. else if (Input.GetKeyDown(KeyCode.DownArrow))
  39. {
  40. max = guess;
  41. NextGuess();
  42. }
  43. else if (Input.GetKeyDown(KeyCode.Return))
  44. {
  45. Debug.Log("Correct");
  46. }
  47. }
  48.  
  49. void NextGuess()
  50. {
  51. guess = (max + min) / 2;
  52. Debug.Log("Is your guess higher or lower than " + guess);
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement