AvitusProgramming

Prison: Version 2.0 (MOBILE)

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