BB.UserLevelClear.Get C# (CSharp) Метод

Get() публичный статический Метод

public static Get ( WorldType world, Level level ) : LevelClearState?
world WorldType
level Level
Результат LevelClearState?
        public static LevelClearState? Get(WorldType world, Level level)
        {
            var key = MakeKey(world, level);
            if (!PlayerPrefs.HasKey(key))
                return null;
            return (LevelClearState)Enum.Parse(typeof (LevelClearState), PlayerPrefs.GetString(key));
        }

Usage Example

Пример #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();
            }
        }