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 SetPlayerAction(Guid actionId) { var reply = _currentPlayerDialogue.FirstOrDefault(a => a.Id.Equals(actionId)); if (reply != null && _chatScoreHistory.LastOrDefault(c => c.ChatObject.Agent == "Player")?.ChatObject.CurrentState != reply.CurrentState) { var actionFormat = $"Speak({reply.CurrentState},{reply.NextState},{reply.Meaning},{reply.Style})"; // Submit dialogue choice to the IAT event list. _events.Add(EventHelper.ActionStart(IATConsts.PLAYER, actionFormat, CurrentCharacter.CharacterName.ToString())); _events.Add(EventHelper.ActionEnd(IATConsts.PLAYER, actionFormat, CurrentCharacter.CharacterName.ToString())); _events.Add(EventHelper.PropertyChange(string.Format(IATConsts.DIALOGUE_STATE_PROPERTY, IATConsts.PLAYER), reply.NextState, "Player")); // UCM tracker tracks the filename ID of each player dialogue choice made TrackerEventSender.SendEvent(new TraceEvent("DialogueSelection", TrackerAsset.Verb.Initialized, new Dictionary <string, string> { { TrackerContextKey.PlayerDialogueState.ToString(), reply.CurrentState }, { TrackerContextKey.PlayerDialogueCode.ToString(), reply.FileName }, { TrackerContextKey.PlayerDialogueText.ToString(), reply.Utterance } })); TrackerEventSender.SendEvaluationEvent(TrackerEvalautionEvent.AssetActivity, new Dictionary <TrackerEvaluationKey, string> { { TrackerEvaluationKey.AssetId, "FAtiMA" }, { TrackerEvaluationKey.Action, "DialogueSelection" } }); TrackerEventSender.SendEvaluationEvent(TrackerEvalautionEvent.GameActivity, new Dictionary <TrackerEvaluationKey, string> { { TrackerEvaluationKey.Event, "DialogueSelection" }, { TrackerEvaluationKey.GoalOrientation, "Progression" }, { TrackerEvaluationKey.Tool, "DialogueChoices" } }); _feedbackScores.Clear(); UpdateFeedbackScores(reply, "Player"); GetCharacterResponse(); GetFeedbackEvent?.Invoke(_feedbackScores, FeedbackLevel); } }