Exemplo n.º 1
0
        public override void Show(Action onFinish)
        {
            var chapterNames         = gameState.GetAllStartupNodeNames();
            var reachedChaptersCount =
                chapterNames.Count(name => checkpointManager.IsReachedForAnyVariables(name, 0) != null);

            if (reachedChaptersCount < 2 && !unlockAllChaptersForDebug && !Utils.GetKeyInEditor(KeyCode.LeftShift))
            {
                BeginChapter();
                return;
            }

            UpdateAllButtons();
            base.Show(onFinish);
        }
Exemplo n.º 2
0
        public override void Show(Action onFinish)
        {
            base.Show(() =>
            {
                viewManager.dialoguePanel.SetActive(false);
                viewManager.StopAllAnimations();
                gameState.ResetGameState();

                if (bgmController != null && !string.IsNullOrEmpty(bgmName))
                {
                    bgmController.scriptVolume = bgmVolume;
                    bgmController.Play(bgmName);
                }

                var reachedChapterCount = gameState.GetAllStartupNodeNames()
                                          .Count(name => checkpointManager.IsReachedForAnyVariables(name, 0) != null);
                if (reachedChapterCount > 1 && configManager.GetInt(ChapterFirstUnlockedKey) == 0)
                {
                    Alert.Show(I18n.__("title.first.selectchapter"));
                    configManager.SetInt(ChapterFirstUnlockedKey, 1);
                }

                onFinish?.Invoke();
            });
        }
Exemplo n.º 3
0
        /// <summary>
        /// Move back to a previously stepped node, the lazy execution block and callbacks at the target dialogue entry
        /// will be executed again.
        /// </summary>
        /// <param name="nodeName">the node to move to</param>
        /// <param name="dialogueIndex">the index of the dialogue to move to</param>
        /// <param name="variablesHash">hash of variables of the target</param>
        /// <param name="clearFuture">clear saved checkpoints in the future</param>
        public void MoveBackTo(string nodeName, int dialogueIndex, string variablesHash, bool clearFuture = false)
        {
            if (CheckActionRunning())
            {
                return;
            }

            // animation should stop
            NovaAnimation.StopAll(AnimationType.All ^ AnimationType.UI);

            // restore history
            var backNodeIndex = walkedThroughNodes.FindLastIndex(x => x == nodeName);

            Assert.IsFalse(backNodeIndex < 0,
                           $"Nova: move back to node {nodeName} that has not been walked through.");

            // state should be normal when goes backward
            state = State.Normal;

            if (clearFuture)
            {
                // all save data of nodes to be removed are deleted
                for (var i = backNodeIndex + 1; i < walkedThroughNodes.Count; i++)
                {
                    checkpointManager.UnsetReached(walkedThroughNodes[i]);
                }

                // all save data of later dialogues are deleted
                for (var i = dialogueIndex + 1; i < flowChartTree.GetNode(nodeName).dialogueEntryCount; i++)
                {
                    checkpointManager.UnsetReached(nodeName, i);
                }
            }

            var nodeHistoryRemoveLength = walkedThroughNodes.Count - backNodeIndex - 1;

            walkedThroughNodes.RemoveRange(backNodeIndex + 1, nodeHistoryRemoveLength);
            currentNode  = flowChartTree.GetNode(walkedThroughNodes.Last());
            currentIndex = dialogueIndex;

            // restore status
            var entry = checkpointManager.IsReached(nodeName, dialogueIndex, variablesHash);

            if (entry == null)
            {
                Debug.LogWarning(
                    $"Nova: Unable to find node with varhash = {variablesHash}, falling back to any variable.");
                entry = checkpointManager.IsReachedForAnyVariables(nodeName, dialogueIndex);
            }

            Restore(entry);
        }
Exemplo n.º 4
0
 private bool IsUnlocked(string name)
 {
     return(unlockAllChaptersForDebug || unlockedStartNodeNames.Contains(name) ||
            checkpointManager.IsReachedForAnyVariables(name, 0) != null);
 }