Advertisement
Guest User

Failure to change UI text.

a guest
Jul 7th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 9.25 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, left_corridor, cell_2,
  11.         stairs_2, courtyard, right_corridor, canteen, corridor_2, corridor_3, table, kitchen};
  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.         print (myState);
  22.         if      (myState == States.cell)            {cell();}
  23.         else if (myState == States.sheets_0)        {sheets_0();}
  24.         else if (myState == States.sheets_1)        {sheets_1();}
  25.         else if (myState == States.lock_0)          {lock_0();}
  26.         else if (myState == States.lock_1)          {lock_1();}
  27.         else if (myState == States.mirror)          {mirror();}
  28.         else if (myState == States.cell_mirror)     {cell_mirror();}
  29.         else if (myState == States.left_corridor)   {left_corridor();}
  30.         else if (myState == States.cell_2)          {cell_2();}
  31.         else if (myState == States.stairs_2)        {stairs_2();}
  32.         else if (myState == States.kitchen)         {kitchen();}
  33.         else if (myState == States.courtyard)       {courtyard();}
  34.         else if (myState == States.right_corridor)  {right_corridor();}
  35.         else if (myState == States.canteen)         {canteen();}
  36.         else if (myState == States.corridor_2)      {corridor_2();}
  37.         else if (myState == States.corridor_3)      {corridor_3();}
  38.         else if (myState == States.table)           {table();}
  39.     }
  40.    
  41.     void table() {
  42.         text.text = "You walk over to the nearest table to you, it is made from heavy wood boards and appears to have been in the room " +
  43.             "for an extremely long time. You can see small stains that look like they could be bits of food or drink. " +
  44.                 "This must be the prison's canteen\n\n" +
  45.                 "Press R to return to Roaming the canteen";
  46.         if (Input.GetKeyDown(KeyCode.R))        {myState = States.canteen;}
  47.     }
  48.    
  49.     void corridor_3() {
  50.         text.text = "You're standing back in the corridor, now convincingly dressed as a cleaner. " +
  51.             "You strongly consider the run for freedom.\n\n" +
  52.                 "Press S to take the Stairs, or U to Undress";
  53.         if  (Input.GetKeyDown(KeyCode.S))   {myState = States.courtyard;}
  54.        
  55.     }
  56.    
  57.     void corridor_2() {
  58.         text.text = "Back in the corridor, having declined to dress-up as a cleaner.\n\n" +
  59.             "Press C to revisit the Closet, and S to climb the stairs";
  60.         if (Input.GetKeyDown(KeyCode.S))    {myState = States.stairs_2;}
  61.     }
  62.    
  63.     void canteen() {
  64.         text.text = "You turn the key in the lock, noticing it takes less effort this time to open the doors. " +
  65.             "You step into a large room, it must be big enough to hold 300 people. Lamps hang from the ceiling " +
  66.                 "and tables line the walls and fill the center of the room. At the far end you can see another door made, " +
  67.                 "this time of metal.\n\n" +
  68.                 "Press T to look at the Tables or D to look at the metal Door.";
  69.         if (Input.GetKeyDown(KeyCode.T))        {myState = States.table;}
  70.         else if (Input.GetKeyDown(KeyCode.S))   {myState = States.kitchen;}
  71.     }
  72.    
  73.     void kitchen() {
  74.         text.text = "You turn the key in the lock, noticing it takes less effort this time to open the doors. " +
  75.             "You step into a large room, it must be big enough to hold 300 people. Lamps hang from the ceiling " +
  76.                 "and tables line the walls and fill the center of the room. At the far end you can see another door made, " +
  77.                 "this time of metal.\n\n" +
  78.                 "Press T to look at the Tables or D to look at the metal Door.";
  79.         if (Input.GetKeyDown(KeyCode.T))        {myState = States.table;}
  80.         else if (Input.GetKeyDown(KeyCode.S))   {myState = States.kitchen;}
  81.     }
  82.    
  83.     void right_corridor () {
  84.         text.text = "To your right there is a pair of wooden doors, this looks like a main entrance to a room. The lock on " +
  85.             "them looks the same as the one in your cell.\n\n" +
  86.                 "Press R to Return to the standing, or O to open the double doors." ;
  87.         if      (Input.GetKeyDown(KeyCode.R))   {myState = States.corridor_0;}
  88.         else if (Input.GetKeyDown(KeyCode.O))   {myState = States.canteen;}
  89.     }  
  90.    
  91.     void courtyard () {
  92.         text.text = "You walk through the courtyard dressed as a cleaner. " +
  93.             "The guard tips his hat at you as you waltz past, claiming " +
  94.                 "your freedom. You heart races as you walk into the sunset.\n\n" +
  95.                 "Press P to Play again." ;
  96.         if (Input.GetKeyDown(KeyCode.P))        {myState = States.cell;}
  97.     }  
  98.    
  99.     void left_corridor () {
  100.         text.text = "Being as you cannot see the end of the corridor through the darkness, you take the torch from the wall " +
  101.             "and head left. You soon come to a dead end, in the wall ther is a wooden door similar to the one on " +
  102.                 "Yyour cell.\n\n" +
  103.                 "Press R to Return to the corridor." ;
  104.         if (Input.GetKeyDown(KeyCode.R))        {myState = States.corridor_0;}
  105.     }
  106.    
  107.     void cell_2 () {
  108.         text.text = "Unfortunately weilding a puny hairclip hasn't given you the " +
  109.             "confidence to walk out into a courtyard surrounded by armed guards!\n\n" +
  110.                 "Press R to Retreat down the stairs" ;
  111.         if (Input.GetKeyDown(KeyCode.R))        {myState = States.canteen;}
  112.     }
  113.    
  114.     void stairs_2() {
  115.         text.text = "You feel smug for picking the closet door open, and are still armed with " +
  116.             "a hairclip (now badly bent). Even these achievements together don't give " +
  117.                 "you the courage to climb up the staris to your death!\n\n" +
  118.                 "Press R to Return to the corridor";
  119.         if (Input.GetKeyDown(KeyCode.R))        {myState = States.corridor_2;}
  120.     }
  121.    
  122.     void cell () {
  123.         text.text = "You wake up in a prison cell, the walls are made of stone blocks and moss grows in the cracks. " +
  124.             "On the bed you can see a pile of filthy sheets, on the wall hangs a broken mirror and the heavy " +
  125.                 "wooden door appears to be locked.\n\n" +
  126.                 "Press S to look at the Sheets, M to look at the Mirror or L to look at the Lock" ;
  127.         if      (Input.GetKeyDown(KeyCode.S))   {myState = States.sheets_0;}
  128.         else if (Input.GetKeyDown(KeyCode.M))   {myState = States.mirror;}
  129.         else if (Input.GetKeyDown(KeyCode.L))   {myState = States.lock_0;}
  130.     }
  131.    
  132.     void mirror() {
  133.         text.text = "The mirror is smashed into fragments that are still loosley attatched to the frame. " +
  134.             "One of the fragments seems to stick out more than the others and appears to be very loose.\n\n" +
  135.                 "Press T to Take the fragment, or R to continue Roaming cell" ;
  136.         if      (Input.GetKeyDown(KeyCode.T))   {myState = States.cell_mirror;}
  137.         else if (Input.GetKeyDown(KeyCode.R))   {myState = States.cell;}
  138.     }
  139.    
  140.     void cell_mirror() {
  141.         text.text = "After grabbing the mirror fragment, all of the pieces fell from the frame to the ground with a loud crash! " +
  142.             "When you look back at the frame, you notice a small bronze key hanging from a thread, you tie the thread around " +
  143.                 "your neck and you stand up to survey your cell once more.\n\n" +
  144.                 "Press S to view Sheets, or L to view Lock" ;
  145.         if      (Input.GetKeyDown(KeyCode.S))   {myState = States.sheets_1;}
  146.         else if (Input.GetKeyDown(KeyCode.L))   {myState = States.lock_1;}
  147.     }
  148.    
  149.     void sheets_0 () {
  150.         text.text = "You can't believe you sleep in these things. Surely it's time somebody changed them. They are covered in " +
  151.             "stains and marks of countless colours and you're glad you dont recognise the stain on the floor beneath the matress. " +
  152.                 "The sheets offer you no assistance in escaping.\n\n" +
  153.                 "Press R to continue Roaming your cell" ;
  154.         if (Input.GetKeyDown(KeyCode.R))        {myState = States.cell;}
  155.     }
  156.    
  157.     void sheets_1() {
  158.         text.text = "Having a key doesn't seem to make the sheets look any better and they still offer you no help in escaping.\n\n " +
  159.             "Press R to continue Roaming your cell" ;
  160.         if (Input.GetKeyDown(KeyCode.R))        {myState = States.cell_mirror;}
  161.     }
  162.    
  163.     void lock_0() {
  164.         text.text = "The metal lock on the door is locked. Looking through the small keyhole you can see a dark corridor outside " +
  165.             "with faint light reflecting on the we floor. The walls of the corridor seem to be made from the same stone as " +
  166.                 "your cell. Without a way to open the lock, it's useless.\n\n" +
  167.                 "Press R to continue Roaming your cell" ;
  168.         if (Input.GetKeyDown(KeyCode.R))        {myState = States.cell;}
  169.     }
  170.    
  171.     void lock_1() {
  172.         text.text = "Looking closer at the lock, you can see that the thick metal is scratched and dented from years of use, " +
  173.             "the small holes in the door above the lock also appear to show that it has been replaced several times. " +
  174.                 "The lock needs a small key to open it, perhapse the one you found will do the trick.\n\n" +
  175.                 "Press O to Open, or R to Return to your cell" ;
  176.         if (Input.GetKeyDown (KeyCode.O))       {myState = States.corridor_0;}
  177.         else if (Input.GetKeyDown (KeyCode.R))  {myState = States.cell_mirror;}
  178.     }              
  179.    
  180.     void corridor_0() {
  181.         text.text = "The lock makes a quiet click after you insert the key and twist with some effort, it appears that the lock has not been used recently. " +
  182.             "Stepping out into the corridor you can see no end to the left and a set of wooden doors down the corridor to your right. The walls of " +
  183.                 "were indeed made from the same stone, and the light eminates from a torch on the wall opposite your cell.\n\n" +
  184.                 "Press L to go Left or R to go Right";
  185.         if (Input.GetKeyDown (KeyCode.L))       {myState = States.left_corridor;}
  186.         else if (Input.GetKeyDown (KeyCode.R))  {myState = States.right_corridor;}
  187.     }
  188. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement