Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- int (x = 0);
- int (clothes = 0);
- public class TextController : MonoBehaviour {
- public Text text;
- private enum States {cell, mirror, lock_0, sheets_0, cell_mirror, lock_1, sheets_1, corridor, lock_open, freedom, cell_think, up_stairs, cafeteria, showers, findkey, wardens, basement, guard, exit_0, exit_1, end_0, end_1}
- private States myState;
- // Use this for initialization
- void Start () {
- myState = States.cell;
- }
- // Update is called once per frame
- void Update () {
- print(myState);
- if (myState == States.cell) {state_cell();}
- else if (myState == States.sheets_0) {state_sheets_0();}
- else if (myState == States.lock_0) {state_lock_0();}
- else if (myState == States.mirror) {state_mirror();}
- else if (myState == States.lock_1) {state_lock_1();}
- else if (myState == States.cell_mirror) {state_cell_mirror();}
- else if (myState == States.lock_open) {state_lock_open();}
- else if (myState == States.corridor) {state_corridor();}
- else if (myState == States.cell_think) {state_cell_think();}
- else if (myState == States.up_stairs) {state_up_stairs();}
- else if (myState == States.cafeteria) {state_cafeteria();}
- else if (myState == States.showers) {state_showers();}
- else if (myState == States.findkey) {state_findkey();}
- else if (myState == States.wardens) {state_wardens();}
- else if (myState == States.basement) {state_basement();}
- else if (myState == States.guard) {state_guard();}
- else if (myState == States.exit_1) {state_exit_1();}
- else if (myState == States.exit_0) {state_exit_0();}
- else if (myState == States.end_0) {state_end_0();}
- else if (myState == States.end_1) {state_end_1();}
- }
- void state_cell() {
- text.text = "You wake up to find yourself stuck in an abandoned prison " +
- "cell that is locked from the outside with sheets on the bed " +
- "and a mirror on the wall.\n\n" + "Press 'S' to view sheets\n\n" +
- "Press 'M' to view mirror\n\n" + "Press 'L' to view lock.";
- if (Input.GetKeyDown(KeyCode.S)) {myState = States.sheets_0;}
- else if (Input.GetKeyDown(KeyCode.M)) {myState = States.mirror;}
- else if (Input.GetKeyDown(KeyCode.L)) {myState = States.lock_0;}
- }
- void state_sheets_0() {
- text.text = "These sheets are freshly changed, very strange indeed. There " +
- "must be someone here still. The real question is, why am I here? " +
- "Lets continue searching the cell. \n\n" +
- "Press 'R' to return to roaming the cell";
- if (Input.GetKeyDown(KeyCode.R)) {myState = States.cell;}
- }
- void state_mirror() {
- text.text = "You look at yourself in the mirror and see an insane, unshaven and " +
- "strangly unfamiliar face. You wonder, 'Who am I?' then 'Just brush it " +
- "off and keep looking.' \n\n" +
- "Press 'R' to continue roaming the cell";
- if (Input.GetKeyDown(KeyCode.R)) {myState = States.cell;}
- }
- void state_lock_0() {
- text.text = "The door is shut tightly with an amazingly strong lock. How about " +
- "we keep looking for something to open it.\n\n" +
- "Press 'R' to continue roaming the cell";
- if (Input.GetKeyDown(KeyCode.R)) {myState = States.cell_think;}
- }
- void state_lock_1() {
- text.text = "The door is shut tightly with an amazingly strong lock. How about " +
- "we keep looking for something to open it.\n\n" +
- "Press 'M' to go back to mirror\n\n" + "Press 'R' to continue searching";
- if (Input.GetKeyDown(KeyCode.R)) {myState = States.cell;}
- else if (Input.GetKeyDown(KeyCode.M)) {myState = States.cell_mirror;}
- }
- void state_cell_mirror() {
- text.text = "After realizing you could break the glass to open the lock, you have a choice to either " +
- "break the glass with your fist and risk breaking it, or sit and wait for someone to come.\n\n" +
- "Press 'T' to break the glass and go to the lock\n\n" + "Press 'M' to sit and wait";
- if (Input.GetKeyDown(KeyCode.T)) {myState = States.lock_open;}
- else if (Input.GetKeyDown(KeyCode.M)) {myState = States.corridor;}
- }
- void state_lock_open() {
- text.text = "You take the piece of broken glass over to the lock.\n\n" +
- "Press 'O' to open the lock with the glass\n\n" +
- "Press 'R' to roam the cell";
- if (Input.GetKeyDown(KeyCode.O)) {myState = States.corridor;}
- else if (Input.GetKeyDown(KeyCode.R)) {myState = States.cell;}
- }
- void state_cell_think() {
- text.text = "After seeing that mirror, you wonder if maybe it can be used on the lock somehow. Lets try " +
- "going back to the mirror. \n\n" +
- "Press 'M' to go back to the mirror";
- if (Input.GetKeyDown(KeyCode.M)) {myState = States.cell_mirror;}
- }
- void state_corridor() {
- text.text = "One you have exitted the cell, you are immediatly forced to make another decision. \n\n" +
- "Press 'LeftArrow' to go to the stairs towards the left \n\n Press 'RightArrow' to go towards " +
- "the cafeteria\n\n Press 'UpArrow' to go towards the showers";
- if (Input.GetKeyDown(KeyCode.LeftArrow)) {myState = States.up_stairs;}
- else if (Input.GetKeyDown(KeyCode.RightArrow)) {myState = States.cafeteria;}
- else if (Input.GetKeyDown(KeyCode.UpArrow)) {myState = States.showers;}
- }
- void state_up_stairs() {
- if (x == 0) {
- text.text = "You come to a flight of stairs and go up them, all that is at the top is a janitor's closet " +
- "that is locked.\n\n Press 'DownArrow' to go back";
- if (Input.GetKeyDown(KeyCode.DownArrow)) {myState = States.corridor;}
- }
- else if (x == 1) {
- text.text = "You can open up the janitor's closet with the key and you put on the guard clothing.";
- int clothes = (clothes + 1);
- }
- }
- void state_cafeteria() {
- text.text = "You enter the cafeteria and see nothing but old food trays and garbage all over. " +
- "Possibly something in the garbage, most likely not. There are two doors that " +
- "leads to the Warden's office and hallway leading to 'who knows where'.\n\n" +
- "Press 'C' to check the garbage\n\n Press 'W' to go to the Warden's office\n\n Press 'H' to go to the hallway";
- if (Input.GetKeyDown(KeyCode.C)) {
- myState = States.findkey;
- }
- else if (Input.GetKeyDown(KeyCode.W)) {
- myState = States.wardens;
- }
- else if (Input.GetKeyDown(KeyCode.H)) {
- myState = States.guard;
- }
- }
- void state_findkey() {
- text.text = "You have found a duplicated key, maybe it works for the janitor's closet.\n\n" +
- "Press 'R' to go back to the corridor";
- x = x + 1;
- if (Input.GetKeyDown(KeyCode.R)) {
- myState = States.corridor;
- }
- }
- void state_showers() {
- text.text = "Nothing in here but moldy showers.\n\n" +
- "Press 'R' to return to the corridor";
- if (Input.GetKeyDown(KeyCode.R)) {
- myState = States.corridor;
- }
- }
- void state_wardens() {
- text.text = "Nothing worth while in here.\n\n Press 'R' to return to corridor";
- if (Input.GetKeyDown(KeyCode.R)) {
- myState = States.corridor;
- }
- }
- void state_basement() {
- text.text = "You walk down the creeky stairs and almost trip over a rat scurrying around down there." +
- "You think to yourself, 'Seems like nobody has been down here in a long time.'" +
- "There is a little hole over in the corner behind the boxes. Maybe we should check it out.\n\n" +
- "Press 'C' to check it out";
- if (Input.GetKeyDown(KeyCode.C)) {
- myState = States.exit_0;
- }
- }
- void state_guard() {
- if (clothes == 0) {
- text.text = "You turn the corner of this old and moldy hallway. There is a guard sitting there, maybe if you had a " +
- "Guard's clothing you could get by just fine. \n\n Press 'C' to go back to the corridor";
- if (Input.GetKeyDown(KeyCode.C)) {
- myState = States.corridor;
- }
- }
- else if (clothes == 1) {
- text.text = "There is a gaurd around the corner, because you have a guard's outfit you can get by him just fine.\n\n" +
- "Press 'Space' to continue";
- if (Input.GetKeyDown(KeyCode.Space)) {
- myState = States.exit_1;
- }
- }
- }
- void state_exit_1() {
- text.text = "You walk by the Guard and give him a nod, after exitting the building you see lines of police cars " +
- "and SWAT trucks. Looks like you are not going to be getting out of this one. You are then put into handcuffs by a " +
- "police officer and thrown in the back of a SWAT truck. 'Maybe there was a better way to escape'.\n\n Press 'Space' to continue";
- if (Input.GetKeyDown(KeyCode.Space)) {
- myState = States.end_1;
- }
- }
- void state_exit_0() {
- text.text = "You exit the building through the tunnel in the wall. After running away from the building someone stops " +
- "you and says that they know you and have an apartment you can stay at.\n\n Press 'Space' to continue";
- if (Input.GetKeyDown(KeyCode.Space)) {
- myState = States.end_0;
- }
- }
- void state_end_0() {
- text.text = "You have won the game! Congradulations and thank you for playing my game. Hope you enjoyed!";
- }
- void state_end_1() {
- text.text = "You have gotten to the end of the game but you did not win. Maybe try again to win! ;) Hope you enjoyed!";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement