コード例 #1
0
    // Use this for initialization
    private void Start()
    {
        AssetManager.Instance.Bridge = new AssetManagerBridge();

        var streamingAssetsPath = Application.streamingAssetsPath;

#if UNITY_EDITOR || UNITY_STANDALONE
        streamingAssetsPath = "file://" + streamingAssetsPath;
#endif
        if (string.IsNullOrEmpty(IATScenario))
        {
            Debug.LogError("Please specify an IAT scenario file!");
            return;
        }

        iat = IntegratedAuthoringToolAsset.LoadFromFile(IATScenario);
        var characterSources = iat.GetAllCharacterSources().ToList();

        //AGENT 1
        agent1RPC = RolePlayCharacterAsset.LoadFromFile(characterSources[1].Source);
        agent1RPC.LoadAssociatedAssets();
        iat.BindToRegistry(agent1RPC.DynamicPropertiesRegistry);

        //AGENT 2
        agent2RPC = RolePlayCharacterAsset.LoadFromFile(characterSources[2].Source);
        agent2RPC.LoadAssociatedAssets();
        iat.BindToRegistry(agent2RPC.DynamicPropertiesRegistry);

        //PLAYER
        playerRPC = RolePlayCharacterAsset.LoadFromFile(characterSources[0].Source);
        playerRPC.LoadAssociatedAssets();
        iat.BindToRegistry(playerRPC.DynamicPropertiesRegistry);

        playerDialogues = DeterminePlayerDialogues();
        UpdatePlayerDialogOptions(true);

        AgentUtterance.text = String.Empty;

        StartCoroutine(UpdateEmotionalState(1f));
        StartCoroutine(DetermineAgentDialogue(0.2f));

        NextPageButton.onClick.RemoveAllListeners();
        NextPageButton.onClick.AddListener(() => OnNextPage());

        PreviousPageButton.onClick.RemoveAllListeners();
        PreviousPageButton.onClick.AddListener(() => OnPreviousPage());

        RestartButton.onClick.RemoveAllListeners();
        RestartButton.onClick.AddListener(() => RestartScene());
    }
コード例 #2
0
ファイル: IATTests.cs プロジェクト: pcannon67/FAtiMA-Toolkit
        private static RolePlayCharacterAsset BuildRPCAsset()
        {
            var kb = new KB((Name)"Matt");


            var rpc = new RolePlayCharacterAsset
            {
                BodyName      = "Male",
                VoiceName     = "Male",
                CharacterName = (Name)"Matt",
                m_kb          = kb,
            };

            rpc.LoadAssociatedAssets(new GAIPS.Rage.AssetStorage());
            return(rpc);
        }
コード例 #3
0
    public void NextLevel()
    {
        CurrentLevel++;

        _feedbackScores.Clear();
        GetFeedbackEvent?.Invoke(_feedbackScores, FeedbackLevel);
        if (_scenarios.Any(data => data.LevelId.Equals(CurrentLevel)))
        {
            CurrentScenario = _scenarios.First(data => data.LevelId.Equals(CurrentLevel));
        }
        else
        {
            var validPaths = _allScenarioPaths.Where(p => p.Contains('#')).ToArray();
            var prefixes = validPaths.Select(p => p.Substring(0, p.IndexOf('-', p.IndexOf('-') + 1) + 1)).ToList();
            var character = new List <string> {
                "Positive", "Neutral", "Negative"
            }.OrderBy(dto => random.Next()).First();

            var prefix = _isDemo
                                ? _demoScenarioPrefix + _demoUtterance
                                : prefixes.OrderBy(dto => random.Next()).First();

            // MaxPoints currently hardcoded to 8 for random scenarios.
            // TODO Review validity/balance of MaxPoints = 8
            CurrentScenario = new ScenarioData(CurrentLevel, _allScenarioPaths.Where(x => x.Contains(prefix)).ToArray(), character, 8, prefix);
        }
        if (CurrentScenario != null)
        {
            var index = random.Next(CurrentScenario.ScenarioPaths.Length);
            Debug.Log(CurrentScenario.ScenarioPaths[index]);
            string error;

            ScenarioCode = _isDemo
                                ? _demoUtterance.Split('#')[0]
                                : CurrentScenario.ScenarioPaths[index].Replace(CurrentScenario.Prefix, string.Empty).Split('#')[0];

            _integratedAuthoringTool = IntegratedAuthoringToolAsset.LoadFromFile(Path.Combine("Scenarios", CurrentScenario.ScenarioPaths[index]), out error);
            if (!string.IsNullOrEmpty(error))
            {
                Debug.LogError(error);
            }
            CurrentCharacter = RolePlayCharacterAsset.LoadFromFile(_integratedAuthoringTool.GetAllCharacterSources().First(c => c.Source.Contains(CurrentScenario.Character)).Source);
            CurrentCharacter.LoadAssociatedAssets();
            _integratedAuthoringTool.BindToRegistry(CurrentCharacter.DynamicPropertiesRegistry);
            CurrentCharacter.BodyName = random.NextDouble() >= 0.5 ? "Male" : "Female";
        }
    }
コード例 #4
0
    public void NextQuestionnaire()
    {
        // Pilot logic to set level id to match CurrentLevel divided by 5, as questionnaires occur every 5 levels. Needs changing if occurance rate of questionnaires change
        CurrentScenario = new ScenarioData(CurrentLevel / 5, _allScenarioPaths.Where(x => x.Contains("Questions")).ToArray(), "Neutral", 0, "Questionnaire");
        string error;

        // Pilot logic to set different questionnaire depending on how many levels have been played. Needs changing if expected appearence of questionnaire changes
        ScenarioCode             = (CurrentLevel < LevelMax && LevelMax > 0 ? 1 : 2).ToString();
        _integratedAuthoringTool = IntegratedAuthoringToolAsset.LoadFromFile(Path.Combine("Scenarios", _allScenarioPaths.First(x => x.Contains("Questions" + ScenarioCode))), out error);
        if (!string.IsNullOrEmpty(error))
        {
            Debug.LogError(error);
        }
        CurrentCharacter = RolePlayCharacterAsset.LoadFromFile(_integratedAuthoringTool.GetAllCharacterSources().First(c => c.Source.Contains("Neutral")).Source);
        CurrentCharacter.LoadAssociatedAssets();
        _integratedAuthoringTool.BindToRegistry(CurrentCharacter.DynamicPropertiesRegistry);
    }
