Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.74 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.    
  9.     private enum States {
  10.         cell, mirror, sheets_0, lock_0, cell_mirror, sheets_1, lock_1, corridor_0,
  11.         stairs_0, floor, closet_0, corridor_1, stairs_1, closet_1
  12.         };
  13.     private States myState;
  14.    
  15.     // Use this for initialization
  16.     void Start () {
  17.         myState = States.cell;
  18.     }
  19.    
  20.     // Update is called once per frame
  21.     void Update () {
  22.         print (myState);
  23.         if      (myState == States.cell)        {cell();}
  24.         else if (myState == States.sheets_0)    {sheets_0();}
  25.         else if (myState == States.sheets_1)    {sheets_1();}
  26.         else if (myState == States.lock_0)      {lock_0();}
  27.         else if (myState == States.lock_1)      {lock_1();}
  28.         else if (myState == States.mirror)      {mirror();}
  29.         else if (myState == States.cell_mirror) {cell_mirror();}
  30.         else if (myState == States.corridor_0)  {corridor_0();}
  31.         else if (myState == States.stairs_0)    {stairs_0();}
  32.         else if (myState == States.floor)       {floor();}
  33.         else if (myState == States.closet_0)    {closet_0();}
  34.         else if (myState == States.corridor_1)  {corridor_1();}
  35.         else if (myState == States.stairs_1)    {stairs_1();}
  36.         else if (myState = States.closet_1)     {closet_1();}
  37.     }
  38.    
  39.     void cell () {
  40.         text.text = "You are in a prison cell, and you want to escape. There are " +
  41.                 "some dirty sheets on the bed, a mirror on the wall, and the door " +
  42.                 "is locked from the outside.\n\n" +
  43.                 "Press S to view Sheets, M to view Mirror and L to view Lock";
  44.         if (Input.GetKeyDown (KeyCode.S))       {myState = States.sheets_0;}
  45.         else if (Input.GetKeyDown (KeyCode.M))  {myState = States.mirror;}
  46.         else if (Input.GetKeyDown (KeyCode.L))  {myState = States.lock_0;}
  47.     }
  48.    
  49.     void mirror () {
  50.         text.text = "The dirty old mirror on the wall seems loose.\n\n " +
  51.                     "Press T to Take the mirror, or R to Return to your cell.";
  52.         if (Input.GetKeyDown (KeyCode.T))       {myState = States.cell_mirror;}
  53.         else if (Input.GetKeyDown (KeyCode.R))  {myState = States.cell;}
  54.     }
  55.    
  56.     void cell_mirror () {
  57.         text.text = "You are still in your cell, and you STILL want to escape! There are " +
  58.                     "some dirty sheets on the bed, a mark where the mirror was, " +
  59.                     "and that pesky door is still there, and firmly locked!\n\n" +
  60.                     "Press S to view Sheets, or L to view Lock.";
  61.         if (Input.GetKeyDown (KeyCode.S))       {myState = States.sheets_1;}
  62.         else if (Input.GetKeyDown (KeyCode.L))  {myState = States.lock_1;}
  63.     }
  64.    
  65.     void sheets_0 () {
  66.         text.text = "You can't believe you seelp in these things. Surley it's " +
  67.                     "time somebody changed them. The pleasures of prison life " +
  68.                     "I guess!\n\n" +
  69.                     "Press R to Return to roaming your cell";
  70.         if (Input.GetKeyDown (KeyCode.R))   {myState = States.cell;}
  71.     }
  72.    
  73.     void sheets_1 () {
  74.         text.text = "Holding a mirror in your hand doesn't make the sheets look " +
  75.                     "any better.\n\n" +
  76.                     "Press R to Return to roaming your cell";
  77.         if (Input.GetKeyDown (KeyCode.R))       {myState = States.cell_mirror;}
  78.     }
  79.    
  80.     void lock_0 () {
  81.         text.text = "This is one of those button locks. Youhave no idea what the " +
  82.                     "combination is. You wish you could somehow see where the dirty " +
  83.                     "fingerprints were, maybe that would help.\n\n" +
  84.                     "Press R to Return to roaming your cell";
  85.         if (Input.GetKeyDown (KeyCode.R))       {myState = States.cell;}
  86.     }
  87.    
  88.     void lock_1 () {
  89.         text.text = "You carefully put the mirror through the bars, and turn it round " +
  90.                     "so you can see the lock. You can just make out the fingerprints around " +
  91.                     "the buttons. You press the dirty buttons and hear a click.\n\n" +
  92.                     "Press O to Open, or R to Return to your cell.";
  93.         if (Input.GetKeyDown (KeyCode.O))       {myState = States.corridor_0;}
  94.         else if (Input.GetKeyDown (KeyCode.R))  {myState = States.cell_mirror;}
  95.     }
  96.    
  97.     void corridor_0() {
  98.         text.text = "You have escaped your cell! Now there's still the problem of leaving " +
  99.                     "the prison. There are a set of stairs that lead up, the floor below you " +
  100.                     "has a set of footprints leading somewhere and there is also a utility closet.\n\n" +
  101.                     "Press S to go up the Stairs, F to inspect the floor, or C to open the closet.";
  102.         if (Input.GetKeyDown (KeyCode.S))       {myState = States.stairs_0;}
  103.         else if (Input.GetKeyDown (KeyCode.F))  {myState = States.floor;}
  104.         else if (Input.GetKeyDown (KeyCode.C))  {myState = States.closet_0;}
  105.     }
  106.    
  107.     void stairs_0 () {
  108.         text.text = "You seem to be on an old staircase. " +
  109.                     "there doesn't seem to be anything in here.  " +
  110.                     "The stairs are a dead end.\n\n" +
  111.                     "Press R to Return to your cell.";
  112.         if (Input.GetKeyDown (KeyCode.R))       {myState = States.corridor_0;}
  113.     }
  114.    
  115.     void floor () {
  116.         text.text = "You inspect the floor. " +
  117.                     "there doesn't seem to be anything in here except an old hairclip.\n\n" +
  118.                     "Press H to pick up the Hairclip, or R to Return.";
  119.         if (Input.GetKeyDown (KeyCode.R))       {myState = States.corridor_0;}
  120.         else if (Input.GetKeyDown (KeyCode.H))  {myState = States.corridor_1;}
  121.     }
  122.    
  123.     void closet_0() {
  124.         text.text = "The closet is locked. Find a way to get in.";
  125.     if(Input.GetKey(KeyCode.R))                 {myState = States.closet_0;}
  126.     }
  127.    
  128.     void corridor_1() {
  129.         text.text = "Now that you've got the Hairclip you can pick locks\n\n" +
  130.                     "Press S to go up the staircase, or press P to pick the lock to the closet";
  131.     if(Input.GetKey(KeyCode.S))                 {myState = States.stairs_1;}
  132.     else if (Input.GetKey(KeyCode.P))           {myState = States.closet_1;}
  133.     }
  134.    
  135.     void stairs_1() {
  136.         text.text = "It's the same empty staircase. Nothing to help you here...\n\n" +
  137.                     "Press R to Return.";
  138.     if(Input.GetKey(KeyCode.R))                 {myState = States.corridor_1;}
  139.     }
  140.    
  141.     void closet_1() {
  142.         text.text = "You've made it into the closet.
  143.        
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement