コード例 #1
0
        // Do not use this code as production example
        // This was made only to test dialogs in implementations

        public static Dialog GetDialog()
        {
            var items = new IDialogItem[]
            {
                new Label("Default label"),
                new Button("Some button"),
                new Panel(new IDialogItem[] { new Button("Button 1"), new Button("Button 2") })
                {
                    Flow = ItemsFlow.LeftRight
                },
                new CheckBox()
                {
                    Content = new Label("CheckBox 1")
                },
                new RadioBox()
                {
                    Content = new Label("RadioBox 1")
                },
                new RadioBox()
                {
                    Content = new Label("RadioBox 2")
                }
            };

            var dialog = new Dialog("Test Dialog", items);

            dialog.BottomPanel.Add(new Button("Fine"));
            dialog.BottomPanel.Add(new Button("Good"));

            return(dialog);
        }
コード例 #2
0
 public void Append(IDialogItem item)
 {
     if (Text.Length > 0)
     {
         dialogItems.Add(new TextNode(Text.ToString()));
         Text.Clear();
     }
     dialogItems.Add(item);
 }
コード例 #3
0
 void IViewModel.OnCheck(IDialogItem item, bool value)
 {
     foreach (var i in items)
     {
         if (i.key == item.Key)
         {
             i.isChecked = value;
             ++itemsRevision;
             changeNotification.Post();
             break;
         }
     }
 }
コード例 #4
0
    void OnEnable()
    {
        // Obviously, none of this is efficient at all
        var jsonData           = JSON.Parse(jsonFile.text);
        var possibleEntryNodes = new HashSet <string>();

        for (var i = 0; i < jsonData.Count; ++i)
        {
            var node = jsonData[i];
            var id   = node["id"];
            nodeByIdCache[id] = node;
            possibleEntryNodes.Add(id);
        }

        for (var i = 0; i < jsonData.Count; ++i)
        {
            var node = jsonData[i];
            if (node["choices"].Count > 0)
            {
                for (var c = 0; c < node["choices"].Count; ++c)
                {
                    possibleEntryNodes.Remove(node["choices"][c]);
                }
            }
            else if (node["branches"].Count > 0)
            {
                foreach (var branch in node["branches"].Keys)
                {
                    possibleEntryNodes.Remove(node["branches"][branch]);
                }
            }
            else
            {
                string next = node["next"];
                if (next != null)
                {
                    possibleEntryNodes.Remove(next);
                }
            }
        }
        Debug.Assert(possibleEntryNodes.Count == 1,
                     "Found multiple possible entry nodes (no input) for dialog " +
                     dialogName + ": [" + string.Join(", ", possibleEntryNodes
                                                      .Select(node => nodeSummary(nodeByIdCache[node]))) + "]");
        var entryId = possibleEntryNodes.ToList()[0];

        root = getNode(entryId);
    }
コード例 #5
0
    public void setDialog(IDialogItem item, GameObject player, GameObject npc)
    {
        Debug.Assert(currentItem == null);
        Debug.Assert(player != null && player.GetComponent <Actor>());

        this.player = player;
        this.npc    = npc;

        Debug.Log("setDialog " + item);
        player.GetComponent <Actor>().SetState(EActorState.InConversation); // can't move
        startDialog.Invoke(player, npc);

        currentItem = item;
        currentItem.enter(this);
        advanceDialog();
    }
コード例 #6
0
    IDialogItem parseBranchNode(JSONNode jsonData)
    {
        var item = cacheItem(jsonData["id"], new DialogBranch(jsonData["variable"]));

        var         branches      = new Dictionary <string, IDialogItem>();
        IDialogItem defaultBranch = null;

        foreach (var branch in jsonData["branches"].Keys)
        {
            if (branch == "_default")
            {
                defaultBranch = getNode(jsonData["branches"][branch]);
            }
            else
            {
                branches[branch] = getNode(jsonData["branches"][branch]);
            }
        }

        item.setBranches(branches, defaultBranch);
        return(item);
    }
コード例 #7
0
    void advanceDialog()
    {
        Debug.Assert(currentItem != null);
        var next = currentItem.next(this);

        while (next != null && next != currentItem)
        {
            Debug.Log("advance dialog " + next);
            next.enter(this);
            currentItem = next;
            next        = currentItem.next(this);
        }
        ;

        if (next == null)
        {
            Debug.Log("end conversation");
            currentItem = null;
            Debug.Assert(player != null);
            player.GetComponent <Actor>().SetState(EActorState.Walking);
            endDialog.Invoke();
        }
    }
コード例 #8
0
 void IViewModel.OnSelect(IDialogItem item)
 {
     selectedKey = item?.Key;
     changeNotification.Post();
 }
コード例 #9
0
 void UpdateButton(IDialogItem item, NSButton btn)
 {
     btn.Title  = item.Title;
     btn.Target = new ActionTarget(_ => viewModel.OnCheck(item, btn.State == NSCellStateValue.On));
     btn.State  = item.IsChecked ? NSCellStateValue.On : NSCellStateValue.Off;
 }
コード例 #10
0
ファイル: DialogItems.cs プロジェクト: josefnpat/LD44
 public Choice(string text, IDialogItem next)
 {
     this.text = text;
     this.next = next;
 }
コード例 #11
0
ファイル: DialogItems.cs プロジェクト: josefnpat/LD44
 public void setNext(IDialogItem nextItem)
 {
     this.nextItem = nextItem;
 }
コード例 #12
0
ファイル: DialogItems.cs プロジェクト: josefnpat/LD44
 public void setBranches(Dictionary <string, IDialogItem> branches, IDialogItem defaultBranch)
 {
     this.branches      = branches;
     this.defaultBranch = defaultBranch;
 }
コード例 #13
0
 private void AddMessageToHistory(IDialogItem item)
 {
     _chatHistory.Add(item);
 }
コード例 #14
0
        private  void ProcessCommandDialogItem(IDialogItem item)
        {
            _logger.LogInfo($"Start ProcessCommandDialogItem. OperatorID - {OperatorID}");
            giveAnswer(ChatAction.Typing());
           
            giveAnswer(item.GetReaction());

            //если обработано то удаляем из памяти
            if (item.IsProcessed)
                _chatHistory.Remove(item);

            _logger.LogInfo($"End ProcessCommandDialogItem. OperatorID - {OperatorID}");
        }