void State_OutsideCell1 () {
if (hasKey1 == false)
text.text = "You are in front of a door and there is a key to your left.
Press o to open the door
Press T to take the key.";
{
if (hasKey1 == true)
text.text = “You have a key in hand. press o to open the door”;
else if (hasKey1 == true & Input.GetKeyDown (KeyCode.O))
myStates = States.door1;
else if(hasKey1 == false & Input.GetKeyDown(KeyCode.T))
text.text = "You don't have a key! Press T to take the key.";
hasKey1 = true;
}
}
I’m trying something like that. It just wont work. when I enter this ‘‘Room’’, it makes haskey1 true and the text is ''You are in front of a door and there is a key to your left (…) ‘’.
I’m pretty sure it has everything to do with the way I typed my if statements and the curly bracers.
Note: I made a way over complicated system to make this work but I don’t want to use that. See for yourself.
/* void State_OutsideCell1 () {
text.text = "As you get closer to the door, it gets bigger. You think it is a bit intimidating. Your head starts to hurt like crazy. " +
"What is behind that door? To your left, there is a key on the wall.
press T to take the key.
press D to open the door. ";
if (hasKey1 == true && Input.GetKeyDown (KeyCode.D)) //
myStates = States.door1;
else if (Input.GetKeyDown (KeyCode.D) && hasKey1 == false) //
myStates = States.HasNoKey1;
else if (Input.GetKeyDown (KeyCode.T) && hasKey1 == false) //
myStates = States.Key1;
else if (Input.GetKeyDown (KeyCode.T) && hasKey1 == true) //
myStates = States.HasKey1;
}
void State_HasKey1 () {
text.text = “you already took the key and There is nothing left on the wall. Press B to go back”;
if (Input.GetKeyDown (KeyCode.B))
myStates = States.OutsideCell1;
}
void State_HasNoKey1 () {
text.text = "You feel nauseous as you reach for the door knob. Why is that? The door is locked and you can't open it without a key." +
"Press B to go back";
if(Input.GetKeyDown(KeyCode.B))
myStates = States.OutsideCell1;
}
void State_Key1 () {
text.text = "Has you reach for the key, your head suddenly feels like it is going to explode. You take a deep breath and clear your mind." +
"
press t to take the key";
hasKey1 = true;
if (Input.GetKeyDown (KeyCode.T))
myStates = States.OutsideCell1;
}
void State_Door1 () {
text.text = "You use the key on the lock and open the door. you shit on your chest. press anykey to masturbate.";
} */
it’s just too long and stupid… But it works… ^,^