Question by
Haugkall · Jan 26, 2018 at 02:27 PM ·
formatting
Formatting issue (newb)
I'm getting a "A namespace can only contain types and namespace declarations" on line "void Update () {" I started learning this yesterday so I have no idea why it's happening. Are my brackets incorrect?
public class TextController : MonoBehaviour {
public Text text;
private enum States {what, who, inn};
private States myState;
// Use this for initialization
void Start () {
myState = States.what;
}
}
// Update is called once per frame
void Update () {
print (myState);
if (myState == States.what) {
state_what();
}
}
void state_what () {
text.text = "What do you want stranger?\n\n" +
"Who are you? 1\n" +
"Do you know the way to the nearest inn? 2 \n" ;
if (Input.GetKeyDown(KeyCode.Alpha1))
state_who ();
if else (Input.GetKeyDown(KeyCode.Alpha2))
state_inn ();
}
void state_inn () {
text.text = "There are no inns around these parts.\n\n" +
"That's too bad 1" ;
if (Input.GetKeyDown(KeyCode.Alpha1))
state_what ();
}
void state_who () {
text.text = "I'm your worst nightmare, die!" ;
if (Input.GetKeyDown(KeyCode.Alpha1))
state_inn ();
}
Comment