Hey everbody!
TextController.cs
public Text myText;
private enum States {intro, cell, sheets_0, sheets_1, lock_0, lock_1, mirror, cell_mirror,
corridor_0, corridor_1, corridor_2, corridor_3, stairs_0, stairs_1,
stairs_2, closet_door, in_closet, floor, courtyard}
private States myStates;
// Use this for initialization
void Start () {
myStates = States.intro;
}
// Update is called once per frame
void Update () {
print (myStates);
if (myStates == States.intro) {intro();}
else if (myStates == States.cell) {cell();}
}
// Introduction
void intro () {
myText.text = "Welcome to Prison, a text adventure game\n\n" +
"Press (Space) key to start.";
if (Input.GetKeyDown(KeyCode.Space)) {print("Space key pressed!"); cell();}
}
// Cell
void cell () {
myText.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, Press (M) to view Mirror, Press (L) to view Lock.";
if (Input.GetKeyDown(KeyCode.S)) {print("S key pressed!"); sheets_0();}
else if (Input.GetKeyDown(KeyCode.M)) {print("M key pressed!"); mirror();}
else if (Input.GetKeyDown(KeyCode.L)) {print("L key pressed!"); lock_0();}
}
The problem is that I start the game, the first screen show up the text but when I press a button to continue to the next step, the next step’s screen show up for almost a second then the screen returns to the original one when the game started.
I managed to do all the work successfully on my own, and when I press B in MonoDevelop it states that the Build Succeed. Personally I think that there is something wrong with the Update section, but can’t figure it out.
Can someone help me with this?
Thanks in advance!