public bool SubmitAnswer(string text) { if (win) { return(false); } GameSentence sent = config.sentences[sentIndex]; SentencePart part = sent.parts[partIndex]; Debug.Log("Submitted: " + text); if (text == part.answer) { ChangeScore(10); if (!next()) { question.text = "Final Score: " + score; win = true; return(true); } question.text = config.sentences[sentIndex].getQuestion(partIndex); return(true); } ChangeScore(-3); return(false); }
public override string ToString() { return(SentencePart.Aggregate( new StringBuilder(), (str, next) => str.Append(next.GetString()), str => str.ToString() ) + EndPunctuation.GetString()); }
public string getQuestion(int partIndex) { string output = ""; for (int i = 0; i < parts.Length; i++) { SentencePart part = parts[i]; if (i == partIndex) { // highlight the current question output += "(" + part.content + ")"; } else if (i < partIndex && part.isQuestion) { output += part.answer; } else { output += part.content; } } return(output); }