Exemple #1
0
    private void handlePaintContext()
    {
        //color tractor...
        string obj;
        string colorName;
        Color  color;
        bool   successful = true;

        if (!grammarData.TryGetValue("object", out obj))
        {
            successful = false;
        }
        if (!grammarData.TryGetValue("color", out colorName))
        {
            successful = false;
        }

        if (successful)
        {
            successful = cds.getColorFromString(colorName, out color);
            if (successful)
            {
                switch (obj)
                {
                case "tractor":
                    tractor.ChangeBodyColor(color);
                    break;

                case "tires":
                    tractor.ChangeTireColor(color);
                    break;
                }
                HoloVoice.StartSpeaking("OK");
            }
            else
            {
                Debug.LogError("grammarData doesn't contain valid color");
            }
        }
        else
        {
            Debug.LogError("grammarData doesn't contain valid paint context");
        }
    }
    public void HandleModificationRequest(List <string> words)
    {
        Debug.Log("Handling modification request", this);

        bool  tireFlag  = false;
        bool  colorFlag = false;
        Color newColor  = new Color();

        foreach (string word in words)
        {
            if (!tireFlag && word.StartsWith("TIRE"))
            {
                tireFlag = true;
                //words.Remove(word);
            }
            else if (!colorFlag && colorDicatationService.getColorFromString(word, out newColor))
            {
                colorFlag = true;
                //words.Remove(word);
            }
        }

        if (colorFlag)
        {
            if (tireFlag)
            {
                tractorBehavior.ChangeTireColor(newColor);
            }
            else
            {
                tractorBehavior.ChangeBodyColor(newColor);
            }
        }
        else
        {
            Apologize();
        }
    }