IT-Academy

Unity Konzola Cela

Aug 7th, 2017
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.08 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, stairs_0, stairs_1,
  11.         stairs_2, courtyard, floor, corridor_1, corridor_2, corridor_3,closet_door, in_closet
  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.stairs_1)    {stairs_1();}
  33.         else if (myState == States.stairs_2)    {stairs_2();}
  34.         else if (myState == States.courtyard)   {courtyard();}
  35.         else if (myState == States.floor)       {floor();}
  36.         else if (myState == States.corridor_1)  {corridor_1();}
  37.         else if (myState == States.corridor_2)  {corridor_2();}
  38.         else if (myState == States.corridor_3)  {corridor_3();}
  39.         else if (myState == States.closet_door) {closet_door();}
  40.         else if (myState == States.in_closet)   {in_closet();}
  41.     }
  42.    
  43.     void in_closet() {
  44.         text.text = "Inside the closet you see a cleaner's uniform that looks about your size! " +
  45.                     "Seems like your day is looking-up.\n\n" +
  46.                     "Press D to Dress up, or R to Return to the corridor";
  47.         if      (Input.GetKeyDown(KeyCode.R))   {myState = States.corridor_2;}
  48.         else if (Input.GetKeyDown(KeyCode.D))   {myState = States.corridor_3;}
  49.     }
  50.    
  51.     void closet_door() {
  52.         text.text = "You are looking at a closet door, unfortunately it's locked. " +
  53.                     "Maybe you could find something around to help enourage it open?\n\n" +
  54.                     "Press R to Return to the corridor";
  55.         if (Input.GetKeyDown(KeyCode.R))        {myState = States.corridor_0;}
  56.     }
  57.    
  58.     void corridor_3() {
  59.         text.text = "You're standing back in the corridor, now convincingly dressed as a cleaner. " +
  60.                     "You strongly consider the run for freedom.\n\n" +
  61.                     "Press S to take the Stairs, or U to Undress";
  62.         if      (Input.GetKeyDown(KeyCode.S))   {myState = States.courtyard;}
  63.         else if (Input.GetKeyDown(KeyCode.U))   {myState = States.in_closet;}
  64.     }
  65.    
  66.     void corridor_2() {
  67.         text.text = "Back in the corridor, having declined to dress-up as a cleaner.\n\n" +
  68.                     "Press C to revisit the Closet, and S to climb the stairs";
  69.         if      (Input.GetKeyDown(KeyCode.C))   {myState = States.in_closet;}
  70.         else if (Input.GetKeyDown(KeyCode.S))   {myState = States.stairs_2;}
  71.     }
  72.    
  73.     void corridor_1() {
  74.         text.text = "Still in the corridor. Floor still dirty. Hairclip in hand. " +
  75.                     "Now what? You wonder if that lock on the closet would succumb to " +
  76.                     "to some lock-picking?\n\n" +
  77.                     "P to Pick the lock, and S to climb the stairs";
  78.         if (Input.GetKeyDown(KeyCode.P))        {myState = States.in_closet;}
  79.         else if (Input.GetKeyDown(KeyCode.S))   {myState = States.stairs_1;}
  80.     }
  81.    
  82.     void floor () {
  83.         text.text = "Rummagaing around on the dirty floor, you find a hairclip.\n\n" +
  84.                     "Press R to Return to the standing, or H to take the Hairclip." ;
  85.         if      (Input.GetKeyDown(KeyCode.R))   {myState = States.corridor_0;}
  86.         else if (Input.GetKeyDown(KeyCode.H))   {myState = States.corridor_1;}
  87.     }  
  88.    
  89.     void courtyard () {
  90.         text.text = "You walk through the courtyard dressed as a cleaner. " +
  91.                     "The guard tips his hat at you as you waltz past, claiming " +
  92.                     "your freedom. You heart races as you walk into the sunset.\n\n" +
  93.                     "Press P to Play again." ;
  94.         if (Input.GetKeyDown(KeyCode.P))        {myState = States.cell;}
  95.     }  
  96.    
  97.     void stairs_0 () {
  98.         text.text = "You start walking up the stairs towards the outside light. " +
  99.                     "You realise it's not break time, and you'll be caught immediately. " +
  100.                     "You slither back down the stairs and reconsider.\n\n" +
  101.                     "Press R to Return to the corridor." ;
  102.         if (Input.GetKeyDown(KeyCode.R))        {myState = States.corridor_0;}
  103.     }
  104.    
  105.     void stairs_1 () {
  106.         text.text = "Unfortunately weilding a puny hairclip hasn't given you the " +
  107.                     "confidence to walk out into a courtyard surrounded by armed guards!\n\n" +
  108.                     "Press R to Retreat down the stairs" ;
  109.         if (Input.GetKeyDown(KeyCode.R))        {myState = States.corridor_1;}
  110.     }
  111.    
  112.     void stairs_2() {
  113.         text.text = "You feel smug for picking the closet door open, and are still armed with " +
  114.                     "a hairclip (now badly bent). Even these achievements together don't give " +
  115.                     "you the courage to climb up the staris to your death!\n\n" +
  116.                     "Press R to Return to the corridor";
  117.         if (Input.GetKeyDown(KeyCode.R))        {myState = States.corridor_2;}
  118.     }
  119.    
  120.     void cell () {
  121.         text.text = "You are in a prison cell, and you want to escape. There are " +
  122.                     "some dirty sheets on the bed, a mirror on the wall, and the door " +
  123.                     "is locked from the outside.\n\n" +
  124.                     "Press S to view Sheets, M to view Mirror and L to view Lock" ;
  125.         if      (Input.GetKeyDown(KeyCode.S))   {myState = States.sheets_0;}
  126.         else if (Input.GetKeyDown(KeyCode.M))   {myState = States.mirror;}
  127.         else if (Input.GetKeyDown(KeyCode.L))   {myState = States.lock_0;}
  128.     }
  129.    
  130.     void mirror() {
  131.         text.text = "The dirty old mirror on the wall seems loose.\n\n" +
  132.                     "Press T to Take the mirror, or R to Return to cell" ;
  133.         if      (Input.GetKeyDown(KeyCode.T))   {myState = States.cell_mirror;}
  134.         else if (Input.GetKeyDown(KeyCode.R))   {myState = States.cell;}
  135.     }
  136.    
  137.     void cell_mirror() {
  138.         text.text = "You are still in your cell, and you STILL want to escape! There are " +
  139.                     "some dirty sheets on the bed, a mark where the mirror was, " +
  140.                     "and that pesky door is still there, and firmly locked!\n\n" +
  141.                     "Press S to view Sheets, or L to view Lock" ;
  142.         if      (Input.GetKeyDown(KeyCode.S))   {myState = States.sheets_1;}
  143.         else if (Input.GetKeyDown(KeyCode.L))   {myState = States.lock_1;}
  144.     }
  145.    
  146.     void sheets_0 () {
  147.         text.text = "You can't believe you sleep in these things. Surely it's " +
  148.                     "time somebody changed them. The pleasures of prison life " +
  149.                     "I guess!\n\n" +
  150.                     "Press R to Return to roaming your cell" ;
  151.         if (Input.GetKeyDown(KeyCode.R))        {myState = States.cell;}
  152.     }
  153.    
  154.     void sheets_1() {
  155.         text.text = "Holding a mirror in your hand doesn't make the sheets look " +
  156.                     "any better.\n\n" +
  157.                     "Press R to Return to roaming your cell" ;
  158.         if (Input.GetKeyDown(KeyCode.R))        {myState = States.cell_mirror;}
  159.     }
  160.    
  161.     void lock_0() {
  162.         text.text = "This is one of those button locks. You have no idea what the " +
  163.                     "combination is. You wish you could somehow see where the dirty " +
  164.                     "fingerprints were, maybe that would help.\n\n" +
  165.                     "Press R to Return to roaming your cell" ;
  166.         if (Input.GetKeyDown(KeyCode.R))        {myState = States.cell;}
  167.     }
  168.    
  169.     void lock_1() {
  170.         text.text = "You carefully put the mirror through the bars, and turn it round " +
  171.                     "so you can see the lock. You can just make out fingerprints around " +
  172.                     "the buttons. You press the dirty buttons, and hear a click.\n\n" +
  173.                     "Press O to Open, or R to Return to your cell" ;
  174.         if      (Input.GetKeyDown(KeyCode.O))   {myState = States.corridor_0;}
  175.         else if (Input.GetKeyDown(KeyCode.R))   {myState = States.cell_mirror;}
  176.     }
  177.    
  178.     void corridor_0() {
  179.         text.text = "You're out of your cell, but not out of trouble." +
  180.                     "You are in the corridor, there's a closet and some stairs leading to " +
  181.                     "the courtyard. There's also various detritus on the floor.\n\n" +
  182.                     "C to view the Closet, F to inspect the Floor, and S to climb the stairs";
  183.         if      (Input.GetKeyDown(KeyCode.S))   {myState = States.stairs_0;}
  184.         else if (Input.GetKeyDown(KeyCode.F))   {myState = States.floor;}
  185.         else if (Input.GetKeyDown(KeyCode.C))   {myState = States.closet_door;}  
  186.     }
  187. }
Advertisement
Add Comment
Please, Sign In to add comment