Exemplo n.º 1
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);
                }

                if (configManager.GetInt(SelectChapterFirstShownKey) == 0)
                {
                    var unlockedChapterCount = gameState.GetAllUnlockedStartNodeNames().Count;
                    var reachedChapterCount  = gameState.GetAllStartNodeNames()
                                               .Count(name => checkpointManager.IsReachedAnyHistory(name, 0));
                    if (unlockedChapterCount == 1 && reachedChapterCount > 1)
                    {
                        Alert.Show(I18n.__("title.first.selectchapter"));
                        configManager.SetInt(SelectChapterFirstShownKey, 1);
                    }
                }

                onFinish?.Invoke();
            });
        }
Exemplo n.º 2
0
        private void DialogueSaveCheckpoint(bool firstEntryOfNode, bool dialogueStepped, out bool isReached,
                                            out bool isReachedAnyHistory)
        {
            if (!firstEntryOfNode && dialogueStepped)
            {
                stepNumFromLastCheckpoint++;
            }

            var entry = checkpointManager.GetReached(nodeHistory, currentIndex);

            isReached           = entry != null;
            isReachedAnyHistory = checkpointManager.IsReachedAnyHistory(currentNode.name, currentIndex);
            if (entry == null)
            {
                // Tell CheckpointManager that a new dialogue entry has been reached
                checkpointManager.SetReached(nodeHistory, currentIndex, GetRestoreEntry());
            }

            // Change states after creating or restoring from checkpoint
            if (shouldSaveCheckpoint)
            {
                stepNumFromLastCheckpoint = 0;
            }

            if (entry != null)
            {
                this.RuntimeAssert(stepNumFromLastCheckpoint == entry.stepNumFromLastCheckpoint,
                                   $"stepNumFromLastCheckpoint mismatch: {stepNumFromLastCheckpoint} {entry.stepNumFromLastCheckpoint}. Try to clear save data.");
                this.RuntimeAssert(restrainCheckpointNum == entry.restrainCheckpointNum,
                                   $"restrainCheckpointNum mismatch: {restrainCheckpointNum} {entry.restrainCheckpointNum}. Try to clear save data.");
            }

            if (checkpointRestrained)
            {
                restrainCheckpointNum--;
            }

            // As the action for this dialogue will be re-run, it's fine to just reset forceCheckpoint to false
            forceCheckpoint = false;
        }
Exemplo n.º 3
0
 private bool IsUnlocked(string name)
 {
     return(unlockAllChaptersForDebug || unlockedStartNodeNames.Contains(name) ||
            checkpointManager.IsReachedAnyHistory(name, 0));
 }