Hello,
I’m having trouble playing the MonoDevelop code that I reluctantly saved and tried to play on Unity. Any help someone could give me would be much appreciated!
Thanks,
J
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class TextController : MonoBehaviour {
public Text text;
private enum States {cell, mirror, sheets_0, lock_0, cell_mirror, sheets_1, lock_1, freedom};
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.sheets_1) {state_sheets_1();}
else if (myState == States.lock_0) {state_lock_0();}
else if (myState == States.lock_1) {state_lock_1();}
else if (myState == States.mirror) {state_mirror();}
else if (myState == States.cell_mirror) {state_cell_mirror();}
else if (myState == States.freedom) {state_freedom();}
}
void state_cell () {
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 to view Sheets, M to view Mirror, and 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_mirror() {
text.text = "It seems like you can easily rip it off of the wall. \n\n" +
"press T to Take the mirror or R to Return to the cell."
if (Input.GetKeyDown(KeyCode.T)) {myState = States.cell_mirror;}
else if (Input.GetKeyDown(KeyCode.R)) {myState = States.cell;}
}
void cell_mirror() {
text.text = "What are you waiting for? Now is the time to escape! \n\n" +
"There are dirty sheets on the bed, a spot where the mirror was, " +
"and that damn door is still locked!" n\n"
"press T to Take the mirror or R to Return to the cell. " +
if (Input.GetKeyDown(KeyCode.S)) {myState = States.sheets_1;}
else if (Input.GetKeyDown(KeyCode.L)) {myState = States.lock_1;}
}
void state_sheets_0 () {
text.text = "You can't believe you sleep in these filthy sheets every night. " +
"It has to be laundry day soon...you can't take prison life any longer. " +
"Time to get out of Dodge!\n\n" +
"Press R to Return to roaming your cell" ;
if (Input.GetKeyDown(KeyCode.R)) {myState = States.cell;
}
}
void state_lock_0 () {
text.text = "You try to jimmy the lock, but it's no use. Then you notice that there is a combination on the front, " +
"but you can't see the numbers. If only there was a way to show wehre the dirty fingerprints last touched " +
"You have to act quickly before a prison guard hears you.\n\n" +
"Press R to Return to roaming your cell" ;
if (Input.GetKeyDown(KeyCode.R)) {myState = States.cell;}
}
void state_lock_1 () {
text.text = "You carefully stick the mirror through the bars and turn it around " +
"so you can see the numbers. You can barely make out the fingerprints around the buttons. " +
"You press the dirty buttons and hear a click!\n\n" +
"Press O to Open or Press R to Return to roaming your cell" ;
if (Input.GetKeyDown(KeyCode.O)) {myState = States.freedom;}
else if (Input.GetKeyDown(KeyCode.R)) {myState = States.cell_mirror;}
}
void state_freedom () {
text.text = "Congratulations, You are FREE!!!\n\n" +
"Press P to play again" ;
if (Input.GetKeyDown(KeyCode.p)) {myState = States.cell;}
}
}

