Пример #1
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;
        }
    }
    public int CountCompleted() {
        var levelNames = GetLevelNames();

        int result = 0;
        for (int i = 0; i < levelNames.Count; ++i) {
            if (MadLevelProfile.IsCompleted(levelNames[i])) {
                result++;
            }
        }

        return result;
    }
Пример #3
0
    protected override void Start()
    {
        base.Start();

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

        onMouseUp += (sprite) => Activate();
        onTap     += (sprite) => Activate();
    }
Пример #4
0
    /// <summary>
    /// Gets the last completed level icon in current group or null if cannot be found.
    /// </summary>
    /// <returns></returns>
    public MadLevelIcon GetLastCompletedIcon()
    {
        var lastCompleted =
            from l in MadLevel.activeConfiguration.levels
            where l.groupId == configurationGroup &&
            l.type == MadLevel.Type.Level &&
            MadLevelProfile.IsCompleted(l.name)
            orderby l.order descending
            select l;
        var lastCompletedLevel = lastCompleted.FirstOrDefault();

        if (lastCompletedLevel != null)
        {
            return(MadLevelLayout.current.GetIcon(lastCompletedLevel.name));
        }
        else
        {
            return(null);
        }
    }
    private string GetPropertyValue()
    {
        string levelName = icon.level.name;

        switch (propertyType)
        {
        case PropertyType.Completed:
            return(MadLevelProfile.IsCompleted(levelName).ToString());

        case PropertyType.Locked:
            return(MadLevelProfile.IsLocked(levelName).ToString());

        case PropertyType.LevelNumber:
            return(icon.levelNumber.text);

        case PropertyType.Custom:
            return(MadLevelProfile.GetLevelAny(levelName, customPropertyName, null));

        default:
            Debug.LogError("Unknown property type: " + propertyType);
            return(null);
        }
    }
Пример #6
0
    bool GetLevelBoolean()
    {
        string levelName = icon.level.name;

        switch (specialType)
        {
        case SpecialType.Regular:
            return(MadLevelProfile.GetLevelBoolean(levelName, name));

        case SpecialType.LevelNumber:
            return(MadLevelProfile.GetLevelBoolean(levelName, name));

        case SpecialType.Locked:
            return(MadLevelProfile.IsLocked(levelName));

        case SpecialType.Completed:
            return(MadLevelProfile.IsCompleted(levelName));

        default:
            MadDebug.Assert(false, "Unknown special type: " + specialType);
            return(false);
        }
    }
Пример #7
0
 /// <summary>
 /// Finds the last completed level (in the order).
 /// </summary>
 /// <returns>The last completed level name or <code>null</code> if there's no level
 /// that is marked as completed.</returns>
 public static string FindLastCompletedLevelName() {
     return FindLastLevelName((level) => MadLevelProfile.IsCompleted(level.name));
 }
Пример #8
0
 /// <summary>
 /// Finds the first completed level (in the order).
 /// </summary>
 /// <returns>The first completed level name or <code>null</code> if there's no level
 /// that is marked as completed.</returns>
 public static string FindFirstCompletedLevelName(string groupName) {
     return FindFirstLevelName(groupName, (level) => MadLevelProfile.IsCompleted(level.name));
 }