public void SetLocked(bool val) {
     var levelNames = GetLevelNames();
     for (int i = 0; i < levelNames.Count; ++i) {
         var levelName = levelNames[i];
         MadLevelProfile.SetLocked(levelName, val);
     }
 }
Пример #2
0
    void SetLevelBoolean(bool val)
    {
        string levelName = icon.level.name;

        switch (specialType)
        {
        case SpecialType.Regular:
            MadLevelProfile.SetLevelBoolean(levelName, name, val);
            break;

        case SpecialType.LevelNumber:
            MadDebug.Assert(false, "Level numbers are not persistent!");
            break;

        case SpecialType.Locked:
            MadLevelProfile.SetLocked(levelName, val);
            break;

        case SpecialType.Completed:
            MadLevelProfile.SetCompleted(levelName, val);
            break;

        default:
            MadDebug.Assert(false, "Unknown special type: " + specialType);
            break;
        }
    }
Пример #3
0
    protected override void Update()
    {
        base.Update();

        if (justEnabled)
        {
            if (Application.isPlaying)
            {
                if (isTemplate)
                {
                    MadGameObject.SetActive(gameObject, false);
                }

                // completed property object is optional
                // if it's not present, check the completed property manually
                if (completedProperty == null)
                {
                    if (level != null)
                    {
                        completed = MadLevelProfile.IsCompleted(level.name);
                    }
                }

                onMouseUp += (sprite) => Activate();
                onTap     += (sprite) => Activate();

                if (!isTemplate)
                {
                    if (!canFocusIfLocked && locked)
                    {
                        var sprite = GetComponent <MadSprite>();
                        sprite.eventFlags = sprite.eventFlags & ~MadSprite.EventFlags.Focus;
                    }
                }
            }

            // init child objects visibility
            if (level != null)
            {
                ChangeState(showWhenLevelLocked, locked);
                ChangeState(showWhenLevelUnlocked, !locked);
                ChangeState(showWhenLevelCompleted, completed);
                ChangeState(showWhenLevelNotCompleted, !completed);

                // if this level is mark as unlocked, make sure that it has a profile entry
                // this is a workaround for situation when level is unlocked, but then level order is changed
                if (!locked && Application.isPlaying)
                {
                    MadLevelProfile.SetLocked(level.name, false);
                }
            }

            justEnabled = false;
        }
    }
Пример #4
0
 /// <summary>
 /// Applies default locked state to profile data if this is not yet applied.
 /// This function is useful when you don't want to use level select screens or you want to get
 /// level locked state before running level select screen.
 /// </summary>
 public void ApplyProfile()
 {
     for (int i = 0; i < levels.Count; ++i)
     {
         var level = levels[i];
         if (!MadLevelProfile.IsLockedSet(level.name))
         {
             MadLevelProfile.SetLocked(level.name, level.lockedByDefault);
         }
     }
 }
    void UnlockAllLevels()
    {
        if (!CheckPlaying())
        {
            return;
        }

        var levelNames = MadLevel.GetAllLevelNames();

        foreach (var levelName in levelNames)
        {
            MadLevelProfile.SetLocked(levelName, false);
        }

        MadLevel.ReloadCurrent();
    }