Esempio n. 1
0
    public void GetCharacterResponse()
    {
        CurrentCharacter.Perceive(_events);
        var possibleActions = CurrentCharacter.Decide();
        var action          = RolePlayCharacterAsset.TakeBestActions(possibleActions).FirstOrDefault();

        _events.Clear();
        CurrentCharacter.Update();

        if (action != null)
        {
            var actionKey = action.Key.ToString();
            if (actionKey == "Speak")
            {
                var nextState         = action.Parameters[1];
                var dialogues         = _integratedAuthoringTool.GetDialogueActionsByState(action.Parameters[0].ToString());
                var characterDialogue = dialogues.FirstOrDefault(dto => string.Equals(dto.Meaning.ToString(), action.Parameters[2].ToString(), StringComparison.CurrentCultureIgnoreCase) && string.Equals(dto.Style.ToString(), action.Parameters[3].ToString(), StringComparison.CurrentCultureIgnoreCase));
                if (characterDialogue != null)
                {
                    UpdateFeedbackScores(characterDialogue, "Client");
                    _events.Add((Name)string.Format("Event(Property-Change,{0},DialogueState(Player),{1})", CurrentCharacter.CharacterName, nextState));
                    UpdateCurrentState();
                    PlayDialogueAudio(characterDialogue.FileName);
                    GetCharacterDialogueSuccessEvent?.Invoke(Localization.GetAndFormat(characterDialogue.FileName, false, ScenarioCode));
                }
            }
        }

        GetCharacterStrongestEmotion();
    }