using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TextCommancd : 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.Lock_0) { state_Lock_0(); }
else if (mystate == States.cell_mirror) { state_cell_mirror(); }
else if (mystate == States.mirror) { state_mirror(); }
else if (mystate == States.Lock_1) { state_Lock_1(); }
else if (mystate == States.freedom) { state_freedom(); }
void state_cell() {
text.text = "There was once a guy who went to prison and he was really really " +
"sad. The only thing he could see in his cell was a sheet, a mirror, " +
"and a door that is locked from the outside. \n " +
"press S for Sheets, M for Mirror, and L for Lock";
if (Input.GetKeyDown(KeyCode.S)) { mystate = States.Sheets_0; }
}
void state_Sheets_0() {
text.text = "I cant believe I have to sleep in these things, that is the life " +
"of a prisoner I guess, the least they could do is give me a bible to worship " +
"my lord and savior Jesus Christ. \n " +
"press R to return roaming your cell";
if (Input.GetKeyDown(KeyCode.R)) { mystate = States.cell; }
}
void state_Lock_0() {
text.text = "This is one of those button locks, how will I ever find out the code? " +
"You have no idea what the combanation is. You wish you could somehow " +
"You wish you could see where the dirty fingerprints were. \n " +
"press R to return roaming your cell";
if (Input.GetKeyDown(KeyCode.R)) { mystate = States.cell; }
}
void state_mirror() {
text.text = "This mirror looks loose and could be used to see what the pad " +
"Code is! \n " +
"press R to return roaming your cell or press T to take the mirror!";
if (Input.GetKeyDown(KeyCode.R)) { mystate = States.cell; }
else if (Input.GetKeyDown(KeyCode.T)) { mystate = States.cell_mirror; }
}
void state_cell_mirror() {
text.text = "You are in your cell holding a mirror and the notice that it is " +
"rather dirty! You still want to escape to help your church! \n" +
"press S to view Sheets or L to view Lock";
if (Input.GetKeyDown(KeyCode.S)) { mystate = States.Sheets_0; }
else if (Input.GetKeyDown(KeyCode.L)) { mystate = States.Lock_1; }
}
void state_Lock_1() {
text.text = "You carfully slide the mirror through the bars and try to get a " +
"look at the locks keypad \n" +
"Press O to Open lock or press R to return to Cell";
if (Input.GetKeyDown(KeyCode.R)) { mystate = States.cell_mirror; }
}
void state_freedom() {
text.text = "You look at the keypad and notice some figermarks and you pray " +
"for the right combination and make an attempt. God has answered your " +
"prayers and has helped you escape to go and spread the news of the gospel. \n" +
"press P to play again";
if (Input.GetKeyDown(KeyCode.P)) { mystate = States.cell; }
}
}
}
void state_cell_mirror() for example is a new method but your code has it inside the Update method so the compiler doesn’t see it as a method just another instruction for Update which means it’s questioning why you’re declaring something void.
You need to end your Update method after the if/else block you’ve got.
2 Likes
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.