/// <summary> /// Get CrewMember reply to player dialogue during a post-race event /// </summary> internal DialogueStateActionDTO SendPostRaceEvent(IntegratedAuthoringToolAsset iat, DialogueStateActionDTO selected, Team team, List <string> subjects) { if (selected == null) { return(null); } var nextState = selected.NextState; var dialogueOptions = iat.GetDialogueActionsByState(nextState).ToList(); //get dialogue if (dialogueOptions.Any()) { //select reply var selectedReply = dialogueOptions.OrderBy(o => Guid.NewGuid()).First(); PostRaceFeedback(selected.NextState, team, subjects); var styleSplit = selectedReply.Style.Split('_').Where(sp => !string.IsNullOrEmpty(sp)).ToList(); if (styleSplit.Any(s => s != WellFormedNames.Name.NIL_STRING)) { styleSplit.ForEach(s => PostRaceFeedback(s, team, subjects)); } return(selectedReply); } return(null); }
/// <summary> /// Get recruit reaction to statement based on their rating of that skill /// </summary> internal string SendRecruitEvent(IntegratedAuthoringToolAsset iat, Skill skill) { string state; if (Skills[skill] >= 9) { state = "NPC_StronglyAgree"; } else if (Skills[skill] >= 7) { state = "NPC_Agree"; } else if (Skills[skill] >= 5) { state = "NPC_Neutral"; } else if (Skills[skill] >= 3) { state = "NPC_Disagree"; } else { state = "NPC_StronglyDisagree"; } var dialogueOptions = iat.GetDialogueActionsByState(state).ToList(); return(dialogueOptions.OrderBy(o => Guid.NewGuid()).First().Utterance); }
public void PlayerInitiateTurn() { var playerAgent = rpcList.Find(x => x.CharacterName == _chosenCharacter); var actionList = _iat.GetDialogueActionsByState(IATConsts.INITIAL_DIALOGUE_STATE).ToList(); var newList = actionList.FindAll(x => x.Meaning.First().ToString().Contains("Initiate")); CommeillFaut.CommeillFautAsset cif = CommeillFaut.CommeillFautAsset.LoadFromFile(rpcList.First().CommeillFautAssetSource); List <DialogueStateActionDTO> dialogs = new List <DialogueStateActionDTO>(); foreach (var social in cif.GetAllSocialExchanges()) { Debug.Log(social.Name.ToString() + " and " + newList.FirstOrDefault().Meaning.First()); var member = newList.FindAll(x => x.Meaning.First().ToString().Contains(social.Name.ToString())).Shuffle().FirstOrDefault(); dialogs.Add(member); } // newList = newList.FindAll(x => x.Parameters[2].ToString().Contains("Initiate")); // Debug.Log(" decided size " + newList.Count); // IEnumerable<DialogueStateActionDTO> availableDialogs = new DialogueStateActionDTO[1]; stopTime = true; /* * foreach (var speakAction in newList) * { * Name currentState = speakAction.CurrentState; * Name nextState = speakAction.NextState; * Name meaning = speakAction.Meanings[0]; * // Debug.Log(" meaning: " + meaning); * Name style = Name.BuildName("*"); * dialogs = _iat.GetDialogueActions(IATConsts.AGENT, currentState, nextState, meaning, style); * // Debug.Log(" dialog: " + dialogs.Count + " first: " + dialogs[0].Utterance); * availableDialogs = dialogs; * * }*/ UpdateButtonTexts(false, dialogs); }
private List <DialogueStateActionDTO> DeterminePlayerDialogues() { var actions = playerRPC.Decide().ToArray(); var dOpt = new List <DialogueStateActionDTO>(); foreach (var action in actions) { if (action.Key.ToString().Equals(IATConsts.DIALOG_ACTION_KEY)) { Name currentState = action.Parameters[0]; Name nextState = action.Parameters[1]; Name meaning = action.Parameters[2]; Name style = action.Parameters[3]; var dialogs = iat.GetDialogueActions(currentState, nextState, meaning, style); dOpt.AddRange(dialogs); } } dOpt = dOpt.Distinct().ToList(); var additional = iat.GetDialogueActionsByState("Any"); dOpt.AddRange(additional); return(dOpt); }
/// <summary> /// Send an event to the EA/RPC to get CrewMember information /// </summary> internal List <string> SendMeetingEvent(IntegratedAuthoringToolAsset iat, string style, Team team) { var reply = new List <string>(); switch (style) { case "StatReveal": //select a random skill that has not been displayed before or any random skill if all have been displayed var availableStats = RevealedSkills.Where(s => s.Value == 0).Select(s => s.Key).ToList(); if (availableStats.Count == 0) { availableStats = RevealedSkills.Where(s => s.Value != Skills[s.Key]).Select(s => s.Key).ToList(); } if (availableStats.Count == 0) { availableStats = RevealedSkills.Select(s => s.Key).ToList(); } var randomStat = StaticRandom.Int(0, availableStats.Count); var statName = availableStats[randomStat].ToString(); var selectedStat = (Skill)Enum.Parse(typeof(Skill), statName); var statValue = Skills[selectedStat]; //add this skill rating to the dictionary to revealed skills RevealedSkills[selectedStat] = statValue; //get available dialogue based off of the rating in the skill style += statValue <= ConfigKey.BadSkillRating.GetIntValue() ? "Bad" : statValue >= ConfigKey.GoodSkillRating.GetIntValue() ? "Good" : "Middle"; reply.Add(statName.ToLower()); //save that this skill has been revealed UpdateSingleBelief(NPCBelief.RevealedSkill, statValue, statName); break; case "RoleReveal": //select a random position var pos = team.Boat.Positions[StaticRandom.Int(0, team.Boat.PositionCount)]; //get dialogue based on if they would be above or below mid-range in this position style += pos.GetPositionRating(this) <= 5 ? "Bad" : "Good"; reply.Add(pos.ToString()); break; case "OpinionRevealPositive": //get all opinions for active crewmembers and the manager var crewOpinionsPositive = CrewOpinions.Where(c => team.CrewMembers.ContainsKey(c.Key)).ToDictionary(p => p.Key, p => p.Value); crewOpinionsPositive.Add(team.ManagerName, CrewOpinions[team.ManagerName]); //get all opinions where the value is equal/greater than the OpinionLike value in the config var opinionsPositive = crewOpinionsPositive.Where(co => co.Value >= ConfigKey.OpinionLike.GetIntValue()).ToDictionary(o => o.Key, o => o.Value); //if there are any positive opinions if (opinionsPositive.Any()) { //select an opinion at random var pickedOpinionPositive = opinionsPositive.OrderBy(o => Guid.NewGuid()).First(); if (pickedOpinionPositive.Value >= ConfigKey.OpinionStrongLike.GetIntValue()) { style += "High"; } reply.Add(pickedOpinionPositive.Key != team.ManagerName ? pickedOpinionPositive.Key : "you"); AddOrUpdateRevealedOpinion(pickedOpinionPositive.Key, pickedOpinionPositive.Value); } //if there are no positive opinions, get dialogue based on that else { style += "None"; } break; case "OpinionRevealNegative": var crewOpinionsNegative = CrewOpinions.Where(c => team.CrewMembers.ContainsKey(c.Key)).ToDictionary(p => p.Key, p => p.Value); crewOpinionsNegative.Add(team.ManagerName, CrewOpinions[team.ManagerName]); var opinionsNegative = crewOpinionsNegative.Where(co => co.Value <= ConfigKey.OpinionDislike.GetIntValue()).ToDictionary(o => o.Key, o => o.Value); if (opinionsNegative.Any()) { var pickedOpinionNegative = opinionsNegative.OrderBy(o => Guid.NewGuid()).First(); if (pickedOpinionNegative.Value >= ConfigKey.OpinionStrongDislike.GetIntValue()) { style += "High"; } reply.Add(pickedOpinionNegative.Key != team.ManagerName ? pickedOpinionNegative.Key : "you"); AddOrUpdateRevealedOpinion(pickedOpinionNegative.Key, pickedOpinionNegative.Value); } else { style += "None"; } break; } SaveStatus(); var dialogueOptions = iat.GetDialogueActionsByState("NPC_" + style).ToList(); if (dialogueOptions.Any()) { reply.Insert(0, dialogueOptions.OrderBy(o => Guid.NewGuid()).First().Utterance); return(reply); } reply.Clear(); return(reply); }
/// <summary> /// Get the names of possible post race events /// </summary> public List <string> GetEventKeys() { return(iat.GetDialogueActionsByState("NPC_PostRaceEventStart").Select(d => d.NextState.Split('_')[1]).ToList()); }
public void GetPlayerDialogueOptions() { UpdateCurrentState(); _currentPlayerDialogue = _integratedAuthoringTool.GetDialogueActionsByState(_currentStateName.ToString()).ToArray(); GetPlayerDialogueSuccessEvent?.Invoke(_currentPlayerDialogue); }
// Update is called once per frame void Update() { if (_agentController == null) { return; } if (!_agentController.IsRunning) { return; } if (_agentController.getJustReplied()) { var reply = _agentController.getReply(); waitingForReply = false; Initialized = true; UpdateHistory(reply.Utterance); ClearDialogOptions(); var cs = reply.CurrentState; var ns = reply.NextState; var m = reply.Meaning; var sty = reply.Style; List <Name> events = new List <Name>(); events.Add(EventHelper.ActionEnd(_agentController.RPC.CharacterName.ToString(), "Speak(" + cs + "," + ns + ", " + m + "," + sty + ")", "Player")); events.Add(EventHelper.PropertyChange("DialogueState(" + _agentController.RPC.CharacterName + ")", ns, _agentController.RPC.CharacterName.ToString())); events.Add(EventHelper.PropertyChange("Has(Floor)", "Player", _agentController.RPC.CharacterName.ToString())); Player.Perceive(events); } if (Input.GetKeyDown(KeyCode.P)) { if (Time.timeScale > 0) { Time.timeScale = 0; } else { Time.timeScale = 1; } } if (Input.GetKeyDown(KeyCode.Alpha1)) { if (!m_buttonList.IsEmpty()) { m_buttonList[0].onClick.Invoke(); } } if (Input.GetKeyDown(KeyCode.Alpha2)) { if (!m_buttonList.IsEmpty()) { m_buttonList[1].onClick.Invoke(); } } if (Input.GetKeyDown(KeyCode.Alpha3)) { if (!m_buttonList.IsEmpty()) { m_buttonList[2].onClick.Invoke(); } } if (Input.GetKeyDown(KeyCode.Alpha4)) { if (!m_buttonList.IsEmpty()) { m_buttonList[3].onClick.Invoke(); } } if (Input.GetKeyDown(KeyCode.Alpha5)) { if (!m_buttonList.IsEmpty()) { m_buttonList[4].onClick.Invoke(); } } if (Input.GetKeyDown(KeyCode.Alpha6)) { if (!m_buttonList.IsEmpty()) { m_buttonList[5].onClick.Invoke(); } } if (Input.GetKeyDown(KeyCode.Keypad1)) { if (!m_buttonList.IsEmpty()) { m_buttonList[0].onClick.Invoke(); } } if (Input.GetKeyDown(KeyCode.Keypad2)) { if (!m_buttonList.IsEmpty()) { m_buttonList[1].onClick.Invoke(); } } if (Input.GetKeyDown(KeyCode.Keypad3)) { if (!m_buttonList.IsEmpty()) { m_buttonList[2].onClick.Invoke(); } } if (Input.GetKeyDown(KeyCode.Keypad4)) { if (!m_buttonList.IsEmpty()) { m_buttonList[3].onClick.Invoke(); } } if (Input.GetKeyDown(KeyCode.Keypad5)) { if (!m_buttonList.IsEmpty()) { m_buttonList[4].onClick.Invoke(); } } if (Input.GetKeyDown(KeyCode.Keypad6)) { if (!m_buttonList.IsEmpty()) { m_buttonList[5].onClick.Invoke(); } } if (Input.GetKeyDown(KeyCode.S)) { this.SaveState(); } if (_agentController.IsRunning) { _agentController.UpdateEmotionExpression(); if (waitingForReply == false) { var action = Player.Decide().FirstOrDefault(); if (action == null) { return; } // Debug.Log("Action Key: " + action.Key); var currentState = action.Parameters[0].ToString(); var possibleOptions = _iat.GetDialogueActionsByState(currentState).ToList(); var originalPossibleActions = possibleOptions; if (PJScenario) { if (!Initialized) { var newOptions = possibleOptions.Shuffle(rand).Where(x => x.CurrentState == "Start").Take(3).ToList(); newOptions.AddRange(_iat.GetDialogueActionsByState("Introduction")); possibleOptions = newOptions; } else { // var uhm = rand.Next(0, 10); // Debug.Log(" rand " + uhm ); var newOptions = possibleOptions.Where(x => !alreadyUsedDialogs.ContainsKey(x.Utterance)).Shuffle(rand).Take(3).ToList(); var additionalOptions = _iat.GetDialogueActionsByState("Start").Shuffle(rand).Take(2).ToList(); possibleOptions = newOptions.Concat(additionalOptions).ToList(); if (alreadyUsedDialogs.Count() > 12 && possibleOptions.Count() < 6) { var ClosureOptions = _iat.GetDialogueActionsByState("Closure").Shuffle(rand).Take(1).ToList(); possibleOptions = newOptions.Concat(additionalOptions).Concat(ClosureOptions).ToList(); } } } // UpdatePapers(); waitingForReply = true; AddDialogButtons(possibleOptions); } } }