moon_ark

Untitled

Jan 31st, 2013
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. #pragma strict
  2. var selection: int;
  3. function Start () {
  4. selection = 0;
  5. }
  6.  
  7. function Update ()
  8. {
  9.  
  10. if(Input.GetKeyDown(KeyCode.DownArrow))
  11. {
  12. selection++;
  13. }
  14. else if(Input.GetKeyDown(KeyCode.UpArrow))
  15. {
  16. selection--;
  17. }
  18. switch(selection)
  19. {
  20. case -1:
  21. selection = 2;
  22. break;
  23.  
  24. case 0:
  25. //new game highlighted
  26. if(Input.GetKeyDown(KeyCode.Space))
  27. {
  28. NewGame();
  29. }
  30. break;
  31.  
  32. case 1:
  33. //load game highlighted
  34. if(Input.GetKeyDown(KeyCode.Space))
  35. {
  36. LoadGame();
  37. }
  38. break;
  39.  
  40. case 2:
  41. //exit game highlighted
  42. if(Input.GetKeyDown(KeyCode.Space))
  43. {
  44. ExitGame();
  45. }
  46. break;
  47.  
  48. case 3:
  49. selection = 0;
  50. break;
  51.  
  52. }
  53. }
  54.  
  55. function OnGUI()
  56. {
  57.  
  58.  
  59. if(selection == 0)
  60. {
  61. GUI.color = Color.yellow;
  62. GUI.Button(Rect(5,5,100,30),"New Game");
  63. GUI.color = Color.white;
  64. GUI.Button(Rect(5,35,100,30),"Load Game");
  65. GUI.color = Color.white;
  66. GUI.Button(Rect(5,65,100,30),"Exit");
  67.  
  68. }
  69. else if (selection == 1)
  70. {
  71. GUI.color = Color.white;
  72. GUI.Button(Rect(5,5,100,30),"New Game");
  73. GUI.color = Color.yellow;
  74. GUI.Button(Rect(5,35,100,30),"Load Game");
  75. GUI.color = Color.white;
  76. GUI.Button(Rect(5,65,100,30),"Exit");
  77.  
  78.  
  79. }
  80. else if(selection == 2)
  81. {
  82.  
  83. GUI.color = Color.white;
  84. GUI.Button(Rect(5,5,100,30),"New Game");
  85. GUI.color = Color.white;
  86. GUI.Button(Rect(5,35,100,30),"Load Game");
  87. GUI.color = Color.yellow;
  88. GUI.Button(Rect(5,65,100,30),"Exit");
  89.  
  90. }
  91.  
  92. }
  93.  
  94.  
  95. function NewGame()
  96. {
  97. //new game
  98. Debug.Log("New Game");
  99. }
  100.  
  101. function LoadGame()
  102. {
  103. //load game
  104. Debug.Log("Load Game");
  105. }
  106.  
  107. function ExitGame()
  108. {
  109. //exit game
  110. Debug.Log("Exit Game");
  111. }
Advertisement
Add Comment
Please, Sign In to add comment