Question by
KristianGrytdal · Aug 08, 2016 at 01:20 PM ·
c#script.inputfield
Making several right answers
This is a part of my script, it takes a guess that a person makes and compares it to the "movieName". But is it possible to make it so it doesn't just take one answer? so it could be several right answers?? Thanks in advance :)
void Awake(){
movieName = "spawn";
text.text = "Guess The Name Of The Movie";
}
public void GetInput(string guess){
CompareGuesses(guess);
input.text = "";
}
public void CompareGuesses (string guess){
if (guess.ToLower() == movieName.ToLower()) {
SceneManager.LoadScene("Level 1");
GameObject go = GameObject.Find ("GameStatus");
GameStatus gs = go.GetComponent<GameStatus> ();
gs.score += 1;
GameObject og = GameObject.Find ("PointStatus");
PointStatus sg = og.GetComponent<PointStatus> ();
sg.point += 1;
} else if (guess != movieName) {
text.text = "Wrong!";
} else if (guess != movieName) {
text.text = "Wrong!";
}
}
Comment
Answer by Kazuva · Aug 08, 2016 at 01:37 PM
Yes you can use || operator ex
if ( guess == rightAnswer1 || guess == rightAnswer2 || guess == rightAnswer3){
//do the things
}
It does the things if one of the statements is true , more info about the || operator