The Error happendes when the “Day2” method is activated
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class TextController : MonoBehaviour {
public Text text;
public Image imageGO;
float timeLeft = 3.5f;
private enum States {backstory, cell_1, scout_1, scout_2, talk_1, sleep_1, lock_1, blood_1};
private States myState;
void Start () {
myState = States.backstory;
}
void Update () {
if (myState == States.backstory) {
state_backstory();
}else if (myState == States.cell_1) {
state_cell_1();
}else if (myState == States.sleep_1) {
state_sleep_1();
}else if (myState == States.talk_1) {
state_talk_1();
}else if (myState == States.scout_1) {
timeLeft -= Time.deltaTime;
if(timeLeft < 0) {
myState = States.scout_2;
}
state_scout_1();
}else if (myState == States.scout_2) {
state_scout_2();
}else if (myState == States.lock_1) {
state_lock_1();
}else if (myState == States.blood_1) {
state_blood_1();
}
}
void state_backstory () {
text.text="You wake up in an odd bed, you quickly realize that you are in a prison cell." +
"You try to remember what you did that caused your arrest. But you could not recall a thing." +
"You try to remember who you even are, but you couldn’t, no matter how hard you tried.
" +
“Press Enter to continue”;
if (Input.GetKeyDown(KeyCode.Return)){
myState = States.cell_1;
}
}
void state_cell_1 () {
text.text="You hear people whom you assume are guards outside the room. what will you do?
" +
"S.go to sleep, maybe you just need a rest and you’ll remember?
" +
"T.Ask the guards why you’re there
" +
“V.Scout the room maybe you could find some clues?”;
if (Input.GetKeyDown(KeyCode.S)){
myState = States.sleep_1;
}else if (Input.GetKeyDown(KeyCode.T)){
myState = States.talk_1;
}else if (Input.GetKeyDown(KeyCode.V)){
myState = States.scout_1;
}
}
void state_sleep_1 () {
text.text="a day passes...";
Day_2();
}
void state_talk_1 () {
text.text="You ask the guards why you’re there.
" +
"They laugh at you… it seems this isn’t going anywhere.
" +
“The guards leave, now that you’re on your own, What should you do?”;
if (Input.GetKeyDown(KeyCode.V)) {
myState = States.scout_1;
}else if (Input.GetKeyDown(KeyCode.L)) {
myState = States.lock_1;
}
}
void state_scout_1 () {
text.text="You look around the room…
";
}
void state_scout_2 () {
text.text="you see some writing on the wall:”It never ends” and some scratches counting up to 20";
if (Input.GetKeyDown(KeyCode.V)) {
myState = States.blood_1;
}else if (Input.GetKeyDown(KeyCode.S)) {
myState = States.scout_1;
}
}
void state_lock_1 () {
}
void state_blood_1 () {
text.text="111";
}
void Day_2() {
imageGO.sprite = Resources.Load<Sprite> ("DayCounter13");
}
}