I am currently working on a text adventure game that is about escaping a prison, but when I tested the code, nothing happened when I pressed L or R. Any help would be greatly appreciated.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TextController : MonoBehaviour {
public Text text;
private enum State {knife, mirror, pillow, sheet, cell, bolt};
private bool Knife = false;
private State mystate;
// Use this for initialization
void Start () {
text.text="You are a prisoner, in a cell, at a low security prison. " +
"In your cell you have a hand held mirror, a makeshift knife, " +
"and a pillow on your bed. The lock to your cell is a rusty barrel bolt " +
"that is very loose
" +
“Press z to pick up the pillow, k to pickup the knife, and m to pickup the mirror”;
}
// Update is called once per frame
void Update ()
{
if (mystate == State.cell) {
text.text="You are a prisoner, in a cell, at a low security prison. " +
"In your cell you have a hand held mirror, a makeshift knife, " +
"and a pillow on your bed. The lock to your cell is a rusty barrel bolt " +
"that is very loose
" +
“Press p to pick up the pillow, k to pickup the knife, and m to pickup the mirror”;
}
if (Input.GetKeyDown(KeyCode.K)) {
knife();
mystate = State.knife;
}
}
void knife ()
{
if (Knife == false) {
text.text = "As you inspect your knife you notice it has a very long blade.
" +
“Press L to put the knife in your pocket or press R to leave it where it is”;
}
else if (Knife == true) {
text.text = "As you inspect your knife you notice it has a very long blade.
" +
“Press R to leave it where it is”;
}
if (Input.GetKeyDown (KeyCode.L)) {
Knife = true;
mystate = State.cell;
}
if(Input.GetKeyDown (KeyCode.R)) {
mystate = State.cell;
}
}
}