Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.86 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4. int (x = 0);
  5. int (clothes = 0);
  6. public class TextController : MonoBehaviour {
  7. public Text text;
  8. private enum States {cell, mirror, lock_0, sheets_0, cell_mirror, lock_1, sheets_1, corridor, lock_open, freedom, cell_think, up_stairs, cafeteria, showers, findkey, wardens, basement, guard, exit_0, exit_1, end_0, end_1}
  9. private States myState;
  10. // Use this for initialization
  11. void Start () {
  12. myState = States.cell;
  13. }
  14. // Update is called once per frame
  15. void Update () {
  16. print(myState);
  17. if (myState == States.cell) {state_cell();}
  18. else if (myState == States.sheets_0) {state_sheets_0();}
  19. else if (myState == States.lock_0) {state_lock_0();}
  20. else if (myState == States.mirror) {state_mirror();}
  21. else if (myState == States.lock_1) {state_lock_1();}
  22. else if (myState == States.cell_mirror) {state_cell_mirror();}
  23. else if (myState == States.lock_open) {state_lock_open();}
  24. else if (myState == States.corridor) {state_corridor();}
  25. else if (myState == States.cell_think) {state_cell_think();}
  26. else if (myState == States.up_stairs) {state_up_stairs();}
  27. else if (myState == States.cafeteria) {state_cafeteria();}
  28. else if (myState == States.showers) {state_showers();}
  29. else if (myState == States.findkey) {state_findkey();}
  30. else if (myState == States.wardens) {state_wardens();}
  31. else if (myState == States.basement) {state_basement();}
  32. else if (myState == States.guard) {state_guard();}
  33. else if (myState == States.exit_1) {state_exit_1();}
  34. else if (myState == States.exit_0) {state_exit_0();}
  35. else if (myState == States.end_0) {state_end_0();}
  36. else if (myState == States.end_1) {state_end_1();}
  37. }
  38.  
  39. void state_cell() {
  40. text.text = "You wake up to find yourself stuck in an abandoned prison " +
  41. "cell that is locked from the outside with sheets on the bed " +
  42. "and a mirror on the wall.\n\n" + "Press 'S' to view sheets\n\n" +
  43. "Press 'M' to view mirror\n\n" + "Press 'L' to view lock.";
  44. if (Input.GetKeyDown(KeyCode.S)) {myState = States.sheets_0;}
  45. else if (Input.GetKeyDown(KeyCode.M)) {myState = States.mirror;}
  46. else if (Input.GetKeyDown(KeyCode.L)) {myState = States.lock_0;}
  47. }
  48. void state_sheets_0() {
  49. text.text = "These sheets are freshly changed, very strange indeed. There " +
  50. "must be someone here still. The real question is, why am I here? " +
  51. "Lets continue searching the cell. \n\n" +
  52. "Press 'R' to return to roaming the cell";
  53. if (Input.GetKeyDown(KeyCode.R)) {myState = States.cell;}
  54. }
  55. void state_mirror() {
  56. text.text = "You look at yourself in the mirror and see an insane, unshaven and " +
  57. "strangly unfamiliar face. You wonder, 'Who am I?' then 'Just brush it " +
  58. "off and keep looking.' \n\n" +
  59. "Press 'R' to continue roaming the cell";
  60. if (Input.GetKeyDown(KeyCode.R)) {myState = States.cell;}
  61. }
  62. void state_lock_0() {
  63. text.text = "The door is shut tightly with an amazingly strong lock. How about " +
  64. "we keep looking for something to open it.\n\n" +
  65. "Press 'R' to continue roaming the cell";
  66. if (Input.GetKeyDown(KeyCode.R)) {myState = States.cell_think;}
  67. }
  68. void state_lock_1() {
  69. text.text = "The door is shut tightly with an amazingly strong lock. How about " +
  70. "we keep looking for something to open it.\n\n" +
  71. "Press 'M' to go back to mirror\n\n" + "Press 'R' to continue searching";
  72. if (Input.GetKeyDown(KeyCode.R)) {myState = States.cell;}
  73. else if (Input.GetKeyDown(KeyCode.M)) {myState = States.cell_mirror;}
  74. }
  75. void state_cell_mirror() {
  76. text.text = "After realizing you could break the glass to open the lock, you have a choice to either " +
  77. "break the glass with your fist and risk breaking it, or sit and wait for someone to come.\n\n" +
  78. "Press 'T' to break the glass and go to the lock\n\n" + "Press 'M' to sit and wait";
  79. if (Input.GetKeyDown(KeyCode.T)) {myState = States.lock_open;}
  80. else if (Input.GetKeyDown(KeyCode.M)) {myState = States.corridor;}
  81. }
  82. void state_lock_open() {
  83. text.text = "You take the piece of broken glass over to the lock.\n\n" +
  84. "Press 'O' to open the lock with the glass\n\n" +
  85. "Press 'R' to roam the cell";
  86. if (Input.GetKeyDown(KeyCode.O)) {myState = States.corridor;}
  87. else if (Input.GetKeyDown(KeyCode.R)) {myState = States.cell;}
  88. }
  89. void state_cell_think() {
  90. text.text = "After seeing that mirror, you wonder if maybe it can be used on the lock somehow. Lets try " +
  91. "going back to the mirror. \n\n" +
  92. "Press 'M' to go back to the mirror";
  93. if (Input.GetKeyDown(KeyCode.M)) {myState = States.cell_mirror;}
  94. }
  95. void state_corridor() {
  96. text.text = "One you have exitted the cell, you are immediatly forced to make another decision. \n\n" +
  97. "Press 'LeftArrow' to go to the stairs towards the left \n\n Press 'RightArrow' to go towards " +
  98. "the cafeteria\n\n Press 'UpArrow' to go towards the showers";
  99. if (Input.GetKeyDown(KeyCode.LeftArrow)) {myState = States.up_stairs;}
  100. else if (Input.GetKeyDown(KeyCode.RightArrow)) {myState = States.cafeteria;}
  101. else if (Input.GetKeyDown(KeyCode.UpArrow)) {myState = States.showers;}
  102. }
  103. void state_up_stairs() {
  104. if (x == 0) {
  105. text.text = "You come to a flight of stairs and go up them, all that is at the top is a janitor's closet " +
  106. "that is locked.\n\n Press 'DownArrow' to go back";
  107. if (Input.GetKeyDown(KeyCode.DownArrow)) {myState = States.corridor;}
  108. }
  109. else if (x == 1) {
  110. text.text = "You can open up the janitor's closet with the key and you put on the guard clothing.";
  111. int clothes = (clothes + 1);
  112. }
  113. }
  114. void state_cafeteria() {
  115. text.text = "You enter the cafeteria and see nothing but old food trays and garbage all over. " +
  116. "Possibly something in the garbage, most likely not. There are two doors that " +
  117. "leads to the Warden's office and hallway leading to 'who knows where'.\n\n" +
  118. "Press 'C' to check the garbage\n\n Press 'W' to go to the Warden's office\n\n Press 'H' to go to the hallway";
  119. if (Input.GetKeyDown(KeyCode.C)) {
  120. myState = States.findkey;
  121. }
  122. else if (Input.GetKeyDown(KeyCode.W)) {
  123. myState = States.wardens;
  124. }
  125. else if (Input.GetKeyDown(KeyCode.H)) {
  126. myState = States.guard;
  127. }
  128. }
  129. void state_findkey() {
  130. text.text = "You have found a duplicated key, maybe it works for the janitor's closet.\n\n" +
  131. "Press 'R' to go back to the corridor";
  132. x = x + 1;
  133. if (Input.GetKeyDown(KeyCode.R)) {
  134. myState = States.corridor;
  135. }
  136. }
  137. void state_showers() {
  138. text.text = "Nothing in here but moldy showers.\n\n" +
  139. "Press 'R' to return to the corridor";
  140. if (Input.GetKeyDown(KeyCode.R)) {
  141. myState = States.corridor;
  142. }
  143. }
  144. void state_wardens() {
  145. text.text = "Nothing worth while in here.\n\n Press 'R' to return to corridor";
  146. if (Input.GetKeyDown(KeyCode.R)) {
  147. myState = States.corridor;
  148. }
  149. }
  150. void state_basement() {
  151. text.text = "You walk down the creeky stairs and almost trip over a rat scurrying around down there." +
  152. "You think to yourself, 'Seems like nobody has been down here in a long time.'" +
  153. "There is a little hole over in the corner behind the boxes. Maybe we should check it out.\n\n" +
  154. "Press 'C' to check it out";
  155. if (Input.GetKeyDown(KeyCode.C)) {
  156. myState = States.exit_0;
  157. }
  158. }
  159. void state_guard() {
  160. if (clothes == 0) {
  161. text.text = "You turn the corner of this old and moldy hallway. There is a guard sitting there, maybe if you had a " +
  162. "Guard's clothing you could get by just fine. \n\n Press 'C' to go back to the corridor";
  163. if (Input.GetKeyDown(KeyCode.C)) {
  164. myState = States.corridor;
  165. }
  166.  
  167. }
  168. else if (clothes == 1) {
  169. text.text = "There is a gaurd around the corner, because you have a guard's outfit you can get by him just fine.\n\n" +
  170. "Press 'Space' to continue";
  171. if (Input.GetKeyDown(KeyCode.Space)) {
  172. myState = States.exit_1;
  173. }
  174. }
  175.  
  176. }
  177. void state_exit_1() {
  178. text.text = "You walk by the Guard and give him a nod, after exitting the building you see lines of police cars " +
  179. "and SWAT trucks. Looks like you are not going to be getting out of this one. You are then put into handcuffs by a " +
  180. "police officer and thrown in the back of a SWAT truck. 'Maybe there was a better way to escape'.\n\n Press 'Space' to continue";
  181. if (Input.GetKeyDown(KeyCode.Space)) {
  182. myState = States.end_1;
  183. }
  184. }
  185. void state_exit_0() {
  186. text.text = "You exit the building through the tunnel in the wall. After running away from the building someone stops " +
  187. "you and says that they know you and have an apartment you can stay at.\n\n Press 'Space' to continue";
  188. if (Input.GetKeyDown(KeyCode.Space)) {
  189. myState = States.end_0;
  190. }
  191. }
  192. void state_end_0() {
  193. text.text = "You have won the game! Congradulations and thank you for playing my game. Hope you enjoyed!";
  194. }
  195. void state_end_1() {
  196. text.text = "You have gotten to the end of the game but you did not win. Maybe try again to win! ;) Hope you enjoyed!";
  197. }
  198. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement