Beispiel #1
0
    public void SubmitAnswer(string input)
    {
        if (usedPuzzles.Count == 0)
        {
            mainManager.showBanner();
        }
        // Checks if the submitted answer is correct
        if (currentPuzzle.puzzleSegments[currentQuestionIndex].CheckAnswer(input))
        {
            mainManager.AddTime();
            // Increments question or gets new puzzle if correct.
            textAnimator.AddAnimations(new TextAnimation(currentPuzzle.puzzleSegments[currentQuestionIndex].successMessage, 0.5f));
            if (currentPuzzle.puzzleSegments.Length != 1 && currentQuestionIndex < currentPuzzle.puzzleSegments.Length - 1)
            {
                currentQuestionIndex++;
            }
            else
            {
                StartPuzzle();
            }
        }
        else
        {
            //Displays failure message, and starts a new puzzle.
            textAnimator.AddAnimations(new TextAnimation(currentPuzzle.puzzleSegments[currentQuestionIndex].failureMessage, 0.5f));
            if (usedPuzzles.Count > 0)
            {
                usedPuzzles.RemoveAt(usedPuzzles.Count - 1);
            }
            cameraShake.ShakeCam(1f, 0.05f);
            musicManager.PlayExplosion();
            StartPuzzle();
        }

        // Plays new question.
        PlayQuestion();
    }