Beispiel #1
0
    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);
    }
Beispiel #2
0
 public override string ToString()
 {
     return(SentencePart.Aggregate(
                new StringBuilder(),
                (str, next) => str.Append(next.GetString()),
                str => str.ToString()
                ) + EndPunctuation.GetString());
 }
Beispiel #3
0
    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);
    }