Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- // Game Jolt link: https://gamejolt.com/games/PrisonEscapeAlpha/278957
- public class TextController : MonoBehaviour {
- public Text text; // public/private (public if able to be linked and called) Type veriablename
- private enum States {
- starting, cell, mirror, sheets_0, lock_0, cell_mirror, sheets_1, lock_1, mirror_obtained, door1, Beta,
- unlock_door,corridor_0, stairs_0, floor, closet_door, hairclip_yes, corridor_1, stairs_1, closet_in, corridor_2, stairs_2,
- corridor_3, courtyard}; //a small table of states
- private States myState; // Private (cant be called in engine) of enum States, called via myState
- public GameObject Beta;
- public InputField DevCheatsField;
- public GameObject DevCheats;
- // Use this for initialization
- void Start () {
- myState = States.starting; // sets the starting state to starting
- DevCheats.SetActive(false);
- }
- // Update is called once per frame
- void Update ()
- {
- // print (myState); // continously prints state
- devEnabled();
- if (myState == States.starting) {
- text.text = "Press enter to start game!";
- if (Input.GetKeyDown (KeyCode.Return)) { // if start/enter is pressed, will continue to cell
- myState = States.cell;
- }
- }
- if (myState == States.cell) {cell();}
- else if (myState == States.sheets_0) {sheets_0();}
- else if (myState == States.mirror) {mirror();}
- else if (myState == States.lock_0) {lock_0();}
- else if (myState == States.cell_mirror) {cell_mirror1();}
- else if (myState == States.lock_1) {lock1();}
- else if (myState == States.mirror_obtained) {mirror_obtained();}
- else if (myState == States.door1) {unlock_door();}
- else if (myState == States.sheets_1) {sheets_1();}
- else if (myState == States.Beta) {BetaController();}
- else if (myState == States.unlock_door) {unlock_door();}
- else if (myState == States.corridor_0) {corridor_0();}
- else if (myState == States.floor) {floor();}
- else if (myState == States.stairs_0) {stairs_0();}
- else if (myState == States.closet_door) {closet_door();}
- else if (myState == States.hairclip_yes) {StartCoroutine( hairclip_yes());}
- else if (myState == States.corridor_1) {corridor_1();}
- else if (myState == States.stairs_1) {stairs_1();}
- else if (myState == States.closet_in) {closet_in();}
- else if (myState == States.corridor_2) {corridor_2();}
- else if (myState == States.stairs_2) {stairs_2();}
- else if (myState == States.corridor_3) {corridor_3();}
- else if (myState == States.courtyard) {courtyard();}
- }
- #region Alpha features (stages/text)
- void mirror_obtained ()
- {
- text.text = "You moved the mirror and now have a good view " +
- "of the lock on the other side of the door.\n\n" +
- "Press C to continue roaming your cell, or L to view the lock.";
- if (Input.GetKeyDown (KeyCode.C)) {
- myState = States.cell_mirror;
- }
- if (Input.GetKeyDown (KeyCode.L)) {
- myState = States.lock_1;
- }
- }
- void cell ()
- {
- // print ("Return successfully pressed.");
- text.text = "You are in a prison cell, and you want to escape. There are " +
- "some dirty sheets on the bed, a mirror on the wall, and the door " +
- "is locked from the outside.\n\n" +
- "Press S view Sheets, M to view Mirror, and L to view Lock";
- if (Input.GetKeyDown (KeyCode.S)) {
- myState = States.sheets_0;
- }
- if (Input.GetKeyDown (KeyCode.M)) {
- myState = States.mirror;
- }
- if (Input.GetKeyDown (KeyCode.L)) {
- myState = States.lock_0;
- }
- }
- void sheets_0 ()
- {
- // print ("S was pressed.");
- text.text = "Some old rags lay carelessly on the wooden frame that is your bed. " +
- "\n That doesn't seem very comfortable!\n\n " +
- "Press R to continue roaming your cell.";
- if (Input.GetKeyDown (KeyCode.R)) {
- myState = States.cell;
- }
- }
- void lock_0 () {
- // print ("L was pressed.");
- text.text = "An old rusty lock hangs outside of your door. " +
- "If only you had a mirror so you could lockpick it...\n\n" +
- "Press R to continue to roam your cell.";
- if (Input.GetKeyDown (KeyCode.R)) {
- myState = States.cell;
- }
- }
- void mirror ()
- {
- // print ("M was pressed.");
- text.text = "An old dusty mirror meets your eye. You use it daily to adjust your " +
- "looks and stay sharp.\n " +
- "The mirror looks like it can be moved around if pushed with great strength.\n\n " +
- "Press R to roam your cell, press M to move the mirror.";
- if (Input.GetKeyDown (KeyCode.R)) {
- // print ("R was pressed.");
- myState = States.cell;
- }
- if (Input.GetKeyDown (KeyCode.M)) {
- // print ("M was pressed.");
- myState = States.mirror_obtained;
- }
- }
- void cell_mirror1 ()
- {
- text.text = "You are in a prison cell, and you want to escape. There are " +
- "some dirty sheets on the bed and a door that " +
- "is locked from the outside.\n\n" +
- "Press S view Sheets, and L to view Lock using the mirror.";
- if (Input.GetKeyDown (KeyCode.S)) {
- // print ("S was pressed.");
- myState = States.sheets_1;
- }
- if (Input.GetKeyDown (KeyCode.L)) {
- // print ("L was pressed.");
- myState = States.lock_1;
- }
- }
- void sheets_1 ()
- {
- if (Input.GetKeyDown (KeyCode.S)) {
- // print ("S was pressed.");
- text.text = "Some old rags lay carelessly on the wooden frame that is your bed. " +
- "\n That doesn't seem very comfortable, but dont worry, you won't sleep there anymore!\n\n " +
- "Press R to continue roaming your cell.";
- }
- if (Input.GetKeyDown (KeyCode.R)) {
- myState = States.cell_mirror;
- }
- }
- void lock1 ()
- {
- if (Input.GetKeyDown (KeyCode.L)) {
- // print ("L was pressed.");
- text.text = "The lock is a plain old cell lock, it's nothing " +
- "you can't handle with that mirror.\n\n" +
- "Press U to unlock the cell door, or R to roam your cell.";
- }
- if (Input.GetKeyDown (KeyCode.U)) {
- myState = States.unlock_door;
- }
- if (Input.GetKeyDown (KeyCode.R)) {
- myState = States.cell_mirror;
- }
- }
- void unlock_door ()
- {
- text.text = "You open the cell door and check your surroundings..\n " +
- "Nobody noticed your escape, you are in the clear!\n\n" +
- "Press Enter to check your surroundings.";
- if (Input.GetKeyDown (KeyCode.Return)) {
- myState = States.Beta;
- }
- }
- #endregion
- #region Start of Beta (transition to corridor_0)
- void BetaController ()
- {
- if (Beta.name != "Beta") {
- if (Input.GetKeyDown (KeyCode.Return)) {
- text.text = "Find it out soon when the beta releases!";
- }
- } else if (Beta.name == "Beta") {
- print ("Start of Beta.");
- myState = States.corridor_0;
- }
- }
- #endregion
- #region Beta features (stages/text)
- void corridor_0 () {
- text.text = "You are standing in a corridor.\nThere is a closet and some stairs leading to the courtyard." +
- " There is some old trash laying across the floor of the corridor.\n\n" +
- "C to view the Closet, F to inspect the Floor, S to climb the Stairs.";
- if (Input.GetKeyDown (KeyCode.C)) {
- myState = States.closet_door;
- }
- if (Input.GetKeyDown (KeyCode.F)) {
- myState = States.floor;
- }
- if (Input.GetKeyDown (KeyCode.S)) {
- myState = States.stairs_0;
- }
- }
- void stairs_0 () {
- text.text = "It would not be wise to go to the courtyard. " +
- "The guards would notice you got out of your cell, " +
- "and you'd end up back in it.\n\n" +
- "Press R return to the corridor.";
- if (Input.GetKeyDown (KeyCode.R)) {
- myState = States.corridor_0;
- }
- }
- void floor () {
- text.text = "There is some old trash laying across the floor of the corridor.\n" +
- "Would you like to inspect it further?\n\n" +
- "Press Enter if Yes, press Backspace if No.";
- if (Input.GetKeyDown (KeyCode.Return)) {
- myState = States.hairclip_yes;
- }
- if (Input.GetKeyDown (KeyCode.Backspace)) {
- myState = States.corridor_0;
- }
- }
- void closet_door () {
- text.text = "You stand in front of a tall closet, however, it is locked. " +
- "If only you could unlock it somehow.\n\n" +
- "Press R to return to the corridor.";
- if (Input.GetKeyDown (KeyCode.R)) {
- myState = States.corridor_0;
- }
- }
- void corridor_1 () {
- text.text = "You are standing in a corridor.\nThere is a closet and some stairs leading to the courtyard." +
- " There is some old trash laying across the floor of the corridor.\n\n" +
- "P to pick the Closet lock or S to climb the Stairs.";
- if (Input.GetKeyDown (KeyCode.P)) {
- myState = States.closet_in;
- }
- if (Input.GetKeyDown (KeyCode.S)) {
- myState = States.stairs_1;
- }
- }
- void stairs_1 () {
- text.text = "It would not be wise to go to the courtyard. " +
- "The guards would notice you got out of your cell, " +
- "and you'd end up back in it.\n\n" +
- "Press R return to the corridor.";
- if (Input.GetKeyDown (KeyCode.R)) {
- myState = States.corridor_1;
- }
- }
- void closet_in () {
- text.text = "You stand in front of a tall closet, which now is unlocked. " +
- "There are some cleaner clothes in the closet that seem to fit you. " +
- "\n\nPress R to return the corridor or D to dress up in the cleaner clothing.";
- if (Input.GetKeyDown (KeyCode.R)) {
- myState = States.corridor_2;
- }
- if (Input.GetKeyDown (KeyCode.D)) {
- myState = States.corridor_3;
- }
- }
- void corridor_2 () {
- text.text = "You are standing in a corridor.\nThere is a closet and some stairs leading to the courtyard." +
- " There is some old trash laying across the floor of the corridor.\n\n" +
- "B to go back to the Closet or S to climb the Stairs.";
- if (Input.GetKeyDown (KeyCode.B)) {
- myState = States.closet_in;
- }
- if (Input.GetKeyDown (KeyCode.S)) {
- myState = States.stairs_2;
- }
- if (Input.GetKeyDown (KeyCode.D)) {
- myState = States.corridor_3;
- }
- }
- void stairs_2 () {
- text.text = "It would not be wise to go to the courtyard. " +
- "The guards would notice you got out of your cell, " +
- "and you'd end up back in it.\n\n" +
- "Press R return to the corridor.";
- if (Input.GetKeyDown (KeyCode.R)) {
- myState = States.corridor_2;
- }
- }
- void corridor_3 () {
- text.text = "You are now dressed as a cleaner, guard will be unable to recognise you " +
- "if you stay in your role well enough.\n\n " +
- "Press U to undress or S to climb the stairs.";
- if (Input.GetKeyDown (KeyCode.U)) {
- myState = States.closet_in;
- }
- if (Input.GetKeyDown (KeyCode.S)) {
- myState = States.courtyard;
- }
- }
- void courtyard () {
- text.fontSize = 18;
- text.text = "You climb up the stairs out to the courtyard. There is a guardpost " +
- "situated at the gate of the prison. You knock on the guardpost's window " +
- "to get the guard's attention. The guard looks at you form his chair, and " +
- "you request him to open the gate, as you 'forgot some of your cleaning items'. " +
- "He opens the gate and you exit the prison.\n\n " +
- "You are now officially a free man.\n\n " +
- "Thank you for playing!\n " +
- "Press Esc. to exit the game.";
- if (Input.GetKeyDown (KeyCode.Escape)) {
- Application.Quit();
- }
- }
- IEnumerator hairclip_yes () {
- text.text = "Among the trash you find an old hairclip." +
- "\nYou put the hairclip in your pocked as it might come to use to you.";
- yield return new WaitForSeconds(4.5f);
- myState = States.corridor_1;
- }
- #endregion
- #region Developer Cheats
- void devEnabled () {
- if (Input.GetKeyDown (KeyCode.BackQuote)) {
- DevCheats.SetActive(true);
- }
- if (DevCheatsField.text == "Courtyard") {
- if (Input.GetKeyDown (KeyCode.Tab)) {
- myState = States.courtyard;
- }
- }
- if (DevCheatsField.text == "Corridor_0") {
- if (Input.GetKeyDown (KeyCode.Tab)) {
- myState = States.corridor_0;
- }
- }
- }
- #endregion
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement