Advertisement
Guest User

hackerscript

a guest
Apr 8th, 2019
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.89 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class Hacker : MonoBehaviour {
  4.  
  5. // Game Configuration Data
  6. const string menuHint = "You may type menu at any time.";
  7. string[] level1Passwords = { "books", "aisle", "shelf", "password", "font", "borrow" };
  8. string[] level2Passwords = { "worm", "duck", "frog", "Roxas", "cheese", "horny" };
  9. string[] level3Passwords = { "labyrinth", "flamingo", "hippo", "jackelope", "santa" };
  10.  
  11. //Game State
  12. int level;
  13.  
  14. string password;
  15. string password2;
  16. string password3;
  17.  
  18. enum Screen { MainMenu, Password, Win };
  19. Screen currentScreen;
  20.  
  21.  
  22. // Use this for initialization
  23. void Start()
  24. {
  25. ShowMainMenu();
  26.  
  27. }
  28.  
  29. void ShowMainMenu()
  30. {
  31. currentScreen = Screen.MainMenu;
  32. Terminal.ClearScreen();
  33. Terminal.WriteLine("Greetings - Time to fuck shit up.");
  34. Terminal.WriteLine("What you wanna hack into?");
  35. Terminal.WriteLine("Press 1 for the local library");
  36. Terminal.WriteLine("Press 2 for the police station");
  37. Terminal.WriteLine("Press 3 for NASA");
  38. Terminal.WriteLine("Enter your selection:");
  39. }
  40.  
  41. void OnUserInput(string input)
  42. {
  43.  
  44. if (input == "menu") // we can always go direct to main menu
  45. {
  46. Terminal.ClearScreen();
  47. ShowMainMenu();
  48. }
  49. else if (input == "quit" || input == "close" || input == "exit")
  50. {
  51. Terminal.WriteLine("If on the web close the tab.");
  52. Application.Quit();
  53. }
  54. else if (currentScreen == Screen.MainMenu)
  55. {
  56. RunMainMenu(input);
  57. }
  58. else if (currentScreen == Screen.Password)
  59. {
  60. CheckPassword(input);
  61. }
  62.  
  63.  
  64. }
  65.  
  66. void RunMainMenu(string input)
  67. {
  68. bool isValidLevelNumber = (input == "1" || input == "2" || input == "3");
  69. if (isValidLevelNumber)
  70. {
  71. level = int.Parse(input);
  72. AskForPassword();
  73. }
  74.  
  75. else if (input == "marco") // easter egg
  76. {
  77. Terminal.WriteLine("Polo!");
  78. }
  79. else if (input == "007") // easter egg
  80. {
  81. Terminal.WriteLine("Welcome home, Mr. Bond.");
  82. }
  83. else
  84. {
  85. Terminal.WriteLine("Choose a valid level!");
  86. Terminal.WriteLine(menuHint);
  87. }
  88. }
  89.  
  90. void AskForPassword()
  91. {
  92.  
  93. currentScreen = Screen.Password;
  94. Terminal.ClearScreen();
  95. SetRandomPassword();
  96. Terminal.WriteLine("Enter your password, hint: " + password.Anagram());
  97. Terminal.WriteLine(menuHint);
  98. }
  99.  
  100. void SetRandomPassword()
  101. {
  102. switch (level)
  103. {
  104. case 1:
  105. password = level1Passwords[Random.Range(0, level1Passwords.Length)];
  106. break;
  107. case 2:
  108. password = level2Passwords[Random.Range(0, level2Passwords.Length)];
  109. password2 = level2Passwords[Random.Range(0, level2Passwords.Length)];
  110. break;
  111. case 3:
  112. password = level3Passwords[Random.Range(0, level3Passwords.Length)];
  113. password2 = level3Passwords[Random.Range(0, level3Passwords.Length)];
  114. password3 = level3Passwords[Random.Range(0, level3Passwords.Length)];
  115. break;
  116. default:
  117. Debug.LogError("Invalid level number");
  118. break;
  119. }
  120. }
  121.  
  122. void CheckPassword(string input)
  123. {
  124. if (input == "1")
  125. {
  126. if (input == password)
  127. {
  128. DisplayWinScreen();
  129. }
  130. else
  131. {
  132. AskForPassword();
  133. }
  134. }
  135. else if (input == "2")
  136. {
  137. if (input == password)
  138. {
  139. Terminal.WriteLine("Now for the second password. Hint: " + password2.Anagram());
  140. if (input == password2)
  141. {
  142. DisplayWinScreen();
  143. }
  144. else
  145. {
  146. AskForPassword();
  147. }
  148. }
  149. }
  150. else if (input == "3")
  151. {
  152. if (input == password)
  153. {
  154. Terminal.WriteLine("Now for the second password. Hint: " + password2.Anagram());
  155. if (input == password2)
  156. {
  157. Terminal.WriteLine("Now for the third password. Hint: " + password3.Anagram());
  158. if (input == password3)
  159. {
  160. DisplayWinScreen();
  161. }
  162. else
  163. {
  164. AskForPassword();
  165. }
  166. }
  167. }
  168. }
  169. }
  170.  
  171. void DisplayWinScreen()
  172. {
  173. currentScreen = Screen.Win;
  174. Terminal.ClearScreen();
  175. ShowLevelReward();
  176. Terminal.WriteLine(menuHint);
  177. }
  178.  
  179. void ShowLevelReward()
  180. {
  181. switch (level)
  182. {
  183. case 1:
  184. Terminal.WriteLine("Have a book...");
  185. Terminal.WriteLine(@"
  186. ______
  187. / //
  188. / //
  189. /_____ //
  190. (______(/
  191. "
  192. );
  193. Terminal.WriteLine("Play again for a greater challenge.");
  194. break;
  195. case 2:
  196. Terminal.WriteLine("Have a lockpick!");
  197. Terminal.WriteLine("Play again for a greater challenge.");
  198. Terminal.WriteLine(@"
  199.  
  200. "
  201. );
  202. break;
  203. case 3:
  204. Terminal.WriteLine("Have a space ship!");
  205. Terminal.WriteLine(@"
  206. ^
  207. / \
  208. | _ |
  209. | { } |
  210. | omo |
  211. <| |>
  212. < >
  213. "
  214. );
  215. break;
  216.  
  217. }
  218.  
  219. }
  220. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement