Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.86 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class TextController : MonoBehaviour {
  7.  
  8.     public Text text;
  9.  
  10.     private enum States {cell, mirror, sheets_0, lock_0, cell_mirror, sheets_1, lock_1, freedom};
  11.  
  12.     private States myState;
  13.  
  14.     // Use this for initialization
  15.     void Start () {
  16.         myState = States.cell;
  17.     }
  18.    
  19.     // Update is called once per frame
  20.     void Update ()
  21.     {
  22.         print (myState);
  23.         if (myState == States.cell)             {state_cell ();}
  24.         else if (myState == States.sheets_0)    {state_sheets_0 ();}
  25.         else if (myState == States.sheets_1)    {state_sheets_1 ();}
  26.         else if (myState == States.lock_0)      {state_lock_0 ();}
  27.         else if (myState == States.lock_1)      {state_lock_1 ();}
  28.         else if (myState == States.mirror)      {state_mirror ();}
  29.         else if (myState == States.cell_mirror) {state_cell_mirror ();}
  30.         else if (myState == States.freedom)     {state_freedom ();}
  31.     }
  32.  
  33.     void state_cell ()
  34.     {
  35.         text.text = "You are in a prison cell, and you want to escape. There are " +
  36.         "some dirty sheets on the bed, a mirror on the wall, and the door " +
  37.         "is locked from the outside.\n\n" +
  38.         "Press S the view Sheets, press M to view Mirror and L to view Lock";
  39.  
  40.         if (Input.GetKeyDown (KeyCode.S)) {
  41.             myState = States.sheets_0;
  42.         } else if (Input.GetKeyDown (KeyCode.M)) {
  43.             myState = States.mirror;
  44.         } else if (Input.GetKeyDown (KeyCode.L)) {
  45.             myState = States.lock_0;
  46.         }
  47.  
  48.     }
  49.  
  50.     void state_mirror ()
  51.     {
  52.         text.text = "The dirty old mirror on the wall seems loose... \n\n" +
  53.         "Press T to take the mirror, or R to return to cell";
  54.  
  55.         if (Input.GetKeyDown (KeyCode.T)) {
  56.             myState = States.cell_mirror;
  57.         } else if (Input.GetKeyDown (KeyCode.R)) {
  58.             myState = States.cell;
  59.         }
  60.  
  61.     }
  62.  
  63.     void state_cell_mirror ()
  64.     {
  65.         text.text = "You are still in your cell, and you STILL want to escape! There are " +
  66.                     " some dirty sheets on the bed a mark where the mirror was, " +
  67.                     "and that pesky door is still there, firmly locked!\n\n" +
  68.                     "Press S to view Sheets, or L to view Lock";
  69.  
  70.         if (Input.GetKeyDown (KeyCode.S)) {
  71.             myState = States.sheets_1;
  72.         } else if (Input.GetKeyDown (KeyCode.L)) {
  73.             myState = States.lock_1;
  74.         }
  75.  
  76.     }
  77.  
  78.     void state_sheets_0 ()
  79.     {
  80.         text.text = "You can't believe you sleep in these things. Surely it's " +
  81.                      "time somebody changed them. The pleasures of prison life " +
  82.                     "I guess!\n\n" +
  83.                     "Press R to return to roaming in your cell";
  84.  
  85.         if (Input.GetKeyDown (KeyCode.R)) {
  86.             myState = States.cell;
  87.         }
  88.  
  89.     }
  90.  
  91.     void state_sheets_1 ()
  92.     {
  93.         text.text = "You can't believe you sleep in these things. They still " +
  94.                      "haven't been changed... The pleasures of prison life " +
  95.                     "I guess!\n\n" +
  96.                     "Press R to return to roaiming in your cell";
  97.  
  98.         if (Input.GetKeyDown (KeyCode.R)) {
  99.             myState = States.cell_mirror;
  100.         }
  101.  
  102.     }
  103.  
  104.     void state_lock_0 ()
  105.     {
  106.         text.text = "This is one of those button locks. You have no idea what the " +
  107.                     "combination is. You wish you could somehow see where the dirty " +
  108.                     "fingerprints were, maybe that would help.\n\n" +
  109.                     "Press R to return to roaiming in your cell";
  110.  
  111.         if (Input.GetKeyDown (KeyCode.R)) {
  112.             myState = States.cell;
  113.         }
  114.  
  115.     }
  116.  
  117.     void state_lock_1 ()
  118.     {
  119.         text.text = "You carefully put the mirror through the barsm abd turn it round " +
  120.                     "so you can see the lock. You can just make out fingerprints around " +
  121.                     "the buttons. You press the dirty buttons... You hear a click!\n\n" +
  122.                     "Press O to Open, or R to return to your cell";
  123.  
  124.         if (Input.GetKeyDown (KeyCode.O)) {
  125.             myState = States.freedom;
  126.         } else if (Input.GetKeyDown (KeyCode.R)) {
  127.             myState = States.cell_mirror;
  128.         }
  129.  
  130.     }
  131.  
  132.     void state_freedom ()
  133.     {
  134.         text.text = "You are free! \n\n" +
  135.                     "Press P to play again";
  136.  
  137.         if (Input.GetKeyDown (KeyCode.P)) {
  138.             myState = States.cell;
  139.         }
  140.  
  141.     }
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement