Advertisement
AvitusProgramming

Prison: Version 2.0 (WINDOWS/MAC)

Aug 26th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 12.03 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. // Game Jolt link: https://gamejolt.com/games/PrisonEscapeAlpha/278957
  7.  
  8. public class TextController : MonoBehaviour {
  9.  
  10.     public Text text; // public/private (public if able to be linked and called) Type veriablename
  11.     private enum States {
  12.     starting, cell, mirror, sheets_0, lock_0, cell_mirror, sheets_1, lock_1, mirror_obtained, door1, Beta,
  13.     unlock_door,corridor_0, stairs_0, floor, closet_door, hairclip_yes, corridor_1, stairs_1, closet_in, corridor_2, stairs_2,
  14.     corridor_3, courtyard}; //a small table of states
  15.     private States myState; // Private (cant be called in engine) of enum States, called via myState
  16.     public GameObject Beta;
  17.     public InputField DevCheatsField;
  18.     public GameObject DevCheats;
  19.  
  20.     // Use this for initialization
  21.     void Start () {
  22.  
  23.     myState = States.starting; // sets the starting state to starting
  24.     DevCheats.SetActive(false);
  25.  
  26.     }
  27.    
  28.     // Update is called once per frame
  29.     void Update ()
  30.     {
  31.         // print (myState); // continously prints state
  32.  
  33.         devEnabled();
  34.  
  35.         if (myState == States.starting) {
  36.             text.text = "Press enter to start game!";
  37.             if (Input.GetKeyDown (KeyCode.Return)) { // if start/enter is pressed, will continue to cell
  38.                 myState = States.cell;
  39.             }
  40.         }
  41.  
  42.         if      (myState == States.cell)            {cell();}
  43.         else if (myState == States.sheets_0)        {sheets_0();}
  44.         else if (myState == States.mirror)          {mirror();}
  45.         else if (myState == States.lock_0)          {lock_0();}
  46.         else if (myState == States.cell_mirror)     {cell_mirror1();}
  47.         else if (myState == States.lock_1)          {lock1();}
  48.         else if (myState == States.mirror_obtained) {mirror_obtained();}
  49.         else if (myState == States.door1)           {unlock_door();}
  50.         else if (myState == States.sheets_1)        {sheets_1();}
  51.         else if (myState == States.Beta)            {BetaController();}
  52.         else if (myState == States.unlock_door)     {unlock_door();}
  53.         else if (myState == States.corridor_0)      {corridor_0();}
  54.         else if (myState == States.floor)           {floor();}
  55.         else if (myState == States.stairs_0)        {stairs_0();}
  56.         else if (myState == States.closet_door)     {closet_door();}
  57.         else if (myState == States.hairclip_yes)    {StartCoroutine( hairclip_yes());}
  58.         else if (myState == States.corridor_1)      {corridor_1();}
  59.         else if (myState == States.stairs_1)        {stairs_1();}
  60.         else if (myState == States.closet_in)       {closet_in();}
  61.         else if (myState == States.corridor_2)      {corridor_2();}
  62.         else if (myState == States.stairs_2)        {stairs_2();}
  63.         else if (myState == States.corridor_3)      {corridor_3();}
  64.         else if (myState == States.courtyard)       {courtyard();}
  65.         }
  66.  
  67.     #region Alpha features (stages/text)
  68.    
  69.     void mirror_obtained ()
  70.     {
  71.  
  72.         text.text = "You moved the mirror and now have a good view " +
  73.         "of the lock on the other side of the door.\n\n" +
  74.         "Press C to continue roaming your cell, or L to view the lock.";
  75.  
  76.         if (Input.GetKeyDown (KeyCode.C)) {
  77.             myState = States.cell_mirror;
  78.         }
  79.  
  80.         if (Input.GetKeyDown (KeyCode.L)) {
  81.             myState = States.lock_1;
  82.         }
  83.     }
  84.  
  85.     void cell ()
  86.     {
  87.  
  88.         // print ("Return successfully pressed.");
  89.         text.text = "You are in a prison cell, and you want to escape. There are " +
  90.                     "some dirty sheets on the bed, a mirror on the wall, and the door " +
  91.                     "is locked from the outside.\n\n" +
  92.                     "Press S view Sheets, M to view Mirror, and L to view Lock";
  93.  
  94.         if (Input.GetKeyDown (KeyCode.S)) {
  95.             myState = States.sheets_0;
  96.         }
  97.  
  98.         if (Input.GetKeyDown (KeyCode.M)) {
  99.             myState = States.mirror;
  100.         }
  101.  
  102.         if (Input.GetKeyDown (KeyCode.L)) {
  103.             myState = States.lock_0;
  104.         }
  105.                          
  106.     }
  107.  
  108.     void sheets_0 ()
  109.     {
  110.  
  111.         // print ("S was pressed.");
  112.         text.text = "Some old rags lay carelessly on the wooden frame that is your bed. " +
  113.                     "\n That doesn't seem very comfortable!\n\n " +
  114.                     "Press R to continue roaming your cell.";
  115.  
  116.         if (Input.GetKeyDown (KeyCode.R)) {
  117.             myState = States.cell;
  118.         }
  119.  
  120.     }
  121.  
  122.     void lock_0 () {
  123.            
  124.         // print ("L was pressed.");
  125.         text.text = "An old rusty lock hangs outside of your door. " +
  126.                     "If only you had a mirror so you could lockpick it...\n\n" +
  127.                     "Press R to continue to roam your cell.";
  128.  
  129.         if (Input.GetKeyDown (KeyCode.R)) {
  130.             myState = States.cell;
  131.         }
  132.     }
  133.  
  134.     void mirror ()
  135.     {
  136.         // print ("M was pressed.");
  137.         text.text = "An old dusty mirror meets your eye. You use it daily to adjust your " +
  138.         "looks and stay sharp.\n " +
  139.         "The mirror looks like it can be moved around if pushed with great strength.\n\n " +
  140.         "Press R to roam your cell, press M  to move the mirror.";
  141.  
  142.         if (Input.GetKeyDown (KeyCode.R)) {
  143.             // print ("R was pressed.");
  144.             myState = States.cell;
  145.         }
  146.        
  147.  
  148.         if (Input.GetKeyDown (KeyCode.M)) {
  149.             // print ("M was pressed.");
  150.             myState = States.mirror_obtained;
  151.         }
  152.                            
  153.     }
  154.  
  155.     void cell_mirror1 ()
  156.     {
  157.        
  158.         text.text = "You are in a prison cell, and you want to escape. There are " +
  159.                     "some dirty sheets on the bed and a door that " +
  160.                     "is locked from the outside.\n\n" +
  161.                     "Press S view Sheets, and L to view Lock using the mirror.";
  162.  
  163.  
  164.             if (Input.GetKeyDown (KeyCode.S)) {
  165.                 // print ("S was pressed.");
  166.                 myState = States.sheets_1;
  167.             }
  168.  
  169.             if (Input.GetKeyDown (KeyCode.L)) {
  170.                 // print ("L was pressed.");
  171.                 myState = States.lock_1;
  172.             }
  173.  
  174.     }
  175.  
  176.     void sheets_1 ()
  177.     {
  178.  
  179.         if (Input.GetKeyDown (KeyCode.S)) {
  180.             // print ("S was pressed.");
  181.             text.text = "Some old rags lay carelessly on the wooden frame that is your bed. " +
  182.                         "\n That doesn't seem very comfortable, but dont worry, you won't sleep there anymore!\n\n " +
  183.                         "Press R to continue roaming your cell.";
  184.         }
  185.  
  186.         if (Input.GetKeyDown (KeyCode.R)) {
  187.             myState = States.cell_mirror;
  188.         }
  189.     }
  190.  
  191.     void lock1 ()
  192.     {
  193.  
  194.         if (Input.GetKeyDown (KeyCode.L)) {
  195.             // print ("L was pressed.");
  196.             text.text = "The lock is a plain old cell lock, it's nothing " +
  197.                         "you can't handle with that mirror.\n\n" +
  198.                         "Press U to unlock the cell door, or R to roam your cell.";
  199.         }
  200.  
  201.         if (Input.GetKeyDown (KeyCode.U)) {
  202.             myState = States.unlock_door;
  203.         }
  204.  
  205.         if (Input.GetKeyDown (KeyCode.R)) {
  206.             myState = States.cell_mirror;
  207.         }
  208.     }
  209.  
  210.     void unlock_door ()
  211.     {
  212.  
  213.         text.text = "You open the cell door and check your surroundings..\n " +
  214.                     "Nobody noticed your escape, you are in the clear!\n\n" +
  215.                     "Press Enter to check your surroundings.";
  216.  
  217.         if (Input.GetKeyDown (KeyCode.Return)) {
  218.             myState = States.Beta;
  219.         }
  220.     }
  221.  
  222.     #endregion
  223.  
  224.     #region Start of Beta (transition to corridor_0)
  225.     void BetaController ()
  226.     {
  227.  
  228.         if (Beta.name != "Beta") {
  229.             if (Input.GetKeyDown (KeyCode.Return)) {
  230.                     text.text = "Find it out soon when the beta releases!";
  231.             }
  232.         } else if (Beta.name == "Beta") {
  233.             print ("Start of Beta.");
  234.             myState = States.corridor_0;
  235.         }
  236.    
  237.     }
  238.     #endregion
  239.  
  240.     #region Beta features (stages/text)
  241.  
  242.     void corridor_0 () {
  243.  
  244.         text.text = "You are standing in a corridor.\nThere is a closet and some stairs leading to the courtyard." +
  245.                     " There is some old trash laying across the floor of the corridor.\n\n" +
  246.                     "C to view the Closet, F to inspect the Floor, S to climb the Stairs.";
  247.  
  248.         if (Input.GetKeyDown (KeyCode.C)) {
  249.             myState = States.closet_door;
  250.         }
  251.  
  252.         if (Input.GetKeyDown (KeyCode.F)) {
  253.             myState = States.floor;
  254.         }
  255.  
  256.         if (Input.GetKeyDown (KeyCode.S)) {
  257.             myState = States.stairs_0;
  258.         }
  259.     }
  260.  
  261.     void stairs_0 () {
  262.  
  263.         text.text = "It would not be wise to go to the courtyard. " +
  264.                     "The guards would notice you got out of your cell, " +
  265.                     "and you'd end up back in it.\n\n" +
  266.                     "Press R return to the corridor.";
  267.  
  268.         if (Input.GetKeyDown (KeyCode.R)) {
  269.             myState = States.corridor_0;
  270.         }
  271.  
  272.     }
  273.  
  274.     void floor () {
  275.  
  276.         text.text = "There is some old trash laying across the floor of the corridor.\n" +
  277.                     "Would you like to inspect it further?\n\n" +
  278.                     "Press Enter if Yes, press Backspace if No.";
  279.  
  280.         if (Input.GetKeyDown (KeyCode.Return)) {
  281.             myState = States.hairclip_yes;
  282.         }
  283.  
  284.         if (Input.GetKeyDown (KeyCode.Backspace)) {
  285.             myState = States.corridor_0;
  286.         }
  287.  
  288.     }
  289.  
  290.     void closet_door () {
  291.  
  292.         text.text = "You stand in front of a tall closet, however, it is locked. " +
  293.                     "If only you could unlock it somehow.\n\n" +
  294.                     "Press R to return to the corridor.";
  295.  
  296.         if (Input.GetKeyDown (KeyCode.R)) {
  297.             myState = States.corridor_0;
  298.         }
  299.     }
  300.  
  301.     void corridor_1 () {
  302.  
  303.         text.text = "You are standing in a corridor.\nThere is a closet and some stairs leading to the courtyard." +
  304.                     " There is some old trash laying across the floor of the corridor.\n\n" +
  305.                     "P to pick the Closet lock or S to climb the Stairs.";
  306.  
  307.         if (Input.GetKeyDown (KeyCode.P)) {
  308.             myState = States.closet_in;
  309.         }
  310.  
  311.         if (Input.GetKeyDown (KeyCode.S)) {
  312.             myState = States.stairs_1;
  313.         }
  314.  
  315.     }
  316.  
  317.     void stairs_1 () {
  318.  
  319.         text.text = "It would not be wise to go to the courtyard. " +
  320.                     "The guards would notice you got out of your cell, " +
  321.                     "and you'd end up back in it.\n\n" +
  322.                     "Press R return to the corridor.";
  323.  
  324.         if (Input.GetKeyDown (KeyCode.R)) {
  325.             myState = States.corridor_1;
  326.         }
  327.  
  328.     }
  329.  
  330.     void closet_in () {
  331.  
  332.         text.text = "You stand in front of a tall closet, which now is unlocked. " +
  333.                     "There are some cleaner clothes in the closet that seem to fit you. " +
  334.                     "\n\nPress R to return the corridor or D to dress up in the cleaner clothing.";
  335.  
  336.         if (Input.GetKeyDown (KeyCode.R)) {
  337.             myState = States.corridor_2;
  338.         }
  339.  
  340.         if (Input.GetKeyDown (KeyCode.D)) {
  341.  
  342.             myState = States.corridor_3;
  343.         }
  344.  
  345.     }
  346.  
  347.     void corridor_2 () {
  348.  
  349.         text.text = "You are standing in a corridor.\nThere is a closet and some stairs leading to the courtyard." +
  350.                     " There is some old trash laying across the floor of the corridor.\n\n" +
  351.                     "B to go back to the Closet or S to climb the Stairs.";
  352.  
  353.         if (Input.GetKeyDown (KeyCode.B)) {
  354.             myState = States.closet_in;
  355.         }
  356.  
  357.         if (Input.GetKeyDown (KeyCode.S)) {
  358.             myState = States.stairs_2;
  359.         }
  360.  
  361.         if (Input.GetKeyDown (KeyCode.D)) {
  362.             myState = States.corridor_3;
  363.         }      
  364.  
  365.     }
  366.  
  367.     void stairs_2 () {
  368.  
  369.         text.text = "It would not be wise to go to the courtyard. " +
  370.                     "The guards would notice you got out of your cell, " +
  371.                     "and you'd end up back in it.\n\n" +
  372.                     "Press R return to the corridor.";
  373.  
  374.         if (Input.GetKeyDown (KeyCode.R)) {
  375.             myState = States.corridor_2;
  376.         }  
  377.  
  378.     }
  379.  
  380.     void corridor_3 () {
  381.  
  382.         text.text = "You are now dressed as a cleaner, guard will be unable to recognise you " +
  383.                     "if you stay in your role well enough.\n\n " +
  384.                     "Press U to undress or S to climb the stairs.";
  385.  
  386.         if (Input.GetKeyDown (KeyCode.U)) {
  387.             myState = States.closet_in;
  388.         }
  389.  
  390.         if (Input.GetKeyDown (KeyCode.S)) {
  391.             myState = States.courtyard;
  392.         }
  393.     }
  394.  
  395.     void courtyard () {
  396.  
  397.         text.fontSize = 18;
  398.         text.text = "You climb up the stairs out to the courtyard. There is a guardpost " +
  399.                     "situated at the gate of the prison. You knock on the guardpost's window " +
  400.                     "to get the guard's attention. The guard looks at you form his chair, and " +
  401.                     "you request him to open the gate, as you 'forgot some of your cleaning items'. " +
  402.                     "He opens the gate and you exit the prison.\n\n " +
  403.                     "You are now officially a free man.\n\n " +
  404.                     "Thank you for playing!\n " +
  405.                     "Press Esc. to exit the game.";
  406.  
  407.         if (Input.GetKeyDown (KeyCode.Escape)) {
  408.  
  409.             Application.Quit();
  410.  
  411.         }
  412.  
  413.     }
  414.  
  415.  
  416.     IEnumerator hairclip_yes () {
  417.  
  418.         text.text = "Among the trash you find an old hairclip." +
  419.                     "\nYou put the hairclip in your pocked as it might come to use to you.";
  420.         yield return new WaitForSeconds(4.5f);
  421.         myState = States.corridor_1;
  422.  
  423.     }
  424.  
  425.     #endregion
  426.  
  427.     #region Developer Cheats
  428.  
  429.      void devEnabled () {
  430.  
  431.         if (Input.GetKeyDown (KeyCode.BackQuote)) {
  432.             DevCheats.SetActive(true);
  433.         }
  434.  
  435.         if (DevCheatsField.text == "Courtyard") {
  436.             if (Input.GetKeyDown (KeyCode.Tab)) {
  437.                 myState = States.courtyard;
  438.             }
  439.         }
  440.  
  441.         if (DevCheatsField.text == "Corridor_0") {
  442.             if (Input.GetKeyDown (KeyCode.Tab)) {
  443.                 myState = States.corridor_0;
  444.             }
  445.         }
  446.     }
  447.  
  448.     #endregion
  449.  
  450. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement