protected override void OnAssetDataLoaded(IntegratedAuthoringToolAsset asset) { textBoxScenarioName.Text = asset.ScenarioName; textBoxScenarioDescription.Text = asset.ScenarioDescription; _characterSources = new BindingListView <CharacterSourceDTO>(asset.GetAllCharacterSources().ToList()); _wmSource = asset.GetWorldModelSource(); dataGridViewCharacters.DataSource = _characterSources; _dialogs = new BindingListView <DialogueStateActionDTO>(new List <DialogueStateActionDTO>()); dataGridViewDialogueActions.DataSource = _dialogs; if (_wmSource != null) { if (_wmSource.Source != "") { pathTextBoxWorldModel.Text = _wmSource.Source; LoadWorldModelForm(); } } //ResetSimulator richTextBoxChat.Clear(); buttonContinue.Enabled = false; textBoxTick.Text = ""; RefreshDialogs(); }
/// <summary> /// Update the set of recruits /// </summary> internal void CreateRecruits() { var recuritsToRemove = new List <string>(); //remove recruits from iat and randomly select to remove them from pool of available recruits foreach (var member in Recruits) { var path = Path.Combine(storageLocation, member.Value.RolePlayCharacter.VoiceName + ".rpc").Replace("\\", "/"); iat.RemoveCharacters(new List <int> { iat.GetAllCharacterSources().First(c => c.Source.Replace("\\", "/") == path).Id }); if (StaticRandom.Int(0, 100) % ConfigKey.RecruitChangeChance.GetIntValue() != 0) { recuritsToRemove.Add(member.Key); } } foreach (var member in recuritsToRemove) { Recruits.Remove(member); } //for the amount of empty recruit spaces, create a new recruit var amount = ConfigKey.RecruitCount.GetIntValue() - Recruits.Count; for (var i = 0; i < amount; i++) { var position = Boat.GetWeakestPosition(CrewMembers.Values.Concat(Recruits.Values).ToList()); var newMember = new CrewMember(position, Nationality); UniqueNameCheck(newMember); Recruits.Add(newMember.Name, newMember); } var storeNum = 0; //set up the files for each recruit and their avatar foreach (var recruit in Recruits) { recruit.Value.CreateRecruitFile(iat, storageLocation, storeNum); storeNum++; } iat.Save(); }
private void buttonAddCharacter_Click(object sender, EventArgs e) { var ofd = new OpenFileDialog(); if (ofd.ShowDialog() == DialogResult.OK) { try { var character = _iatAsset.AddCharacter(ofd.FileName); if (character.ErrorOnLoad != null) { MessageBox.Show("Error when loading character '" + character.CharacterName + "': " + character.ErrorOnLoad, Resources.ErrorDialogTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } _characterSources.DataSource = _iatAsset.GetAllCharacterSources().ToList(); _characterSources.Refresh(); } catch (Exception ex) { MessageBox.Show(ex.Message + "-" + ex.StackTrace, Resources.ErrorDialogTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
// 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()); }
private void LoadScenario(SingleCharacterDemo.ScenarioData data) { ClearButtons(); _iat = data.IAT; _introPanel.SetActive(true); _introText.text = string.Format("<b>{0}</b>\n\n\n{1}", _iat.ScenarioName, _iat.ScenarioDescription); var characterSources = _iat.GetAllCharacterSources().ToList(); int CharacterCount = 0; foreach (var source in characterSources) { var rpc = RolePlayCharacterAsset.LoadFromFile(source.Source); rpc.LoadAssociatedAssets(); _iat.BindToRegistry(rpc.DynamicPropertiesRegistry); rpcList.Add(rpc); var body = m_bodies.FirstOrDefault(b => b.BodyName == rpc.BodyName); _agentController = new MultiCharacterAgentController(data, rpc, _iat, body.CharaterArchtype, m_characterAnchors[CharacterCount], m_dialogController); StopAllCoroutines(); _agentControllers.Add(_agentController); CharacterCount++; } AddButton("Back to Scenario Selection Menu", () => { _iat = null; LoadScenarioMenu(); }); foreach (var actor in rpcList) { foreach (var anotherActor in rpcList) { if (actor != anotherActor) { var changed = new[] { EventHelper.ActionEnd(anotherActor.CharacterName.ToString(), "Enters", "Room") }; actor.Perceive(changed); } } } RandomizeNext(); SetCamera(); }
private IEnumerator LoadScenario(ScenarioData data) { ClearButtons(); _iat = data.IAT; _introPanel.SetActive(true); _introText.text = string.Format("<b>{0}</b>\n\n\n{1}", _iat.ScenarioName, _iat.ScenarioDescription); previousState = ""; var characterSources = _iat.GetAllCharacterSources().ToList(); var addedDialogs = new List <string>(); _wm = WorldModelAsset.LoadFromFile(_iat.GetWorldModelSource().Source); foreach (var source in characterSources) { var rpc = RolePlayCharacterAsset.LoadFromFile(source.Source); rpc.LoadAssociatedAssets(); if (rpc.CharacterName.ToString() == "Player") { Player = rpc; _iat.BindToRegistry(Player.DynamicPropertiesRegistry); continue; } _iat.BindToRegistry(rpc.DynamicPropertiesRegistry); AddButton(characterSources.Count <= 2 ? "Start" : rpc.CharacterName.ToString(), () => { Debug.Log("Interacted with the start button"); var body = m_bodies.FirstOrDefault(b => b.BodyName == rpc.BodyName); _agentController = new AgentControler(data, rpc, _iat, body.CharaterArchtype, m_characterAnchor, m_dialogController); StopAllCoroutines(); _agentController.storeFinalScore(_finalScore); _agentController.Start(this, VersionMenu); _agentController.startingTime = this.startingTime; InstantiateScore(); }); } if (m_scenarios.Length > 1) { AddButton("Back to Scenario Selection Menu", () => { _iat = null; LoadScenarioMenu(); }); } yield return(nextframe); }
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"; } }
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); }
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; } } }
private void LoadScenario(SingleCharacterDemo.ScenarioData data) { ClearButtons(); _iat = data.IAT; if (skipDescription) { _introPanel.SetActive(true); _introText.text = string.Format("<b>{0}</b>\n\n\n{1}", _iat.ScenarioName, _iat.ScenarioDescription); } if (_iat.m_worldModelSource != null) { if (_iat.m_worldModelSource.Source != "" && _iat.m_worldModelSource.Source != null) { _wm = WorldModel.WorldModelAsset.LoadFromFile(_iat.GetWorldModelSource().Source); } } var characterSources = _iat.GetAllCharacterSources().ToList(); int CharacterCount = 0; foreach (var source in characterSources) { var rpc = RolePlayCharacterAsset.LoadFromFile(source.Source); rpc.LoadAssociatedAssets(); _iat.BindToRegistry(rpc.DynamicPropertiesRegistry); rpcList.Add(rpc); var body = m_bodies.FirstOrDefault(b => b.BodyName == rpc.BodyName); UnityEngine.Random.InitState((int)System.DateTime.Now.Ticks); var r = UnityEngine.Random.Range(0, 30); Debug.Log("Going to wait" + r); StartCoroutine(JustWait(UnityEngine.Random.Range(0, 3))); _agentController = new MultiCharacterAgentController(data, rpc, _iat, body.CharaterArchtype, m_characterAnchors[CharacterCount], m_dialogController); // StopAllCoroutines(); _agentControllers.Add(_agentController); if (rpc.CharacterName == _player.CharacterName) { _player = rpc; } CharacterCount++; } foreach (var agent in _agentControllers) { if (agent.RPC.CharacterName != _player.CharacterName) { agent.StartBehaviour(this, VersionMenu); } } foreach (var actor in rpcList) { foreach (var anotherActor in rpcList) { if (actor != anotherActor) { var changed = new[] { EventHelper.ActionEnd(anotherActor.CharacterName.ToString(), "Enters", "Room") }; actor.Perceive(changed); } } } SetCamera(); PlayerDecide(); }
private void LoadScenario(ScenarioData data) { ClearButtons(); _iat = data.IAT; _introPanel.SetActive(true); _introText.text = string.Format("<b>{0}</b>\n\n\n{1}", _iat.ScenarioName, _iat.ScenarioDescription); if (_iat.m_worldModelSource != null) { if (!string.IsNullOrEmpty(_iat.m_worldModelSource.Source)) { var wat = _iat.GetWorldModelSource(); string errorsOnLoad; // _wm = WorldModel.WorldModelAsset.LoadFromFile(_iat.GetWorldModelSource().RelativePath); _wm = WorldModel.WorldModelAsset.LoadFromFile(_iat.GetWorldModelSource().Source, out errorsOnLoad); if (errorsOnLoad != null) { throw new Exception(errorsOnLoad); } } } var characterSources = _iat.GetAllCharacterSources().ToList(); foreach (var source in characterSources) { var rpc = RolePlayCharacterAsset.LoadFromFile(source.Source); rpc.LoadAssociatedAssets(); _iat.BindToRegistry(rpc.DynamicPropertiesRegistry); if (rpc.CharacterName.ToString().Contains("Player")) { Player = rpc; continue; } AddButton(characterSources.Count <= 2 ? "Start" : rpc.CharacterName.ToString(), () => { var body = m_bodies.FirstOrDefault(b => b.BodyName == rpc.BodyName); _agentController = new AgentControler(data, rpc, _iat, body.CharaterArchtype, m_characterAnchor, m_dialogController); StopAllCoroutines(); _agentController.Start(this, VersionMenu); _background.SetActive(true); if (!backgrounds.IsEmpty()) { if (!backgrounds.ToList().FindAll(x => x.scenarioName == _iat.ScenarioName).IsEmpty()) { _background.GetComponent <Renderer>().material = backgrounds.ToList().Find(x => x.scenarioName == _iat.ScenarioName).mat; } else { _background.GetComponent <Renderer>().material = activeBackgroundMaterial; } } else { _background.GetComponent <Renderer>().material = activeBackgroundMaterial; } }); } AddButton("Back to Scenario Selection Menu", () => { _iat = null; LoadScenarioMenu(); }); }
protected override void OnAssetDataLoaded(IntegratedAuthoringToolAsset asset) { textBoxScenarioName.Text = asset.ScenarioName; _characterSources = new BindingListView<CharacterSourceDTO>(asset.GetAllCharacterSources().ToList()); dataGridViewCharacters.DataSource = _characterSources; }
private void CalculateEmotions(object sender, EventArgs e) { Dictionary <string, Dictionary <string, int> > emotionList = new Dictionary <string, Dictionary <string, int> >(); IntegratedAuthoringToolAsset loadedIAT = this.LoadedAsset; List <RolePlayCharacterAsset> rpcList = new List <RolePlayCharacterAsset>(); List <WellFormedNames.Name> _eventList = new List <WellFormedNames.Name>(); foreach (var rpc in loadedIAT.GetAllCharacterSources()) { var actor = RolePlayCharacterAsset.LoadFromFile(rpc.Source); ; actor.LoadAssociatedAssets(); loadedIAT.BindToRegistry(actor.DynamicPropertiesRegistry); rpcList.Add(actor); } foreach (var actor in rpcList) { foreach (var anotherActor in rpcList) { if (actor != anotherActor) { var changed = new[] { EventHelper.ActionEnd(anotherActor.CharacterName.ToString(), "Enters", "Room") }; actor.Perceive(changed); } } emotionList.Add(actor.CharacterName.ToString(), new Dictionary <string, int>()); // actor.SaveToFile("../../../Tests/" + actor.CharacterName + "-output1" + ".rpc"); } string validationMessage = ""; var rpcActions = new Dictionary <IAction, RolePlayCharacterAsset>(); var act = rpcList.FirstOrDefault().Decide(); if (act == null) { foreach (var r in rpcList) { act = r.Decide(); if (act != null) { rpcActions.Add(act.FirstOrDefault(), r); break; } } } int timestamp = 0; while (rpcActions.Keys != null) { // Stopping condition kinda shaky rpcActions = new Dictionary <ActionLibrary.IAction, RolePlayCharacterAsset>(); foreach (var rpc in rpcList) { act = rpc.Decide(); if (act.FirstOrDefault() == null) { continue; } foreach (var action in act) { rpcActions.Add(action, rpc); } } // COPY the rpc list without linked refereces var newList = new List <RolePlayCharacterAsset>(); // mmm is the new list linked to the other? to be tested foreach (var action in rpcActions) { // COPY the rpc list without linked refereces var newListAux = new List <RolePlayCharacterAsset>( rpcList); // mmm is the new list linked to the other? to be tested foreach (var rpctoPerceive in newListAux) { _eventList = new List <WellFormedNames.Name>(); if (rpctoPerceive.CharacterName != action.Value.CharacterName) { if (action.Key.Name.ToString().Contains("Speak") && action.Key.Target == rpctoPerceive.CharacterName) { _eventList.Add(EventHelper.PropertyChange( "DialogueState(" + action.Value.CharacterName.ToString() + ")", action.Key.Parameters.ElementAt(1).ToString(), action.Value.CharacterName.ToString())); } _eventList.Add(EventHelper.ActionEnd(action.Value.CharacterName.ToString(), action.Key.Name.ToString(), action.Key.Target.ToString())); rpctoPerceive.Perceive(_eventList); newList.Add(rpctoPerceive); } } } rpcList.Clear(); rpcList = newList; foreach (var rpc in rpcList) { foreach (var emot in rpc.GetAllActiveEmotions()) { if (!emotionList[rpc.CharacterName.ToString()].Keys.Contains(emot.Type)) { emotionList[rpc.CharacterName.ToString()].Add(emot.Type, (timestamp + 1)); } } } timestamp++; if (timestamp > 1) { break; } } if (emotionList.Count > 0) { validationMessage = "Simulation result: " + "\n"; foreach (var rpc in emotionList.Keys) { validationMessage += rpc + " felt: " + "\n"; foreach (var emot in emotionList[rpc]) { var lastFor = timestamp - emot.Value; double timePercentage = ((double)lastFor / (double)timestamp) * 100; validationMessage += "Emotion: " + emot.Key + " ( " + timePercentage + "% of total scenario time)\n"; } } } else { validationMessage += "No emotions detected"; } MessageBox.Show(validationMessage); }