So I’ve been working on a text based game and I just finished writing out the code. I have two current errors in my code. One is CS1525 unexpected symbol ‘{’ which is on line 85. The next error has two occurrences in the code. It is CS0116 a namespace can only contain types and namespace declarations. there is one error on line 89 and 98.
If anyone could help me i’d really appreciate it
My code is here:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class TextController : MonoBehaviour {
public Text text;
private enum States {boat, cabin_0, atf, button, cabin_1, key, ulb, lifeboat};
public States myState;
// Use this for initialization
void Start () {
myState = States.boat;
}
// Update is called once per frame
void Update () {
print (myState);
if (myState == States.boat) {state_boat();}
else if (myState == States.cabin_0) {state_cabin_0();}
else if (myState == States.atf) {state_atf();}
else if (myState == States.button) {state_button();}
else if (myState == States.cabin_1) {state_cabin_1();}
else if (myState == States.key) {state_key();}
else if (myState == States.ulb) {state_ulb();}
else if (myState == States.lifeboat) {state_lifeboat();}
}
void state_boat () {
text.text = "You are on your boat and all you remember was a sudden bang. You look towords " +
"the cabin of the boat only to see it filling with more water by the second. " +
"You know that there is a lifeboat on the boat but you need to find out how to " +
"activate it.
" +
"Press C to look further into the cabin, A to look around the front of the boat and B to " +
“investigate the lifeboat button.”;
if (Input.GetKeyDown(KeyCode.C)) {myState = States.cabin_0;}
else if (Input.GetKeyDown(KeyCode.A)) {myState = States.atf;}
else if (Input.GetKeyDown(KeyCode.B)) {myState = States.button;}
}
void state_cabin_0 () {
text.text = "You walk into the cabin as water gushes through the hole in the hull " +
"You notice that there is a sign that states 'Lifeboat button outside (requires key) " +
"
" +
“Press R to return to the deck of the boat”;
if (Input.GetKeyDown(KeyCode.R)) {myState = States.boat;}
}
void state_atf () {
text.text = "You walk around the side of the boad to notice what you have hit, you hit a rock which teared " +
"right through the hull. You also notice a lot of junk here with a chest at the end of the boat. " +
"
" +
“Press L too Look into the chest, press R to return ot the deck of the boat”;
if (Input.GetKeyDown(KeyCode.L)) {myState = States.key;}
else if (Input.GetKeyDown (KeyCode.R)) {myState = States.boat;}
}
void state_button() {
text.text = "You walk over to the end of the boat and notice that there is a button that is locked over by a cover. " +
"It is the button to activate the lifeboat, the only problem is you need to find the key somewhere. " +
"I hope that it didnt fall off the edge!
" +
“Press R to return ot the deck of the boat”;
if (Input.GetKeyDown (KeyCode.R)) {myState = States.boat;}
}
void state_cabin_1() {
text.text = "You walk back into the cabin to find that the water is now reaching your knee, you need to act fast and " +
"get that lifeboat on the water before the boat goes under! " +
"
" +
“Press R to return to the crate around the front of the boat”;
if (Input.GetKeyDown (KeyCode.R)) {myState = States.key;}
}
void state_key() {
text.text = "You open the lid of the crate and theres boxes everywhere you pick out one box in particular the box says" +
" 'USE ONLY IN AN EMERGENCY' You crack it open and find the key to the lifeboat button as well as some first aid and flares " +
"
" +
“Press C to look in the cabin again, press B to go to the unlock Button”;
if (Input.GetKeyDown(KeyCode.C)) {myState = States.cabin_1;}
else if (Input.GetKeyDown(KeyCode.B) {myState = States.ulb;}
}
void state_ulb () {
text.text = "You run down the side of the boat, you get the key out of your pocket and insert it into the key slot and turn it. " +
"You feel a sense of relief as it unlocks the lid of the button. " +
"
" +
“Press L activate the Lifeboat”;
if (Input.GetKeyDown (KeyCode.L)) {myState = States.lifeboat;}
}
void state_lifeboat () {
text.text = "You hit the button and you can see the lifeboat fall out the side of the boat you feel reallt happy and you jump into the boat and paddle away" +
"
" +
“Press R to restart the game you won :D”;
if (Input.GetKeyDown (KeyCode.R)) {myState = States.boat;}
}