Exemplo n.º 1
0
        private void InitLevelButton(LevelButton button, Level level)
        {
            button.SetLevel(level);

            var clearState = UserLevelClear.Get(World, level);

            if (clearState.HasValue)
            {
                button.SetAsClear(clearState.Value);
            }
            else
            {
                var unlocked   = UserLevelClear.Unlocked;
                var shouldLock = true;

                if (unlocked.HasValue)
                {
                    var unlockedValue     = unlocked.Value;
                    var isCurrentUnlocked = unlockedValue.World == World && unlockedValue.Level == level;
                    shouldLock = !isCurrentUnlocked;
                }

                button.SetLock(shouldLock);
                button.SetAsNotCleared();
            }
        }
        private void Win()
        {
            Debug.Assert(_starsLeft.Count == 0);

            UnregisterGetStar();

            UserLevelClear.Win(_levelDef);

            var nextLevel = _levelDef.Next();

            if (nextLevel.HasValue)
            {
                TransitionManager.TransferToLevel(nextLevel.Value);
            }
            else
            {
                TransitionManager.TransferToLevelSelect(new LevelSelectController.TransitionData(_levelDef.World));
            }
        }