コード例 #5
0
        private void loadScenario(string agentType)
        {
            System.IO.Directory.CreateDirectory(LOGS_PATH);

            var characterSources = _iat.GetAllCharacterSources().ToList();

            foreach (var source in characterSources)
            {
                RolePlayCharacterAsset character = RolePlayCharacterAsset.LoadFromFile(source.Source);
                character.LoadAssociatedAssets();
                if (character.BodyName.ToString() == agentType)
                {
                    _iat.BindToRegistry(character.DynamicPropertiesRegistry);
                    _rpc = character;
                    break;
                }
            }
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: samuelfm/FAtiMA-DST
        static void Main(string[] args)
        {
            AssetManager.Instance.Bridge = new BasicIOBridge();

            Console.Write("Loading Character from file... ");
            Walter = RolePlayCharacterAsset.LoadFromFile("./walter.rpc");
            Walter.LoadAssociatedAssets();
            Console.WriteLine("Complete!");

            WebServer ws = new WebServer(SendResponse, "http://localhost:8080/");

            ws.Run();
            Console.WriteLine("Press a key to quit.");
            Console.ReadKey();
            ws.Stop();

            Walter.SaveToFile("./walter-final.rpc");
        }
コード例 #7
0
    void Start()
    {
        isStopped = false;

        string rpcPath = GameGlobals.FAtiMAIat.GetAllCharacterSources().FirstOrDefault().Source;

        //Application.ExternalEval("console.log(\"rpcPath: " + rpcPath + "\")");
        rpc = RolePlayCharacterAsset.LoadFromFile(rpcPath);


        rpc.LoadAssociatedAssets();
        GameGlobals.FAtiMAIat.BindToRegistry(rpc.DynamicPropertiesRegistry);

        //start update thread
        StartCoroutine(UpdateCoroutine());

        speechBalloonDelayPerWordInSeconds = 0.5f;
        currSpeeches = new List <string>();


        float speechCheckDelayInSeconds = 0.1f;

        StartCoroutine(ConsumeSpeeches(speechCheckDelayInSeconds));
    }
コード例 #8
0
ファイル: Program.cs プロジェクト: pcannon67/FAtiMA-Toolkit
        static void Main(string[] args)
        {
            //AssetStorage
            var storage = AssetStorage.FromJson(File.ReadAllText("../../../../Examples/AssetStorage.json"));
            //Loading the asset
            var rpc = new RolePlayCharacterAsset();

            rpc.LoadAssociatedAssets(storage);
            rpc.ActivateIdentity(new Identity((Name)"Portuguese", (Name)"Culture", 1));
            Console.WriteLine("Starting Mood: " + rpc.Mood);
            var actions = rpc.Decide();
            var action  = actions.FirstOrDefault();

            rpc.Update();

            Console.WriteLine("The name of the character loaded is: " + rpc.CharacterName);
            // Console.WriteLine("The following event was perceived: " + event1);
            Console.WriteLine("Mood after event: " + rpc.Mood);
            Console.WriteLine("Strongest emotion: " + rpc.GetStrongestActiveEmotion()?.EmotionType + "-" + rpc.GetStrongestActiveEmotion()?.Intensity);
            Console.WriteLine("First Response: " + action?.Name + ", Target:" + action?.Target.ToString());

            var busyAction = rpc.Decide().FirstOrDefault();

            Console.WriteLine("Second Response: " + busyAction?.Name + ", Target:" + action?.Target.ToString());

            var event3 = EventHelper.ActionEnd(rpc.CharacterName.ToString(), action?.Name.ToString(), "Player");

            rpc.Perceive(new[] { event3 });
            action = rpc.Decide().FirstOrDefault();

            Console.WriteLine("Third Response: " + action?.Name + ", Target:" + action?.Target.ToString());


            int x = 0;

            while (true)
            {
                Console.WriteLine("Mood after tick: " + rpc.Mood + " x: " + x + " tick: " + rpc.Tick);
                Console.WriteLine("Strongest emotion: " + rpc.GetStrongestActiveEmotion()?.EmotionType + "-" + rpc.GetStrongestActiveEmotion()?.Intensity);
                rpc.Update();
                Console.ReadLine();

                if (x == 10)
                {
                    var event1 = EventHelper.ActionEnd("Player", "Kick", rpc.CharacterName.ToString());

                    rpc.Perceive(new[] { event1 });
                    action = rpc.Decide().FirstOrDefault();
                    rpc.Update();
                }


                if (x == 11)
                {
                    rpc.ResetEmotionalState();
                }
                if (x == 25)
                {
                    var event1 = EventHelper.ActionEnd("Player", "Kick", rpc.CharacterName.ToString());

                    rpc.Perceive(new[] { event1 });
                    action = rpc.Decide().FirstOrDefault();
                    rpc.Update();
                }


                else if (x == 30)
                {
                    Console.WriteLine("Reloading " + rpc.GetStrongestActiveEmotion().Intensity + " " + rpc.GetStrongestActiveEmotion().EmotionType + " mood: " + rpc.Mood);

                    Console.WriteLine("Reloading result: " + rpc.GetStrongestActiveEmotion().Intensity + " " + rpc.GetStrongestActiveEmotion().EmotionType + " mood: " + rpc.Mood);
                }

                x++;
            }
        }