Пример #1
0
    void checkTextForKeyWords(string text)
    {
        setGameState(GAME_STATE.SPEAKING);
        Debug.Log(text + " " + myCar.getSolutionKeywords()[0] + " " + myCar.getSolutionKeywords()[2]);

        int failureKeywordsFound = 0;

        foreach (string s in CarProblems.AllKeywords())
        {
            if (text.ToLower().Contains(s.ToLower()))
            {
                failureKeywordsFound++;
            }
        }

        int successKeyWordsFound = 0;

        foreach (string s in myCar.getSolutionKeywords())
        {
            if (text.ToLower().Contains(s.ToLower()))
            {
                successKeyWordsFound++;
                failureKeywordsFound--;
            }
        }

        bool isWarningLight = myCar.currentProblemType == ProblemTypes.WarningLight;

        if (failureKeywordsFound >= 2)
        {
            Debug.Log("incorrect");
            incorrectCommandGiven();
        }
        else if (successKeyWordsFound >= 2)
        {
            Debug.Log("correct");
            myCar.solveCurrentProblem();
        }

        else if (text.ToLower().Contains("brake shift") || text.ToLower().Contains("break shift"))
        {
            myCar.reportState(ReportTypes.brakeShift);
        }
        else if (text.ToLower().Contains("carburetor valve"))
        {
            myCar.reportState(ReportTypes.valve);
        }
        else if (text.ToLower().Contains("transmission"))
        {
            myCar.reportState(ReportTypes.transmission);
        }

        else if (isWarningLight && (text.ToLower().Contains("describe") || text.ToLower().Contains("look") || text.ToLower().Contains("looks") || text.ToLower().Contains("which")))
        {
            myCar.reportState(ReportTypes.warningFrame);
        }
        else if (isWarningLight && (text.ToLower().Contains("points")))
        {
            myCar.reportState(ReportTypes.pointsInStar);
        }
        else if (text.ToLower().Contains("number") || text.ToLower().Contains("center") || text.ToLower().Contains("middle"))
        {
            if (isWarningLight)
            {
                myCar.reportState(ReportTypes.numberInCenter);
            }
            else
            {
                myCar.DidntUnderstand();
            }
        }

        else if (text.ToLower().Contains("repeat") || text.ToLower().Contains("again") || text.ToLower().Contains("problem"))
        {
            myCar.playAudioDescriptionOfProblem();
        }
        else
        {
            // incorrect solution?
            myCar.DidntUnderstand();
        }
    }