Advertisement
junebug217

Escape - Unity Game

Mar 14th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 19.13 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4.  
  5. public class TextController : MonoBehaviour {
  6.  
  7.     public Text text;
  8.     private enum States { freedom, look_around, room, stand, wake,
  9.                         crack_0, door_0, glass_shard_0, hand_0, mirror_0, sheets_0, smashed_mirror_0, ripped_sheets_0, walls_0, wire_0,
  10.                         crack_1, door_1, ripped_sheets_1,
  11.                         door_2};
  12.     private States myState;
  13.     private bool sheets_ripped, hands_wrapped, crack_investigated, have_shard, have_wire;
  14.  
  15.     // Use this for initialization
  16.     void Start () {
  17.         myState = States.wake;
  18.         sheets_ripped = false;
  19.         hands_wrapped = false;
  20.         crack_investigated = false;
  21.         have_shard = false;
  22.         have_wire = false;
  23.     }
  24.    
  25.     // Update is called once per frame
  26.     void Update () {
  27.         print ("Current state: " + myState);
  28.        
  29.         if  (myState == States.wake)            { state_wake(); }
  30.         else if (myState == States.look_around)         { state_look_around(); }
  31.         else if (myState == States.stand)           { state_stand(); }
  32.         else if (myState == States.room)            { state_room(); }
  33.         else if (myState == States.mirror_0)            { state_mirror_0(); }
  34.         else if (myState == States.sheets_0)            { state_sheets_0(); }
  35.         else if (myState == States.walls_0)             { state_walls_0(); }
  36.         else if (myState == States.crack_0)             { state_crack_0(); }
  37.         else if (myState == States.door_0)          { state_door_0(); }
  38.         else if (myState == States.ripped_sheets_0)         {state_ripped_sheets_0(); }
  39.         else if (myState == States.ripped_sheets_1)         {state_ripped_sheets_1(); }
  40.         else if (myState == States.hand_0)          { state_hand_0(); }
  41.         else if (myState == States.door_1)          { state_door_1(); }
  42.         else if (myState == States.smashed_mirror_0)        { state_smashed_mirror_0(); }
  43.         else if (myState == States.glass_shard_0)       { state_glass_shard_0(); }
  44.         else if (myState == States.crack_1)             { state_crack_1(); }
  45.         else if (myState == States.wire_0)          { state_wire_0(); }
  46.         else if (myState == States.door_2)          { state_door_2(); }
  47.         else if (myState == States.freedom)         { state_freedom(); }
  48.     }
  49.    
  50.     void state_wake () {
  51.         text.text = "Your eyes slowly open. Everything is blurry for a moment, but it all begins to come into focus after a few seconds. " +
  52.                     "It’s dark, but not completely. Light seems to be coming from a small hole in the ceiling of what appears to be a room." +
  53.                     "\n\n\"Hello? Is anyone there? Where am I?\"\n\n" +
  54.                     "Your questions are met with silence." +
  55.                     "\n\n Press L to look around";
  56.                    
  57.         if (Input.GetKeyDown(KeyCode.L))            { myState = States.look_around; }
  58.     }
  59.    
  60.     void state_look_around () {
  61.         text.text = "After a few minutes, your eyes finally adjust to the darkness. You make out the edges of what appear to be walls on either " +
  62.                     "side of you. On the wall across from you is what looks to be a wooden door. Hopefully, it’s the way out. There " +
  63.                     "seems to be something reflective on the wall to your left, possibly a mirror. Fortunately, the light from the hole in the ceiling is directed " +
  64.                     "at this object, which is helping to amplify what little bit of light there is.  The only other thing of interest in the room is some bundled up " +
  65.                     "sheets next to you." +
  66.                     "\n\n\"I have to find some way out of here.\"\n\n" +
  67.                     "Press S to stand-up";
  68.                    
  69.         if (Input.GetKeyDown(KeyCode.S))            { myState = States.stand; }
  70.     }
  71.    
  72.     void state_stand() {
  73.         text.text = "You put your hand against the wall for support as you try to stand. It’s smooth, as if it’s made of marble. “What kind of " +
  74.                     "room is -” Pain immediately shoots through your leg! You fall back to the ground, and instinctively reach down to feel for the source. " +
  75.                     "Something feels wet directly below your left kneecap. You touch it. More pain. You bring your fingers to your lips. Blood." +
  76.                     "\n\n\"What the hell happened?\"\n\n" +
  77.                     "You take a moment to regain your composure, prepare for the pain and attempt to stand once more. This time you’re successful. " +
  78.                     "It isn’t broken, which is good, but it’s still going to need some medical attention.\n\n" +
  79.                     "Press L to look at the mirror, P to pick up the sheets, E to examine the walls, O to open the door.";
  80.                    
  81.         if  (Input.GetKeyDown(KeyCode.L))           { myState = States.mirror_0; }
  82.         else if (Input.GetKeyDown(KeyCode.P))           { myState = States.sheets_0; }
  83.         else if (Input.GetKeyDown(KeyCode.E))           { myState = States.walls_0; }
  84.         else if (Input.GetKeyDown(KeyCode.O))           { myState = States.door_0; }
  85.     }
  86.    
  87.     void state_room() {
  88.         if (!crack_investigated) {
  89.             text.text = "You return to the middle of the room. You decide to keep searching around for anything that can possibly help you escape.\n\n" +
  90.                         "Press L to look at the mirror, P to pick up the sheets, E to examine the walls, O to open the door.";
  91.                        
  92.             if  (Input.GetKeyDown(KeyCode.L))       { myState = States.mirror_0; }
  93.             else if (Input.GetKeyDown(KeyCode.P))       { myState = States.sheets_0; }
  94.             else if (Input.GetKeyDown(KeyCode.E))       { myState = States.walls_0; }
  95.             else if (Input.GetKeyDown(KeyCode.O))       { myState = States.door_0; }
  96.         }
  97.         else if(crack_investigated) {
  98.             text.text = "You return to the middle of the room. You decide to keep searching around for anything that can possibly help you escape.\n\n" +
  99.                         "Press L to look at the mirror, P to pick up the sheets, E to examine the crack in the wall, O to open the door.";
  100.            
  101.             if  (Input.GetKeyDown(KeyCode.L))       { myState = States.mirror_0; }
  102.             else if (Input.GetKeyDown(KeyCode.P))       { myState = States.sheets_0; }
  103.             else if (Input.GetKeyDown(KeyCode.E))       { myState = States.crack_0; }
  104.             else if (Input.GetKeyDown(KeyCode.O))       { myState = States.door_0; }
  105.         }
  106.     }
  107.    
  108.     void state_mirror_0 () {
  109.         text.text = "The light from the ceiling bounces off the mirror, illuminating your face. The reflection in the mirror shows the image of a " +
  110.                     "person that’s seen better times. Your hair is caked with dirt, your lip is busted, and it looks like you haven’t slept for days. " +
  111.                     "The worst part is that you have no clue why you look this way. Whatever the reason, all that matters at the moment is getting out of " +
  112.                     "this room.\n\n" +
  113.                     "Press R to return to searching the room.";
  114.        
  115.         if (Input.GetKeyDown(KeyCode.R))            { myState = States.room; }
  116.     }
  117.    
  118.     void state_sheets_0 () {
  119.         text.text = "The sheets feel as if they’ve been recently cleaned. The smell they put off reminds you of the time you were in the hospital.\n\n" +
  120.                     "\"Why would they be this clean?\"\n\n" +
  121.                     "Press T to tear off a strip of fabric, or R to return to searching the room.";
  122.        
  123.         if  (Input.GetKeyDown(KeyCode.T))           { myState = States.ripped_sheets_0; }
  124.         else if (Input.GetKeyDown(KeyCode.R))           { myState = States.room; }
  125.        
  126.     }  
  127.    
  128.     void state_walls_0 () {
  129.         text.text = "Hoping to find some sort of switch or button, you begin to feel your way around the perimeter of the room, meticulously checking for " +
  130.                     "anything out of the ordinary. Pain is coursing through your leg, but your resolve is stronger. You are a few feet from the door when you " +
  131.                     "notice a long, narrow crack in the wall. Your hopes lift a little. Maybe this can help you escape the room.\n\n" +
  132.                     "Press I to investigate the crack in the wall, or R to return to searching the room.";
  133.        
  134.        
  135.         if  (Input.GetKeyDown(KeyCode.I))           { myState = States.crack_0; }
  136.         else if (Input.GetKeyDown(KeyCode.R)) {
  137.             if (!sheets_ripped)                     { myState = States.room; }
  138.             else if (sheets_ripped)                 { myState = States.ripped_sheets_1; }
  139.         }
  140.     }
  141.    
  142.     void state_crack_0 () {
  143.         if (!have_shard) {
  144.             text.text = "You reach into the fissure. There’s something in it, but it’s stuck. Maybe you can find something to help pry it loose.\n\n" +
  145.                         "Press R to return to searching the room.";
  146.            
  147.             if (Input.GetKeyDown(KeyCode.R)) {
  148.                 if (!sheets_ripped)             { myState = States.room; }
  149.                 else if (sheets_ripped)         { myState = States.ripped_sheets_1; }
  150.             }
  151.         }
  152.         else if (have_shard && !crack_investigated) {
  153.             text.text = "You reach into the fissure. There’s something in it, but it’s stuck. You're pretty sure that the shard is a perfect fit for the crack, " +
  154.                         "and that you might just be able to pry out whatever is stuck of it.\n\n" +
  155.                         "Press P to pry the object in the crack loose, or R to return to searching the room.";
  156.            
  157.             if  (Input.GetKeyDown(KeyCode.R))       { myState = States.ripped_sheets_1; }
  158.             else if (Input.GetKeyDown(KeyCode.P))       { myState = States.crack_1; }
  159.         }
  160.         else if (have_shard && crack_investigated) {
  161.             text.text = "You're pretty sure that the shard is a perfect fit for the crack, and that you might just be able to pry out whatever is stuck " +
  162.                         "of it.\n\n" +
  163.                         "Press P to pry the object in the crack loose, or R to return to searching the room.";
  164.            
  165.             if  (Input.GetKeyDown(KeyCode.R))       { myState = States.ripped_sheets_1; }
  166.             else if (Input.GetKeyDown(KeyCode.P))       { myState = States.crack_1; }
  167.         }
  168.         crack_investigated = true;
  169.     }
  170.    
  171.     void state_door_0 () {
  172.         text.text = "You limp over to the wooden door. You turn the knob. No such luck. If only it was that easy. Below the knob is a keyhole.\n\n" +
  173.                     "\"If I had the right stuff, I could probably pick the lock.\"\n\n" +
  174.                     "Press R to return to searching the room.";
  175.        
  176.         if (Input.GetKeyDown(KeyCode.R)) {
  177.             if (!sheets_ripped)                     { myState = States.room; }
  178.             else if (sheets_ripped)                 { myState = States.ripped_sheets_1; }
  179.         }
  180.     }
  181.    
  182.     void state_ripped_sheets_0 () {
  183.         if (!crack_investigated) {
  184.             text.text = "You tear a strip of fabric off of the sheets and throw the rest of the cloth back on the ground. You’re not really sure what good " +
  185.                         "this will be to you, but maybe somehow it’ll be of help.\n\n" +
  186.                         "Press E to examine the walls, W to wrap your hands with the fabric, or O to open the door.";
  187.            
  188.             if  (Input.GetKeyDown(KeyCode.E))       { myState = States.walls_0; }
  189.             else if (Input.GetKeyDown(KeyCode.W))       { myState = States.hand_0; }
  190.             else if (Input.GetKeyDown(KeyCode.O))       { myState = States.door_0; }
  191.             else if (Input.GetKeyDown(KeyCode.H))       { myState = States.door_1; }
  192.         }
  193.         else if (crack_investigated) {
  194.             text.text = "You tear a strip of fabric off of the sheets and throw the rest of the cloth back on the ground. You’re not really sure what good " +
  195.                         "this will be to you, but maybe somehow it’ll be of help.\n\n" +
  196.                         "Press E to examine the crack in the wall, W to wrap your hands with the fabric, or O to open the door.";
  197.            
  198.             if  (Input.GetKeyDown(KeyCode.E))       { myState = States.crack_0; }
  199.             else if (Input.GetKeyDown(KeyCode.W))       { myState = States.hand_0; }
  200.             else if (Input.GetKeyDown(KeyCode.O))       { myState = States.door_0; }
  201.             else if (Input.GetKeyDown(KeyCode.H))       { myState = States.door_1; }
  202.         }
  203.        
  204.         sheets_ripped = true;
  205.     }
  206.    
  207.     void state_ripped_sheets_1 () {
  208.         if (crack_investigated && !hands_wrapped) {
  209.             text.text = "You're still not sure how this strip of fabric will help, but you figure that if you keep looking around the room it'll become more clear.\n\n" +
  210.                         "Press E to examine the crack in the wall, W to wrap your hands, or O to open the door.";
  211.            
  212.             if  (Input.GetKeyDown(KeyCode.E))       { myState = States.crack_0; }
  213.             else if (Input.GetKeyDown(KeyCode.W))       { myState = States.hand_0; }
  214.             else if (Input.GetKeyDown(KeyCode.O))       { myState = States.door_0; }
  215.         }
  216.         else if (crack_investigated && hands_wrapped && !have_shard) {
  217.             text.text = "You've wrapped your hands with the fabric, but you're not sure how that's going to help at the moment. Maybe if you keep looking around.\n\n" +
  218.                         "Press E to examine the crack in the walls, H to hit the door, or P to punch the mirror, or O to open the door.";
  219.            
  220.             if  (Input.GetKeyDown(KeyCode.E))       { myState = States.crack_0; }
  221.             else if (Input.GetKeyDown(KeyCode.H))       { myState = States.door_1; }
  222.             else if (Input.GetKeyDown(KeyCode.P))       { myState = States.smashed_mirror_0; }
  223.             else if (Input.GetKeyDown(KeyCode.O))       { myState = States.door_0; }
  224.         }
  225.         else if (!crack_investigated && hands_wrapped && !have_shard) {
  226.             text.text = "You've wrapped your hands with the fabric, but you're not sure how that's going to help at the moment. Maybe if you keep looking around.\n\n" +
  227.                         "Press E to examine the walls, H to hit the door, P to punch the mirror, or O to open the door.";
  228.                        
  229.             if  (Input.GetKeyDown(KeyCode.E))       { myState = States.walls_0; }
  230.             else if (Input.GetKeyDown(KeyCode.H))       { myState = States.door_1; }
  231.             else if (Input.GetKeyDown(KeyCode.P))       { myState = States.smashed_mirror_0; }
  232.             else if (Input.GetKeyDown(KeyCode.O))       { myState = States.door_0; }
  233.         }
  234.         else if (!crack_investigated && !hands_wrapped) {
  235.             text.text = "You're still not sure how this strip of fabric will help, but you figure that if you keep looking around the room it'll become more clear.\n\n" +
  236.                         "Press E to examine the walls, W to wrap your hands, or O to open the door.";
  237.            
  238.             if  (Input.GetKeyDown(KeyCode.E))       { myState = States.walls_0; }
  239.             else if (Input.GetKeyDown(KeyCode.W))       { myState = States.hand_0; }
  240.             else if (Input.GetKeyDown(KeyCode.O))       { myState = States.door_0; }
  241.         }
  242.         else if (!crack_investigated && have_shard) {
  243.             text.text = "You've finished your regime of punching things for a while, but you still have this shard of glass. You decide to keep searching the room for " +
  244.                         "someway to use it.\n\n" +
  245.                         "Press E to examine the walls, or O to open the door.";
  246.            
  247.             if  (Input.GetKeyDown(KeyCode.E))       { myState = States.walls_0; }
  248.             else if (Input.GetKeyDown(KeyCode.O))       { myState = States.door_0; }
  249.         }
  250.         else if (crack_investigated && have_shard && !have_wire) {
  251.             text.text = "You've finished your regime of punching things for a while, but you still have this shard of glass. You decide to keep searching the room for " +
  252.                         "someway to use it.\n\n" +
  253.                         "Press E to examine the crack in the wall again, or O to open the door.";
  254.                        
  255.             if  (Input.GetKeyDown (KeyCode.E))      { myState = States.crack_0; }
  256.             else if (Input.GetKeyDown(KeyCode.O))       { myState = States.door_0; }
  257.         }
  258.         else if (crack_investigated && hands_wrapped && have_shard && have_wire) {
  259.             text.text = "You have a piece of wire that can be bent and twisted to whatever shape you need it. You know that this will definitely help you out somehow. " +
  260.                         "You decide to keep searching around the room to see if you can use it to help you escape.\n\n" +
  261.                         "Press O to open the door.";
  262.                        
  263.             if (Input.GetKeyDown(KeyCode.O))        { myState = States.door_2; }
  264.         }
  265.     }
  266.    
  267.     void state_hand_0 () {
  268.         text.text = "You slowly wrap the cloth around your knuckles. There are at least two objects in the room in which brute force may be of some use: the mirror and the door. " +
  269.                     "Kicking either of these is obviously not going to happen, so fists it is.\n\n" +
  270.                     "H to hit the door, P to punch the mirror, or R to return to searching the room.";
  271.                    
  272.         if  (Input.GetKeyDown(KeyCode.H))           { myState = States.door_1; }
  273.         else if (Input.GetKeyDown (KeyCode.P))          { myState = States.smashed_mirror_0; }
  274.         else if (Input.GetKeyDown(KeyCode.R))           { myState = States.ripped_sheets_1; }
  275.        
  276.         hands_wrapped = true;
  277.     }
  278.    
  279.     void state_door_1 () {
  280.         text.text = "\"Maybe it’s a lot weaker than it looks.\"\n\n" +
  281.                     "You steady yourself and, using all the strength you can muster, shoot your fist towards the door. The door doesn’t even budge, but now your fist is raging with pain. " +
  282.                     "You want to think it was worth a shot, but you’re not so sure it was.\n\n" +
  283.                     "Press R to return to searching the room.";
  284.                    
  285.         if (Input.GetKeyDown(KeyCode.R))            { myState = States.ripped_sheets_1; }
  286.     }
  287.    
  288.     void state_smashed_mirror_0 () {
  289.         text.text = "You head over to the mirror. You check to make sure the cloth is completely covering your knuckles before punching the mirror with everything you've got. The mirror shatters, " +
  290.                     "causing the light to refract in all different directions. Your fist flares with pain, and your knuckles are bleeding a little bit. However, it looks like there a few useable shards " +
  291.                     "of glass that might come in handy.\n\n" +
  292.                     "Press P to pick up a shard of glass.";
  293.                    
  294.         if (Input.GetKeyDown(KeyCode.P))            { myState = States.glass_shard_0; }
  295.     }  
  296.    
  297.     void state_glass_shard_0 () {
  298.         text.text = "Carefully, you pick up a small, thin glass shard. You’re not sure how you’ll be able to use it right at the moment, but maybe you can pry something loose with it.\n\n" +
  299.                     "Press R to return to searching the room.";
  300.        
  301.         if (Input.GetKeyDown(KeyCode.R))            { myState = States.ripped_sheets_1; }
  302.        
  303.         have_shard = true;
  304.     }
  305.    
  306.     void state_crack_1 () {
  307.         text.text = "You carefully begin to wiggle the glass shard into the crack in the wall. With some force, you feel the object jolt free and hear it hit the ground. The glass shard is broken, but " +
  308.                     "it served it's purpose well.\n\n" +
  309.                     "Press P to pick up the object.";
  310.                    
  311.         if (Input.GetKeyDown(KeyCode.P))            { myState = States.wire_0; }
  312.     }
  313.    
  314.     void state_wire_0 () {
  315.         text.text = "You pick up the object and bring it close to your face. It is a piece of wire. This will probably come in very handy.\n\n" +
  316.                     "Press R to return to searching the room.";
  317.        
  318.         if (Input.GetKeyDown(KeyCode.R))            { myState = States.ripped_sheets_1; }
  319.        
  320.         have_wire = true;
  321.    
  322.     }
  323.    
  324.     void state_door_2 () {
  325.         text.text = "Remembering the lock on the door, you twist the wire into a makeshift lockpick. You insert it into the lock and begin raking it " +
  326.                     "back and forth across the small pins within, while turning the handle at the same time. Afte what feels like forever, you hear a \'click\' " +
  327.                     " and the knob turns over. Excitement rushes over your entire body.\n\n" +
  328.                     "Press O to open the door.";
  329.                    
  330.         if (Input.GetKeyDown(KeyCode.O))            { myState = States.freedom; }  
  331.     }
  332.    
  333.     void state_freedom () {
  334.         text.text = "You hurridly push open the door and run through into a completely white room. The door slams closed behind you. You can't see a thing. Your eyes take several minutes to " +
  335.                     "adjust to the brightness of the room. The room is completely empty, except for a small hole in the floor, in the very middle of the room. " +
  336.                     "You crouch down on the floor and peak through the hole. Within, you see a room, much like the one you just exited. In fact, it looks exactly " +
  337.                     "the same. You notice something move, and see a figure start to move. It's a man. \"Hello? Is anyone there? Where am I?\", you hear him ask out loud. " +
  338.                     "You try to answer him, but he doesn't seem to hear you. You watch for some time as he goes through the exact same movements as you did. He rips the sheets, " +
  339.                     "breaks the mirror, and uses the piece of glass to obtain the wire in the wall. He begins to pick the lock. You immediately begin to hear the door knob behind " +
  340.                     "you jiggle.\n\n" +
  341.                     "\"That's not possible!\"\n\n" +
  342.                     "You hear the \'click\' and watch as the man opens the door. The ground below you opens up and you begin to fall. You hit the ground and black out. Darkness.\n\n" +
  343.                     "Press W to wake up.";
  344.                    
  345.         if (Input.GetKeyDown (KeyCode.W))           { myState = States.wake; }         
  346.     }
  347.        
  348. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement