When I run the game I don’t get any errors, but something is definitely wrong. Whenever I hit spacebar to go to the next method (livingroom), it immediately takes me right back to the method called story.
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class TextController : MonoBehaviour {
public Text text;
private enum House {story, livingroom, basement, upstairs, kitchen, bedroom_1, bedroom_2, attic, window, roof, hallway, bathroom};
private House myHouse;
// Use this for initialization
void Start ()
{
myHouse = House.story;
}
// Update is called once per frame
void Update (){
print (myHouse);
if (myHouse == House.story)
{
house_story();
}
else if (myHouse == House.livingroom)
{
house_livingroom();
}
}
void house_story(){
text.text = "You were kidnapped and taken to a place you have never seen before. The kidnappers tied you " +
"to a chair in the middle of the living room of what seems to be an abandoned house in the woods. " +
"Luckily, one kidnapper is guarding the front door, while the other left the house for the moment giving " +
"you enough time to untie yourself free and quickly look for a way out. \n\n" +
"Press Space to untie yourself and try to escape.";
if (Input.GetKeyDown(KeyCode.Space))
{
house_livingroom();
}
}
void house_livingroom(){
text.text = "Great! Now that you are untied, make your way through the house and try to escape \n\n" +
"Press 1 = Basement, 2 = Kitchen, 3 = Upstairs, 4 = Bedroom One";
if (Input.GetKeyDown(KeyCode.Keypad1)){
house_basement();
}
}
void house_basement(){
text.text = "A dark and creepy place with no signs of exit besides the way you came in. I think it would be best to " +
"turn back and try another way \n\n" +
"Press Space to return.";
if (Input.GetKeyDown(KeyCode.Space)){
house_livingroom();
}
}
}
