Advertisement
dreadpallex

The Cabin Source Code

Jun 1st, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 14.96 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4.  
  5. public class TextController : MonoBehaviour
  6. {
  7.    
  8.     public Text text;
  9.     private enum States
  10.     {Bedroom_0, Bedroom_1, Celler_2, Front_door, Push_Harder, Peak, Call_0, Window_0, Grabbed, Struggle, Call_1, Punch, Livingroom_0, Livingroom_1,Livingroom_2,Celler_1, Hide_0, Window_1, Run_0,
  11.         Dodge_0, Duck_0, Zigzag_0, Zigzag_1, Car_0, Glove, Sun_0,Sun_1,Body,Closet, End,
  12.     };
  13.     private States myState;
  14.    
  15.     // Use this for initialization
  16.     void Start()
  17.     {
  18.         myState = States.Livingroom_0;
  19.        
  20.     }
  21.    
  22.     // Update is called once per frame
  23.     void Update(){
  24.         print (myState);
  25.         if (myState == States.Bedroom_0)            {state_bedroom_0();}
  26.         else if (myState == States.Bedroom_1)       {state_Bedroom_1();}
  27.         else if (myState == States.Celler_1)        {state_Celler_1();}
  28.         else if (myState == States.Celler_2)        {state_Celler_2();}
  29.         else if (myState == States.Front_door)      {state_Front_door();}
  30.         else if (myState == States.Livingroom_0)    {state_Livingroom_0();}
  31.         else if (myState == States.Livingroom_1)    {state_Livingroom_1();}
  32.         else if (myState == States.Livingroom_2)    {state_Livingroom_2();}
  33.         else if (myState == States.Push_Harder)     {state_Push_Harder();}
  34.         else if (myState == States.Peak)            {state_Peak();}
  35.         else if (myState == States.Call_0)          {state_Call_0();}
  36.         else if (myState == States.Call_1)          {state_Call_1();}
  37.         else if (myState == States.Window_0)        {state_Window_0();}
  38.         else if (myState == States.Window_1)        {state_Window_1();}
  39.         else if (myState == States.Grabbed)         {state_Grabbed();}
  40.         else if (myState == States.Struggle)        {state_Struggle();}
  41.         else if (myState == States.Punch)           {state_Punch();}
  42.         else if (myState == States.Closet)          {state_Closet();}
  43.         else if (myState == States.Run_0)           {state_Run_0();}
  44.         else if (myState == States.Dodge_0)         {state_Dodge_0();}
  45.         else if (myState == States.Duck_0)          {state_Duck_0();}
  46.         else if (myState == States.Zigzag_0)        {state_Zigzag_0();}
  47.         else if (myState == States.Zigzag_1)        {state_Zigzag_1();}
  48.         else if (myState == States.Car_0)           {state_Car_0();}
  49.         else if (myState == States.Glove)           {state_Glove();}
  50.         else if (myState == States.Sun_0)           {state_Sun_0();}
  51.         else if (myState == States.Sun_1)           {state_Sun_1();}
  52.         else if (myState == States.Body)            {state_Body();}
  53.         else if (myState == States.End)             {state_End();}
  54.         if (Input.GetKey("escape"))
  55.             Application.Quit();
  56.        
  57.     }
  58.  
  59.    
  60.     void state_Livingroom_0()    {
  61.         text.text = "You're up in the mountains with your three friends, Benjamin(your best friend), Fred and Anna, during summer vacation in a nice little cabin that's owned by Benjamin.  " +
  62.                 "Fred and Anna went to the car about an hour ago to grab some beers, seems weird they're not back yet.. In the mean time you can look around\n\n" +
  63.                     "Press 1 to head into the bedroom,  2 to go to the wine celler, 3 to go outside"; {
  64.                 if(Input.GetKeyDown(KeyCode.Alpha1)) {myState = States.Bedroom_0;}
  65.                     else if(Input.GetKeyDown(KeyCode.Alpha2)) {myState = States.Celler_1;}
  66.                         else if(Input.GetKeyDown(KeyCode.Alpha3)) {myState = States.Front_door;}
  67.             }
  68.     }  
  69.     void state_bedroom_0()  {
  70.         text.text = "You enter the room. No signs of Frank or Anna in here, just clothes, suitecases spread out in the room and an open window. Oh well. \n\n" +
  71.                 "You decide to return to the living room in the cabin. \n\n " +
  72.                     "Press 2 to goto the wine celler, 3 to go outside"; {  
  73.                         if(Input.GetKeyDown(KeyCode.Alpha2))    {myState = States.Celler_1;}
  74.                         else if (Input.GetKeyDown(KeyCode.Alpha3))  {myState = States.Front_door;}
  75.         }  
  76.     }        
  77.     void state_Celler_1()   {
  78.         text.text = "The wine celler door has a huge lock on it, so there's no chance they could of gone down there. Benjamin yells from the couch in the living room : I lost the key last time we were up here, so we'll have to stick to beer and vodka. \n\n"+
  79.                 "That's a shame, a glass of red would of been nice today. At least we know they're not down there.\n\n" +
  80.                     "press Space to go back to the living room" ;{
  81.                         if(Input.GetKeyDown(KeyCode.Space))     {myState = States.Livingroom_0;}
  82.         }
  83.     }
  84.     void state_Livingroom_1()   {
  85.         text.text = "Just the front door left.\n\n" +
  86.                 "Press Space to goto the front door"; {
  87.                     if(Input.GetKeyDown(KeyCode.Space))     {myState = States.Front_door;}}
  88.                 }
  89.            
  90.                        
  91.    
  92.     void state_Front_door(){   
  93.         text.text = "You head to the front door, but it won't budge, you look over to Benjamin and he just shrugs and says :Sometimes it jams.\n\n" +
  94.                 "Press 1 to push harder, 2 check if somethings blocking the door"; {
  95.                     if(Input.GetKeyDown(KeyCode.Alpha1)) {myState =  States.Push_Harder;}
  96.                         else if(Input.GetKeyDown(KeyCode.Alpha2)) {myState = States.Peak;}
  97.                         }
  98.                     }
  99.                    
  100.     void state_Push_Harder()    {
  101.         text.text = "You push the door with all your might and manage to open it just enough to stick your head through the opening.\n\n " +
  102.                 "Press Space to peak."; {
  103.                     if(Input.GetKeyDown(KeyCode.Space)) {myState = States.Peak;}
  104.                 }
  105.             }  
  106.    
  107.     void state_Peak()   {
  108.         text.text = "You see two pairs of feet, the shoes look like they belong to Fred and Anna. You also hear the buzzing noise of flies.\n\n " +
  109.                 "Press Space to Call their names."; {
  110.                     if(Input.GetKeyDown(KeyCode.Space)) {myState = States.Call_0;}
  111.                 }
  112.             }
  113.     void state_Call_0() {
  114.         text.text = "No answer. You take notice of the large window next to the door.\n\n " +
  115.             "Press space to Open the window and peak through it"; {
  116.                 if(Input.GetKeyDown(KeyCode.Space)) {myState = States.Window_0;}
  117.             }
  118.         }
  119.        
  120.     void state_Window_0() {
  121.         text.text = "As you're sticking your head through the window you hear movement in the bushes to your right, you ignore it and look left, towards the front door.\n\n" +
  122.             "You see Anna has an axe sticking out of her chest, and you only recognize Fred from the bloody clothes he's wearing, as his face and body are covered in gore.\n\n" +
  123.             "press Space to continue.." ;{
  124.                 if(Input.GetKeyDown(KeyCode.Space)) {myState = States.Grabbed;}
  125.             }
  126.         }
  127.     void state_Grabbed() {
  128.         text.text = "You're suddenly grabbed by the neck!\n\n" +
  129.             "you turn your head and see a tall figure in a mask and hood, wielding a machete and what seems like some sort of gun on his back.\n\n"+
  130.             "Press to struggle 1, 2 to call for Benjamin , 3 attempt to punch the strange figure."; {
  131.                 if(Input.GetKeyDown(KeyCode.Alpha1)) {myState = States.Struggle;}
  132.                     else if(Input.GetKeyDown(KeyCode.Alpha2)) {myState = States.Call_1;}
  133.                     else if(Input.GetKeyDown(KeyCode.Alpha3)) {myState = States.Punch;}
  134.                     }
  135.                 }
  136.     void state_Struggle() {
  137.         text.text = "You manage to break free from the assailants grip by wiggling your body around and quickly pull your head in and shut the window.\n\n" +
  138.                 "press Space to continue"; {
  139.                 if(Input.GetKeyDown(KeyCode.Space)) {myState = States.Livingroom_2;}
  140.                 }
  141.             }
  142.            
  143.     void state_Call_1() {
  144.         text.text = "You scream out Benjamin! as loud as you can.\n\n"+
  145.                 "You get no response, and try to turn around so you can see the couch.\n\n" +
  146.                 "You see Benjamin impaled to the couch by a harpoon.\n\n" +
  147.                 "Suddenly, you feel a sharp pain in your chest, and everything slowly fades to black..\n\n" +
  148.                 "Game Over! Press Return to start over!";  {   
  149.                     if(Input.GetKeyDown(KeyCode.Return)) {myState = States.Livingroom_0;}
  150.                                 }
  151.                             }
  152.     void state_Punch() {
  153.         text.text = "You attempt to punch the assailent in the stomach.\n\n" +
  154.                     "Unfortunetly, the assailant is wearing some kind of metal plating under his or her shirt so your punch has no effect.\n\n" +
  155.                     "You suddenly feel a sharp pain in your chest, and everything slowly fades to black..\n\n" +
  156.                     "Game Over! Press Return to start over!" ; {
  157.                         if(Input.GetKeyDown(KeyCode.Return)) {myState = States.Livingroom_0;}
  158.                         }
  159.                     }
  160.                        
  161.     void state_Livingroom_2() {
  162.         text.text = "As you try to catch your breathe, you notice Benjamin, impaled on the couch by a harpoon.\n\n" +
  163.                     "You nearly puke at the sight of your best friends motionless body. \n\n" +
  164.                     "Now you have to try and escape! The assailant is slowly banging down the front door, you don't have much time.\n\n" +
  165.                     "press 1 to goto the wine celler, press 2 to goto the bedroom, 3 check Benjamins body"; {
  166.                         if(Input.GetKeyDown(KeyCode.Alpha1)) {myState = States.Celler_2;}
  167.                             else if(Input.GetKeyDown(KeyCode.Alpha2)) {myState = States.Bedroom_1;}
  168.                                 else if(Input.GetKeyDown(KeyCode.Alpha3)) {myState = States.Body;}
  169.                                 }
  170.                             }
  171.                            
  172.     void state_Celler_2() {
  173.         text.text = "As you approtch the celler, you remember it had a lock on it and Benjamin lost the key.\n\n" +
  174.                     "You hear the front door get smashed down, all hope is lost..\n\n" +
  175.                     "Game Over! Press Return to start over!"; {
  176.                         if(Input.GetKeyDown(KeyCode.Return)) {myState = States.Livingroom_0;}
  177.                     }
  178.                 }
  179.        
  180.     void state_Body() {
  181.                     text.text = "You rush over to Benjamins side and shake him while asking if he can move, he responds by gurgling the blood inside of his mouth.\n\n"+
  182.                         "You tell him you're going to go find help. \n\n" +
  183.                         "goto the wine celler press 1, dash for the bedroom press 2"; {
  184.                         if(Input.GetKeyDown(KeyCode.Alpha1)) {myState = States.Celler_2;}
  185.                         else if(Input.GetKeyDown(KeyCode.Alpha2)) {myState = States.Bedroom_1;}
  186.                         }
  187.                     }
  188.     void state_Bedroom_1() {
  189.                     text.text = "You run into the bedroom and lock the door behind you. Your options are: \n\n" +
  190.                             "1 Hide in the closet or 2 escape through the window." ;{
  191.                                 if(Input.GetKeyDown(KeyCode.Alpha1)) {myState = States.Closet;}
  192.                                     else if(Input.GetKeyDown(KeyCode.Alpha2)) {myState = States.Window_1;}
  193.                             }
  194.                         }
  195.                        
  196.     void state_Closet() {
  197.                     text.text = "You hide in the closet, it works in movies, so you should be safe, right?\n\n" +
  198.                         "You hold your breathe as the assailent knocks down the bedroom door with ease.\n\n" +
  199.                             "He walks over to the bed and flips it over.\n\n" +
  200.                             "He then starts to scan the room.\n\n" +
  201.                             "He notices the open window, and starts walking towards it.\n\n" +
  202.                             "He stops infront of it and slowly turns towards the closet, and walks towards you.\n\n" +
  203.                             "You close your eyes and he chops the closet door open...\n\n" +
  204.                                     "Game over! Press Return to try again!" ;{
  205.                                         if(Input.GetKeyDown(KeyCode.Return)) {myState = States.Grabbed;}
  206.                         }
  207.                     }
  208.                    
  209.     void state_Window_1() {
  210.                     text.text = "You climb through the window and shut it behind you, and start running towards the car!\n\n" +
  211.                                 "You hear the sound of glass breaking as the assailent breaks through the window and starts running after you.\n\n" +
  212.                                 "Luckely, you're a fast runner and seem to be faster than the assailant.\n\n" +
  213.                                 "press Space to continue" ;{
  214.                                     if(Input.GetKeyDown(KeyCode.Space)) {myState = States.Run_0;}
  215.                                    
  216.                                 }
  217.                             }
  218.        
  219.     void state_Run_0 () {
  220.             text.text = "While running, a harpoon lands to the left of your leg! It seems he's trying to injure you before you get out of range of the harpoon gun.\n\n" +
  221.                         "You turn your head around to look where he's aiming, he's aiming the gun at about chest hight\n\n" +
  222.                     "Press 1 to Dodge to the side, 2 to duck, 3 to zigzag"; {
  223.                         if(Input.GetKeyDown(KeyCode.Alpha1)) {myState = States.Dodge_0;}
  224.                             else if(Input.GetKeyDown(KeyCode.Alpha2)) {myState = States.Duck_0;}
  225.                                 else if(Input.GetKeyDown(KeyCode.Alpha3)) {myState = States.Zigzag_0;}
  226.                             }
  227.                         }
  228.    
  229.     void state_Dodge_0 () {
  230.                     text.text = "You attempt to dodge to the right, but do it before he shoots, and get shot in the lower back slowing you down.\n\n" +
  231.                             "The assailat catches up to you right as you begin to see the car..\n\n" +
  232.                                 "Game over! Press Return to try again!" ;{
  233.                                 if(Input.GetKeyDown(KeyCode.Return)) {myState = States.Window_1;}
  234.                             }
  235.                         }
  236.                        
  237.     void state_Duck_0 () {
  238.                     text.text = "You attempt to duck while running, the assailent wasn't expecting that and misses by a few cm!\n\n" +
  239.                         "press Space to continue."; {
  240.                         if(Input.GetKeyDown(KeyCode.Space)) {myState = States.Car_0;}
  241.                        
  242.                     }
  243.                 }
  244.                
  245.     void state_Zigzag_0() {
  246.                     text.text = "You start zigzagging in a Z like movement, the assailent lines up the shot and hits you in the leg!\n\n" +
  247.                         "You're now running at half speed.\n\n" +
  248.                          "press Space to continue" ; {
  249.                          if(Input.GetKeyDown(KeyCode.Space)) {myState = States.Zigzag_1;}
  250.                     }
  251.                 }
  252.                
  253.     void state_Zigzag_1(){
  254.                     text.text = "You're about 15 meters from the car, when you feel a sharp pain in in your other leg, and fall to the ground.\n\n" +
  255.                         "as you hear footsteps closing in all you could think about is if only you had ducked you'd of made it to the car in time...\n\n" +
  256.                          "Game Over! Press return to try again!"; {
  257.                             if(Input.GetKeyDown(KeyCode.Return)) {myState = States.Window_1;}
  258.                         }
  259.                     }
  260.     void state_Car_0() {
  261.                     text.text = "You manage to get to the car, now to find the keys!\n\n" +
  262.                         "Press 1 to check glove compartment, 2 check the sun visor.";{
  263.                             if(Input.GetKeyDown(KeyCode.Alpha1)) {myState = States.Glove;}
  264.                                 else if(Input.GetKeyDown(KeyCode.Alpha2)) {myState = States.Sun_0;}
  265.                             }
  266.                         }
  267.  
  268.     void state_Glove() {
  269.                     text.text = "No key! Suddenly the windshield glass shatters, and you're pulled through the opening..\n\n" +
  270.                      "Game Over! Press return to try again!";{
  271.                         if(Input.GetKeyDown(KeyCode.Return)) {myState = States.Window_1;}
  272.                     }
  273.                 }
  274.                
  275.     void state_Sun_0() {
  276.                     text.text = "There they are!\n\n" +
  277.                         "You quickly stick the key into the ignition and drive as fast as you can towards the main road.\n\n" +
  278.                             "You hear the screams of the assailent slowly fade away as you drive.\n\n" +
  279.                             "Press Space to continue"; {
  280.                             if(Input.GetKeyDown(KeyCode.Space)) {myState = States.Sun_1;}
  281.                         }
  282.                     }
  283.     void state_Sun_1 () {
  284.                     text.text = "You've made it to the main road, and start heading to the nearest town to get help.\n\n" +
  285.                         "A few hours after arriving to town and waiting at the police station after informing them of what happened, you get a phone call.\n\n" +
  286.                             "The caller was a 'police man', and tells you that there's no signs of a break in, bodies or blood anywhere..\n\n" +
  287.                             "You recognize the voice, but can't remember who it belongs to.\n\n" +
  288.                             "The 'Police man' says :  I'll come get you as he quickly hangs up the phone.\n\n" +
  289.                             "Press space to continue"; {
  290.                             if(Input.GetKeyDown(KeyCode.Space)) {myState = States.End;}
  291.                         }
  292.                     }
  293.                            
  294.     void state_End() {
  295.         text.text = "The end?\n\n" +
  296.                     "Thanks for playing!\n\n" +
  297.                     "Game by : Caleb Thomas\n\n" +
  298.                 "Special thanks to : Markus 'Russin' Rydstedt for all the debugging help! <3\n\n" +
  299.                 "Press turn to play again! Escape to close game" ;
  300.                 }
  301.             }
  302.        
  303.        
  304.        
  305.        
  306.                                    
  307.                                    
  308.    
  309.                
  310.        
  311.    
  312. //ADD ONE LAST } ONCE ALL STATES ARE ADDED AND YOU SHOULD BE DONE! AYYYYYYYYYY LMAO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement