public void Next()
        {
            int numPlayerResponses = FilterOnCondition(_currentDialogue.GetPlayerChildren(_currentNode)).Count();

            if (numPlayerResponses > 0)
            {
                _isChoosing = true;
                TriggerExitAction();
                onConversationUpdated?.Invoke();
                return;
            }

            DialogueNode[] children    = FilterOnCondition(_currentDialogue.GetAllChildren(_currentNode)).ToArray();
            int            randomIndex = UnityEngine.Random.Range(0, children.Count());

            if (_currentNode.IsPlayerSpeaking() && children.Count() <= 0)
            {
                Quit();
                return;
            }

            TriggerExitAction();
            _currentNode = children[randomIndex];
            TriggerEnterAction();
            onConversationUpdated?.Invoke();
        }
Exemple #2
0
        private DialogueNode MakeNode(DialogueNode parent)
        {
            DialogueNode node = CreateInstance <DialogueNode>();

            node.name = Guid.NewGuid().ToString();
            if (parent != null)
            {
                parent.AddChild(node.name);
                node.SetPlayerSpeaking(!parent.IsPlayerSpeaking());
                node.SetPosition(parent.GetRect().position + newNodeOffset);
            }

            return(node);
        }