Exemple #1
0
        private IEnumerator WaitActionEnd(bool hasBeenReached)
        {
            while (actionPauseLock.isLocked)
            {
                yield return(null);
            }

            state = State.Normal;

            // everything that makes game state pause has ended, change dialogue
            // TODO: use advancedDialogueHelper to override dialogue
            // The game author should define overriding dialogues for each locale
            // By the way, we don't need to store all dialogues in save data,
            // just those overriden
            DialogueChanged?.Invoke(new DialogueChangedData(currentNode.name, currentIndex,
                                                            currentDialogueEntry.displayData, new Dictionary <string, VoiceEntry>(voicesOfNextDialogue),
                                                            hasBeenReached));

            voicesOfNextDialogue.Clear();

            var pendingJumpTarget = advancedDialogueHelper.GetJump();

            if (pendingJumpTarget != null)
            {
                var node = flowChartTree.GetNode(pendingJumpTarget);
                this.RuntimeAssert(node != null, "Node " + pendingJumpTarget + " does not exist!");
                MoveToNextNode(node);
            }
        }
Exemple #2
0
        /// <summary>
        /// Bind all lazy binding entries
        /// </summary>
        private void BindAllLazyBindingEntries()
        {
            foreach (var entry in lazyBindingLinks)
            {
                var node = entry.from;
                node.AddBranch(entry.branchInfo, flowChartTree.GetNode(entry.destination));
            }

            // Remove unnecessary reference
            lazyBindingLinks = null;
        }
Exemple #3
0
        private IEnumerator UpdateDialogue(bool firstEntryOfNode, bool dialogueStepped, bool fromCheckpoint,
                                           Action onFinish)
        {
            if (!fromCheckpoint)
            {
                // If the following lines of code are put into a new coroutine, one frame's delay will be introduced,
                // so don't do that
                currentDialogueEntry.ExecuteAction(DialogueActionStage.BeforeCheckpoint, isRestoring);
                while (actionPauseLock.isLocked)
                {
                    yield return(null);
                }
            }

            DialogueSaveCheckpoint(firstEntryOfNode, dialogueStepped, out var isReached,
                                   out var isReachedAnyHistory);
            dialogueWillChange.Invoke(new DialogueWillChangeData());

            currentDialogueEntry.ExecuteAction(DialogueActionStage.Default, isRestoring);
            while (actionPauseLock.isLocked)
            {
                yield return(null);
            }

            dialogueChanged.Invoke(new DialogueChangedData(nodeHistory.Last(), currentIndex,
                                                           currentDialogueEntry.GetDisplayData(), new Dictionary <string, VoiceEntry>(voicesNextDialogue),
                                                           isReached, isReachedAnyHistory));

            voicesNextDialogue.Clear();

            currentDialogueEntry.ExecuteAction(DialogueActionStage.AfterDialogue, isRestoring);
            while (actionPauseLock.isLocked)
            {
                yield return(null);
            }

            if (advancedDialogueHelper.GetFallThrough())
            {
                Step(Utils.WrapActionWithParameter <bool>(onFinish));
                yield break;
            }

            var pendingJumpTarget = advancedDialogueHelper.GetJump();

            if (pendingJumpTarget != null)
            {
                var node = flowChartTree.GetNode(pendingJumpTarget);
                this.RuntimeAssert(node != null, $"Node {pendingJumpTarget} not found.");
                MoveToNextNode(node, onFinish);
                yield break;
            }

            onFinish?.Invoke();
        }