示例#1
0
        private void buttonContinue_Click(object sender, EventArgs e)
        {
            foreach (var ag in agentsInChat)
            {
                if (ag.IsPlayer)
                {
                    continue;
                }
                var decisions = ag.Decide().Where(a => a.Key.ToString() == IATConsts.DIALOG_ACTION_KEY);

                if (decisions.Any())
                {
                    var    action = decisions.First();
                    string error;
                    var    diag = LoadedAsset.GetDialogAction(action, out error);
                    if (error != null)
                    {
                        EditorTools.WriteText(richTextBoxChat, ag.CharacterName + " : " + error, Color.Red, true);
                    }
                    else if (this.ValidateTarget(action, ag.CharacterName.ToString()))
                    {
                        EditorTools.WriteText(richTextBoxChat,
                                              ag.CharacterName + " To " + action.Target + " : ", Color.ForestGreen, false);

                        EditorTools.WriteText(richTextBoxChat, diag.Utterance, Color.Black, false);

                        EditorTools.WriteText(richTextBoxChat,
                                              " (" + ag.GetInternalStateString() + " | " + ag.GetSIRelationsString() + ")" + "\n", Color.DarkRed,
                                              true);

                        HandleEffects(action, ag, diag);
                    }
                }

                ag.Update();
            }

            EditorTools.WriteText(richTextBoxChat, "", Color.Black, true);

            var playerRPC     = agentsInChat.First(a => a.IsPlayer == true);
            var decisionsList = playerRPC.Decide().Where(a => a.Key.ToString() == IATConsts.DIALOG_ACTION_KEY);



            if (decisionsList.Any())
            {
                var maxUtility      = decisionsList.Max(x => x.Utility);
                var playerDecisions = decisionsList.Where(x => x.Utility == maxUtility);
                this.determinePlayerDialogueOptions(playerDecisions, playerRPC.CharacterName.ToString());
            }
            else
            {
                listBoxPlayerDialogues.DataSource = new List <string>();
            }

            playerRPC.Update();

            //Assumption: All agents have the same tick
            textBoxTick.Text = agentsInChat[0].Tick.ToString();
        }
示例#2
0
        private void determinePlayerDialogueOptions(IEnumerable <IAction> actions, string playerCharName)
        {
            playerActions = new List <IAction>();
            string error;

            foreach (var a in actions)
            {
                var diag = LoadedAsset.GetDialogAction(a, out error);
                if (error != null)
                {
                    EditorTools.WriteText(richTextBoxChat, playerCharName + " : " + error, Color.Red, true);
                }
                else if (this.ValidateTarget(a, playerCharName))
                {
                    playerActions.Add(a);
                }
            }

            listBoxPlayerDialogues.DataSource = playerActions.Select(x => "To " + x.Target + " : " +
                                                                     LoadedAsset.GetDialogAction(x, out error)
                                                                     .Utterance).ToList();
        }
示例#3
0
        private void listBoxPlayerDialogues_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            var idx = listBoxPlayerDialogues.SelectedIndex;

            if (idx == -1)
            {
                return;
            }

            var act = playerActions[idx];

            EditorTools.WriteText(richTextBoxChat,
                                  "Player " + listBoxPlayerDialogues.SelectedItem.ToString() + "\n", Color.Blue, true);

            var    playerRPC = agentsInChat.First(x => x.IsPlayer);
            string error;
            var    dialog = LoadedAsset.GetDialogAction(act, out error);

            this.HandleEffects(act, playerRPC, dialog);

            this.buttonContinue_Click(sender, e);
        }