public static GenericTextInterchange ParseGenericTextInterchangeFromText(string text) {
        string[] interchangePieces = text.Split(new string[] { "%%" + Environment.NewLine }, StringSplitOptions.None);

        if (interchangePieces.Length != 4) {
            Debug.LogError("The generic text interchange was not parsed correctly from the text: " + text);
            return null;
        }

        string question = interchangePieces[0];
        string expectedResponse = interchangePieces[1];

        Func<bool, string> getAiResponse;
        
        if (interchangePieces[2].Trim() == "RANDOM") {
            interchangePieces[2] = RandomResponse(true);
        }
        if (interchangePieces[3] == "RANDOM") {
            interchangePieces[3] = RandomResponse(false);
        }


        getAiResponse = (b) => (b ? interchangePieces[2] : interchangePieces[3]);

        GenericTextInterchange interchange = new GenericTextInterchange(AIAlignmentState.Neutral);

        interchange.SetExpectedResponse(expectedResponse);
        interchange.SetQuestionAndResponse(question, getAiResponse);

        return interchange;                    
    }
Esempio n. 2
0
    public static GenericTextInterchange ParseGenericTextInterchangeFromText(string text)
    {
        string[] interchangePieces = text.Split(new string[] { "%%" + Environment.NewLine }, StringSplitOptions.None);

        if (interchangePieces.Length != 4)
        {
            Debug.LogError("The generic text interchange was not parsed correctly from the text: " + text);
            return(null);
        }

        string question         = interchangePieces[0];
        string expectedResponse = interchangePieces[1];

        Func <bool, string> getAiResponse;

        if (interchangePieces[2].Trim() == "RANDOM")
        {
            interchangePieces[2] = RandomResponse(true);
        }
        if (interchangePieces[3] == "RANDOM")
        {
            interchangePieces[3] = RandomResponse(false);
        }


        getAiResponse = (b) => (b ? interchangePieces[2] : interchangePieces[3]);

        GenericTextInterchange interchange = new GenericTextInterchange(AIAlignmentState.Neutral);

        interchange.SetExpectedResponse(expectedResponse);
        interchange.SetQuestionAndResponse(question, getAiResponse);

        return(interchange);
    }
Esempio n. 3
0
    /// <summary>
    /// Given a generic text interchange object, executes the interchange on the 2 way commchannel
    /// and closes doors on the player
    /// </summary>
    /// <param name="interchange"></param>
    private void ExecTextInterchange(GenericTextInterchange interchange)
    {
        if (interchange == null)
        {
            Debug.LogError("interchange was null in ExecTextInterchange");
            return;
        }

        Debug.LogError("about to close doors in cell exectextinterchange");
        maze.CloseDoorsInCell(playerCurrentCoords);

        currentInterchange = interchange;

        SendMessageToPlayer(currentInterchange.GetQuestionText(), textCommChannel);
    }
Esempio n. 4
0
    /// <summary>
    /// Given a generic text interchange object, executes the interchange on the 2 way commchannel
    /// and closes doors on the player
    /// </summary>
    /// <param name="interchange"></param>
    private void ExecTextInterchange(GenericTextInterchange interchange) {
        if (interchange == null) {
            Debug.LogError("interchange was null in ExecTextInterchange");
            return;
        }

        Debug.LogError("about to close doors in cell exectextinterchange");
        maze.CloseDoorsInCell(playerCurrentCoords);

        currentInterchange = interchange;

        SendMessageToPlayer(currentInterchange.GetQuestionText(), textCommChannel);
    }