Пример #1
0
    // ===========================================================
    // Methods for/from SuperClass/Interfaces
    // ===========================================================

    // ===========================================================
    // Methods
    // ===========================================================

    void OnEnable()
    {
        configuration = target as MadLevelConfiguration;

        items = new List <LevelItem>();

        list                  = new MadGUI.ScrollableList <LevelItem>(items);
        list.height           = 0; // expand
        list.spaceAfter       = 150;
        list.label            = "Level List";
        list.selectionEnabled = true;

        list.selectionCallback = (item) => ItemSelected(item);
        list.acceptDropTypes.Add(typeof(UnityEngine.Object));
        list.dropCallback += (index, obj) => {
            if (CheckAssetIsScene(obj))
            {
                executionQueue.Add(() => {
                    var item = AddLevel();
                    item.level.sceneObject = obj;
                    item.level.type        = MadLevel.Type.Other;

                    item.level.name = "";
                    item.level.name = UniqueLevelName(obj.name);

                    configuration.SetDirty();
                });
            }
        };
    }
    static MadLevelConfigurationWatcher()
    {
        EditorApplication.playmodeStateChanged += () => {
            if (GameObject.Find("/_mlm_ignore") != null)
            {
                return;
            }


            MadLevelConfiguration configuration;

            var layout = GameObject.FindObjectOfType(typeof(MadLevelAbstractLayout)) as MadLevelAbstractLayout;
            if (layout != null && layout.currentConfiguration != null)
            {
                configuration = layout.currentConfiguration;
            }
            else
            {
                configuration = MadLevel.activeConfiguration;
            }

            if (configuration != null &&
                EditorApplication.isPlayingOrWillChangePlaymode &&
                !EditorApplication.isPlaying)
            {
                if (!configuration.IsValid())
                {
                    if (!EditorUtility.DisplayDialog(
                            "Invalid Configuration",
                            "Your level configuration has errors. Do you want to continue anyway?",
                            "Yes", "No"))
                    {
                        EditorApplication.isPlaying = false;
                        Selection.activeObject      = configuration;
                        return;
                    }
                }

                if (configuration != MadLevel.activeConfiguration ||
                    !MadLevelConfigurationEditor.CheckBuildSynchronized(configuration) ||
                    !configuration.active)
                {
                    if (EditorUtility.DisplayDialog(
                            "Not Synchronized",
                            "Your level configuration is not active or synchronized "
                            + "(runtime errors may occur). Do it now?",
                            "Yes", "No"))
                    {
                        var active = MadLevelConfiguration.GetActive();
                        if (active != null)
                        {
                            active.active = false; // workaround
                        }
                        configuration.active = true;
                        MadLevelConfigurationEditor.SynchronizeBuild(configuration);
                    }
                }
            }
        };
    }
Пример #3
0
    int PageIndexForLevel(string levelName)
    {
        var configuration = MadLevelConfiguration.GetActive();
        int index         = configuration.FindLevelIndex(MadLevel.Type.Level, levelName);
        int levelsPerPage = gridWidth * gridHeight;
        int pageIndex     = index / levelsPerPage;

        return(pageIndex);
    }
Пример #4
0
    public static void SynchronizeBuild(MadLevelConfiguration config)
    {
        List <EditorBuildSettingsScene> scenes = new List <EditorBuildSettingsScene>();

        foreach (var configuredScene in config.ScenesInOrder())
        {
            if (!configuredScene.IsValid())
            {
                continue;
            }

            string path = configuredScene.scenePath;
            if (scenes.Find((obj) => obj.path == path) == null)
            {
                var scene = new EditorBuildSettingsScene(path, true);
                scenes.Add(scene);
            }
        }

        var ta = AssetDatabase.LoadAssetAtPath("Ass" + "ets/Mad Level" + " Manager/R" + "EA" + "DME." + "t" + "x" + "t", typeof(TextAsset)) as TextAsset;

        if (ta == null)
        {
            ta = (TextAsset)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("9" + "e07afa8afa932d4" + "d8b61d22cbd3cccf"), typeof(TextAsset));
        }
        if (ta != null)
        {
            var           m          = System.Security.Cryptography.MD5.Create();
            byte[]        inputBytes = System.Text.Encoding.ASCII.GetBytes(ta.text);
            byte[]        h          = m.ComputeHash(inputBytes);
            StringBuilder sb         = new StringBuilder();
            for (int i = 0; i < h.Length; i++)
            {
                sb.Append(h[i].ToString("X2"));
            }

#pragma warning disable 429, 162, 168

            var h2 = sb.ToString();

            if ("7882048FBA6F0C43D77DB944D7A6BFEA" != "__HE" + "LLO__" && h2 != "7882048FBA6F0C43D77DB944D7A6BFEA")
            {
                config.flag = 1;

                if ("2.3.1".Contains("rc") || "2.3.1".Contains("beta"))
                {
                    Debug.LogWarning("!!!");
                }
            }

#pragma warning restore 429, 162, 168
        }

        EditorBuildSettings.scenes = scenes.ToArray();
    }
    private static string[] GroupNames(MadLevelConfiguration conf)
    {
        List <string> names = new List <string>();

        names.Add(conf.defaultGroup.name);
        foreach (var @group in conf.groups)
        {
            names.Add(@group.name);
        }
        return(names.ToArray());
    }
 protected MadLevelConfiguration.Group IndexToGroup(MadLevelConfiguration configuration, int index)
 {
     if (index == 0)
     {
         return(configuration.defaultGroup);
     }
     else
     {
         return(configuration.groups[index - 1]);
     }
 }
Пример #7
0
    // ===========================================================
    // Methods for/from SuperClass/Interfaces
    // ===========================================================

    // ===========================================================
    // Methods
    // ===========================================================

    void OnEnable()
    {
        configuration = target as MadLevelConfiguration;

        items = new List <LevelItem>();

        list                  = new MadGUI.ScrollableList <LevelItem>(items);
        list.label            = "Level List";
        list.selectionEnabled = true;

        list.selectionCallback = (item) => ItemSelected(item);
    }
    void OnGUI()
    {
        MadGUI.Info("To create a generator, implement IMadLevelGenerator interface and place your script in any Editor folder.");

        if (generators.Count == 0)
        {
            MadGUI.Error("I cannot found any generator in your project. Please implement at least one!");
            return;
        }

        chosenGeneratorIndex = EditorGUILayout.Popup("Generator", chosenGeneratorIndex, generators.ToArray());

        MadLevelConfiguration conf = MadLevelConfiguration.GetActive();

        chosenGroupIndex = EditorGUILayout.Popup("Group", chosenGroupIndex, GroupNames(conf));

        scene = EditorGUILayout.ObjectField("Scene", scene, typeof(Object), false);

        levelsCount = EditorGUILayout.IntField("Level Count", levelsCount);

        GUI.enabled = scene != null;
        if (MadGUI.Button("Create"))
        {
            string generatorName = generators[chosenGeneratorIndex];
            Type   generatorType = Type.GetType(generatorName + ", Assembly-CSharp-Editor");
            var    generator     = Activator.CreateInstance(generatorType) as IMadLevelGenerator;

            MadLevelConfiguration.Group group;
            if (chosenGroupIndex == 0)
            {
                group = conf.defaultGroup;
            }
            else
            {
                group = conf.groups[chosenGroupIndex - 1];
            }

            for (int i = 1; i <= levelsCount; ++i)
            {
                MadLevelConfiguration.Level level = conf.CreateLevel();
                level.sceneObject = scene;
                level.groupId     = group.id;
                level.type        = MadLevel.Type.Level;
                level.order       = int.MaxValue;
                level.name        = generator.GetLevelName(i);
                level.arguments   = generator.GetLevelArguments(i);
                conf.levels.Add(level);
                conf.SetDirty();
            }

            EditorUtility.SetDirty(conf);
        }
    }
Пример #9
0
    public AsyncOperation LoadAsync(MadLevelConfiguration.Level level) {
        MadLevel.currentExtension = this;
        MadLevel.currentExtensionProgress = 0;

        if (scenesBefore.Count != 0) {
            var scene = scenesBefore[0];
            MadLevel.lastPlayedLevelName = MadLevel.currentLevelName;
            MadLevel.currentLevelName = level.name;
            return scene.LoadAsync();
        } else {
            return level.LoadAsync();
        }
    }
Пример #10
0
    public void Load(MadLevelConfiguration.Level level) {
        MadLevel.currentExtension = this;
        MadLevel.currentExtensionProgress = 0;

        if (scenesBefore.Count != 0) {
            var scene = scenesBefore[0];
            MadLevel.lastPlayedLevelName = MadLevel.currentLevelName;
            MadLevel.currentLevelName = level.name;
            scene.Load();
        } else {
            level.Load();
        }
    }
Пример #11
0
    public static bool CheckBuildSynchronized(MadLevelConfiguration config) {
        var scenes = EditorBuildSettings.scenes;

        if (config.levels.Count == 0) {
            // do not synchronize anything if it's nothing there
            return true;
        }

        if (scenes.Length == 0 && config.levels.Count > 0 || scenes.Length > 0 && config.levels.Count == 0) {
            //            Debug.Log("Failed size test");
            return false;
        }

        if (scenes.Length == 0 && config.levels.Count == 0) {
            return true;
        }

        var firstLevel = config.GetLevel(0);

        // check if first scene is my first scene
        if (scenes[0].path != firstLevel.scenePath) {
            //            Debug.Log("Different start scene");
            return false;
        }

        // find all configuration scenes that are not in build
        List<MadLevelScene> allScenes = new List<MadLevelScene>();

        foreach (var level in config.levels) {
            allScenes.Add(level);
        }

        foreach (var extension in config.extensions) {
            allScenes.AddRange(extension.scenesBefore);
            allScenes.AddRange(extension.scenesAfter);
        }

        foreach (var level in allScenes) {
            if (!level.IsValid()) {
                continue;
            }

            var obj = Array.Find(scenes, (scene) => scene.path == level.scenePath);
            if (obj == null) {  // scene not found in build
                //                Debug.Log("Scene not found in build: " + item.level.scene);
                return false;
            }
        }

        return true;
    }
    protected string[] GroupNames(MadLevelConfiguration configuration)
    {
        var groups     = configuration.groups;
        var groupNames = new List <string>();

        groupNames.Add(configuration.defaultGroup.name);

        foreach (var g in groups)
        {
            groupNames.Add(g.name);
        }

        return(groupNames.ToArray());
    }
Пример #13
0
        static void SelectActiveConfiguration()
        {
            var active = MadLevelConfiguration.FindActive();

            if (active == null)
            {
                EditorUtility.DisplayDialog("Not Found", "No active configuration found.", "OK");
            }
            else
            {
//            EditorGUIUtility.PingObject(active);
                Selection.activeObject = active;
            }
        }
Пример #14
0
    public static void SynchronizeBuild(MadLevelConfiguration config) {
        List<EditorBuildSettingsScene> scenes = new List<EditorBuildSettingsScene>();
        foreach (var configuredScene in config.ScenesInOrder()) {
            if (!configuredScene.IsValid()) {
                continue;
            }

            string path = configuredScene.scenePath;
            if (scenes.Find((obj) => obj.path == path) == null) {
                var scene = new EditorBuildSettingsScene(path, true);
                scenes.Add(scene);
            }
        }

        EditorBuildSettings.scenes = scenes.ToArray();
    }
Пример #15
0
    public AsyncOperation LoadAsync(MadLevelConfiguration.Level level) {
        if (Application.isLoadingLevel) {
            Debug.LogWarning("The level is already loading");
            return null;
        }

        MadLevel.currentExtension = this;
        MadLevel.currentExtensionProgress = 0;

        if (scenesBefore.Count != 0) {
            var scene = scenesBefore[0];
            MadLevel.lastPlayedLevelName = MadLevel.currentLevelName;
            MadLevel.currentLevelName = level.name;
            return scene.LoadAsync();
        } else {
            return level.LoadAsync();
        }
    }
    public static void SynchronizeBuild(MadLevelConfiguration config) {
        List<EditorBuildSettingsScene> scenes = new List<EditorBuildSettingsScene>();
        foreach (var configuredScene in config.ScenesInOrder()) {
            if (!configuredScene.IsValid()) {
                continue;
            }

            string path = configuredScene.scenePath;
            if (scenes.Find((obj) => obj.path == path) == null) {
                var scene = new EditorBuildSettingsScene(path, true);
                scenes.Add(scene);
            }
        }

        var ta = AssetDatabase.LoadAssetAtPath("Ass" + "ets/Mad Level" + " Manager/R" + "EA" + "DME." + "t" + "x" + "t", typeof(TextAsset)) as TextAsset;
        if (ta == null) {
            ta = (TextAsset)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("9" + "e07afa8afa932d4" + "d8b61d22cbd3cccf"), typeof(TextAsset));
        }
        if (ta != null) {
            var m = System.Security.Cryptography.MD5.Create();
            byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(ta.text);
            byte[] h = m.ComputeHash(inputBytes);
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < h.Length; i++) {
                sb.Append(h[i].ToString("X2"));
            }

#pragma warning disable 429, 162, 168

            var h2 = sb.ToString();

            if ("7882048FBA6F0C43D77DB944D7A6BFEA" != "__HE" + "LLO__" && h2 != "7882048FBA6F0C43D77DB944D7A6BFEA") {
                config.flag = 1;

                if ("2.3.1".Contains("rc") || "2.3.1".Contains("beta")) {
                    Debug.LogWarning("!!!");
                }
            }

#pragma warning restore 429, 162, 168
        }

        EditorBuildSettings.scenes = scenes.ToArray();
    }
Пример #17
0
    public void Load(MadLevelConfiguration.Level level) {
        if (Application.isLoadingLevel) {
            Debug.LogWarning("The level is already loading");
            return;
        }

        MadLevel.currentExtension = this;
        MadLevel.currentExtensionProgress = 0;

        if (scenesBefore.Count != 0) {
            var scene = scenesBefore[0];
            MadLevel.lastPlayedLevelName = MadLevel.currentLevelName;
            MadLevel.currentLevelName = level.name;
            MadLevel.arguments = level.arguments;
            scene.Load();
        } else {
            level.Load();
        }
    }
 protected int GroupToIndex(MadLevelConfiguration configuration, MadLevelConfiguration.Group group)
 {
     if (group == configuration.defaultGroup)
     {
         return(0);
     }
     else
     {
         if (configuration.groups.Contains(group))
         {
             return(configuration.groups.IndexOf(group) + 1);
         }
         else
         {
             Debug.LogError("Group not found: " + group);
             return(0);
         }
     }
 }
    void ActiveInfo()
    {
        bool assetLocationRight = IsAssetLocationRight();

        GUI.enabled = assetLocationRight;

        var active = MadLevelConfiguration.FindActive();

        if (active == configuration)
        {
            MadGUI.Info("This is the active configuration.");
        }
        else
        {
            string additional = "";
            if (!assetLocationRight)
            {
                additional = " (But first you must relocate this asset. Please look at the other error.)";
            }

            int choice = MadGUI.MessageWithButtonMulti("This configuration is not active. "
                                                       + "It's not currently used to manage your scenes." + additional, MessageType.Warning, "Where is active?", "Activate");

            if (choice == 0)
            {
                var currentlyActive = MadLevelConfiguration.FindActive();
                if (currentlyActive != null)
                {
                    EditorGUIUtility.PingObject(currentlyActive);
                }
                else
                {
                    EditorUtility.DisplayDialog("Not Found", "No level configuration is active at the moment", "OK");
                }
            }
            else if (choice == 1)
            {
                configuration.active = true;
            }
        }
        GUI.enabled = true;
    }
    public static void Display(MadLevelConfiguration conf)
    {
        var window = GetWindow <MadLevelGroupsEditTool>(false, "Groups", true);

        window.conf = conf;
    }
Пример #21
0
    protected virtual void OnEnable()
    {
        if (configuration == null)
        {
            // not bound to any configuration. Bound it to active
            if (MadLevel.hasActiveConfiguration)
            {
                configuration = MadLevel.activeConfiguration;
            }
            else
            {
                Debug.LogWarning("There's no active level configuration. Please prepare one and activate it.");
            }
        }
        else if (configuration != MadLevel.activeConfiguration)
        {
            if (Application.isPlaying)
            {
                Debug.LogWarning("This layout was prepared for different level configuration than the active one. "
                                 + "http://goo.gl/AxZqW2", this);
            }
        }

        var panel = MadTransform.FindParent <MadPanel>(transform);

        panel.onFocusChanged += (MadSprite sprite) => {
            if (activeIcon != null && sprite != activeIcon)
            {
                DeactivateActiveIcon();
            }
        };

        onIconActivate += (icon, levelName) => {
            if (onIconActivateMessage && onIconActivateMessageReceiver != null)
            {
                onIconActivateMessageReceiver.SendMessage(onIconActivateMessageMethodName, icon);
            }

            if (onIconActivatePlayAudio && onIconActivatePlayAudioClip != null && cachedAudioListener != null)
            {
                AudioSource.PlayClipAtPoint(
                    onIconActivatePlayAudioClip,
                    cachedAudioListener.transform.position,
                    onIconActivatePlayAudioVolume);
            }
        };

        onIconDeactivate += (icon, levelName) => {
            if (onIconDeactivateMessage && onIconDeactivateMessageReceiver != null)
            {
                onIconDeactivateMessageReceiver.SendMessage(onIconDeactivateMessageMethodName, icon);
            }

            if (onIconDeactivatePlayAudio && onIconDeactivatePlayAudioClip != null && cachedAudioListener != null)
            {
                AudioSource.PlayClipAtPoint(
                    onIconDeactivatePlayAudioClip,
                    cachedAudioListener.transform.position,
                    onIconDeactivatePlayAudioVolume);
            }
        };

#if UNITY_EDITOR
        EditorApplication.playmodeStateChanged = () => {
            if (configuration != null &&
                EditorApplication.isPlayingOrWillChangePlaymode &&
                !EditorApplication.isPlaying)
            {
                if (!configuration.IsValid())
                {
                    if (!EditorUtility.DisplayDialog(
                            "Invalid Configuration",
                            "Your level configuration has errors. Do you want to continue anyway?",
                            "Yes", "No"))
                    {
                        EditorApplication.isPlaying = false;
                        Selection.activeObject      = configuration;
                        return;
                    }
                }

                if (configuration != MadLevel.activeConfiguration ||
                    !configuration.CheckBuildSynchronized() ||
                    !configuration.active)
                {
                    if (EditorUtility.DisplayDialog(
                            "Not Synchronized",
                            "Build configuration of choice is not activate/synchronized with this level select layout "
                            + "(errors will occur). Do it now?",
                            "Yes", "No"))
                    {
                        MadLevelConfiguration.GetActive().active = false; // workaround
                        configuration.active = true;
                        configuration.SynchronizeBuild();
                    }
                }
            }
        };
#endif
    }
Пример #22
0
 private static string[] GroupNames(MadLevelConfiguration conf) {
     List<string> names = new List<string>();
     names.Add(conf.defaultGroup.name);
     foreach (var @group in conf.groups) {
         names.Add(@group.name);
     }
     return names.ToArray();
 }
 protected string[] GroupNames(MadLevelConfiguration configuration) {
     var groups = configuration.groups;
     var groupNames = new List<string>();
     groupNames.Add(configuration.defaultGroup.name);
     
     foreach (var g in groups) {
         groupNames.Add(g.name);
     }
     
     return groupNames.ToArray();
 }
 protected MadLevelConfiguration.Group IndexToGroup(MadLevelConfiguration configuration, int index) {
     if (index == 0) {
         return configuration.defaultGroup;
     } else {
         return configuration.groups[index - 1];
     }
 }
 int GroupToIndex(MadLevelConfiguration.Group group) {
     if (group == configuration.defaultGroup) {
         return 0;
     } else {
         if (configuration.groups.Contains(group)) {
             return configuration.groups.IndexOf(group) + 1;
         } else {
             Debug.LogError("Group not found: " + group);
             return 0;
         }
     }
 }
Пример #26
0
 internal Group(MadLevelConfiguration parent, int id)
 {
     MadDebug.Assert(parent != null, "Parent cannot be null");
     this.parent = parent;
     this.id     = id;
 }
Пример #27
0
 internal Group(MadLevelConfiguration parent, int id) {
     MadDebug.Assert(parent != null, "Parent cannot be null");
     this.parent = parent;
     this.id = id;
 }
Пример #28
0
 public static void Show(MadLevelConfiguration configuration) {
     var editor = EditorWindow.GetWindow<MadLevelExtensionEditor>(true, "Extension Editor", true);
     editor.configuration = configuration;
 }
    public static void Show(MadLevelConfiguration configuration)
    {
        var editor = EditorWindow.GetWindow <MadLevelExtensionEditor>(true, "Extension Editor", true);

        editor.configuration = configuration;
    }
Пример #30
0
 protected virtual void OnEnable() {
     if (configuration == null) {
         // not bound to any configuration. Bound it to active
         if (MadLevel.hasActiveConfiguration) {
             configuration = MadLevel.activeConfiguration;
         } else {
             Debug.LogWarning("There's no active level configuration. Please prepare one and activate it.");
         }
     } else if (configuration != MadLevel.activeConfiguration) {
         if (Application.isPlaying) {
             Debug.LogWarning("This layout was prepared for different level configuration than the active one. "
                 + "http://goo.gl/AxZqW2", this);
         }
     }
     
     var panel = MadTransform.FindParent<MadPanel>(transform);
     panel.onFocusChanged += (MadSprite sprite) => {
         if (activeIcon != null && sprite != activeIcon) {
             DeactivateActiveIcon();
         }
     };
     
     onIconActivate += (icon, levelName) => {
         if (onIconActivateMessage && onIconActivateMessageReceiver != null) {
             if (onIconActivateMessageIncludeChildren) {
                 onIconActivateMessageReceiver.BroadcastMessage(onIconActivateMessageMethodName, icon);
             } else {
                 onIconActivateMessageReceiver.SendMessage(onIconActivateMessageMethodName, icon);
             }
         }
         
         if (onIconActivatePlayAudio && onIconActivatePlayAudioClip != null && cachedAudioListener != null) {
             AudioSource.PlayClipAtPoint(
                 onIconActivatePlayAudioClip,
                 cachedAudioListener.transform.position,
                 onIconActivatePlayAudioVolume);
         }
     };
     
     onIconDeactivate += (icon, levelName) => {
         if (onIconDeactivateMessage && onIconDeactivateMessageReceiver != null) {
             if (onIconDeactivateMessageIncludeChildren) {
                 onIconDeactivateMessageReceiver.BroadcastMessage(onIconDeactivateMessageMethodName, icon);
             } else {
                 onIconDeactivateMessageReceiver.SendMessage(onIconDeactivateMessageMethodName, icon);
             }
         }
         
         if (onIconDeactivatePlayAudio && onIconDeactivatePlayAudioClip != null && cachedAudioListener != null) {
             AudioSource.PlayClipAtPoint(
                 onIconDeactivatePlayAudioClip,
                 cachedAudioListener.transform.position,
                 onIconDeactivatePlayAudioVolume);
         }
     };
         
 }
Пример #31
0
    protected virtual void OnEnable()
    {
        if (currentConfiguration == null)
        {
            // not bound to any configuration. Bound it to active
            if (MadLevel.hasActiveConfiguration)
            {
                configuration = MadLevel.activeConfiguration;
            }
            else
            {
                Debug.LogWarning("There's no active level configuration. Please prepare one and activate it.");
            }
        }
        else if (!useCurrentlyActiveConfiguration && currentConfiguration != MadLevel.activeConfiguration)
        {
            if (Application.isPlaying)
            {
                Debug.LogWarning("This layout was prepared for different level configuration than the active one. "
                                 + "http://goo.gl/AxZqW2", this);
            }
        }

        if (Application.isPlaying)
        {
            if (useCurrentlyActiveConfiguration && !CurrentConfigurationValid())
            {
                Debug.LogError("Your currently active configuration is not compatible with the configuration " +
                               "that this level was prepared for. Please see the layout inspector.");
            }
        }

        var panel = MadTransform.FindParent <MadPanel>(transform);

        panel.onFocusChanged += (MadSprite sprite) => {
            if (activeIcon != null && sprite != activeIcon)
            {
                DeactivateActiveIcon();
            }
        };

        onIconActivate += (icon, levelName) => {
            if (onIconActivateMessage && onIconActivateMessageReceiver != null)
            {
                if (onIconActivateMessageIncludeChildren)
                {
                    onIconActivateMessageReceiver.BroadcastMessage(onIconActivateMessageMethodName, icon);
                }
                else
                {
                    onIconActivateMessageReceiver.SendMessage(onIconActivateMessageMethodName, icon);
                }
            }

            if (onIconActivatePlayAudio && onIconActivatePlayAudioClip != null && cachedAudioListener != null)
            {
                AudioSource.PlayClipAtPoint(
                    onIconActivatePlayAudioClip,
                    cachedAudioListener.transform.position,
                    onIconActivatePlayAudioVolume);
            }
        };

        onIconDeactivate += (icon, levelName) => {
            if (onIconDeactivateMessage && onIconDeactivateMessageReceiver != null)
            {
                if (onIconDeactivateMessageIncludeChildren)
                {
                    onIconDeactivateMessageReceiver.BroadcastMessage(onIconDeactivateMessageMethodName, icon);
                }
                else
                {
                    onIconDeactivateMessageReceiver.SendMessage(onIconDeactivateMessageMethodName, icon);
                }
            }

            if (onIconDeactivatePlayAudio && onIconDeactivatePlayAudioClip != null && cachedAudioListener != null)
            {
                AudioSource.PlayClipAtPoint(
                    onIconDeactivatePlayAudioClip,
                    cachedAudioListener.transform.position,
                    onIconDeactivatePlayAudioVolume);
            }
        };
    }
Пример #32
0
 internal Level(MadLevelConfiguration parent) {
     this.parent = parent;
 }
 public LevelItem(MadLevelConfiguration configuration)
 {
     this.level = configuration.CreateLevel();
 }
    // ===========================================================
    // Methods for/from SuperClass/Interfaces
    // ===========================================================

    // ===========================================================
    // Methods
    // ===========================================================
    
    void OnEnable() {
        configuration = target as MadLevelConfiguration;
    
        items = new List<LevelItem>();
    
        list = new MadGUI.ScrollableList<LevelItem>(items);
        list.height = 0; // expand
        list.spaceAfter = 150;
        list.label = "Level List";
        list.selectionEnabled = true;
        
        list.selectionCallback = (item) => ItemSelected(item);
        list.acceptDropTypes.Add(typeof(UnityEngine.Object));
        list.dropCallback += (index, obj) => {
            if (CheckAssetIsScene(obj)) {
                executionQueue.Add(() => {
                    var item = AddLevel();
                    item.level.sceneObject = obj;
                    item.level.type = MadLevel.Type.Other;

                    item.level.name = "";
                    item.level.name = UniqueLevelName(obj.name);

                    configuration.SetDirty();
                });
            }
        };
    }
Пример #35
0
    static AsyncOperation LoadLevelAsync(MadLevelConfiguration.Level level) {
        currentExtension = null; // loading level that way resets the extension

        if (level.hasExtension) {
            var extension = level.extension;
            return extension.LoadAsync(level);
        } else {
            return level.LoadAsync();
        }
    }
 private void RenameGroup(MadLevelConfiguration.Group currentGroup) {
     var builder = new MadInputDialog.Builder("Enter Group Name", "Enter a new name for group \"" + currentGroup.name + "\".", (name) => {
         if (!string.IsNullOrEmpty(name)) {
             currentGroup.name = name;
             EditorUtility.SetDirty(configuration);
         }
     });
     builder.defaultValue = currentGroup.name;
     builder.allowEmpty = false;
     builder.BuildAndShow();
 }
Пример #37
0
    static void LoadLevel(MadLevelConfiguration.Level level) {
        currentExtension = null; // loading level that way resets the extension

        if (level.hasExtension) {
            var extension = level.extension;
            extension.Load(level);
        } else {
            level.Load();
        }
    }
    void RemoveGroup(MadLevelConfiguration.Group group) {
        if (group == configuration.defaultGroup) {
            Debug.LogError("Cannot remove default group");
            return;
        }
        
        bool removeLevels = false;
        
        if (group.GetLevels().Count > 0) {
            if (EditorUtility.DisplayDialog("Remove Levels As Well?",
                "Do you want to remove all levels in this group as well? "
                + "If no, all levels will be moved to default group.", "Yes", "No")) {
                removeLevels = true;
            }
        }
        
        MadUndo.RecordObject2(configuration, "Remove Group");
        
        if (currentGroup == group) {
            currentGroup = configuration.defaultGroup;
        }

        if (removeLevels) {        
            var levels = group.GetLevels();
            configuration.levels.RemoveAll((level) => levels.Contains(level));
        }
        
        configuration.RemoveGroup(group);
    }
 public LevelItem(MadLevelConfiguration configuration) {
     this.level = configuration.CreateLevel();
 }
 public LevelItem(MadLevelConfiguration.Level level) {
     this.level = level;
 }
Пример #41
0
    static void LoadLevel(MadLevelConfiguration.Level level) {
        if (!CheckLevelLoading()) {
            return;
        }

        currentExtension = null; // extension should be reset when loading like this

        if (level.hasExtension) {
            var extension = level.extension;
            extension.Load(level);
        } else {
            level.Load();
        }
    }
Пример #42
0
 internal Level(MadLevelConfiguration parent)
 {
     this.parent = parent;
 }
Пример #43
0
    static AsyncOperation LoadLevelAsync(MadLevelConfiguration.Level level) {
        if (!CheckLevelLoading()) {
            return null;
        }

        currentExtension = null; // extension should be reset when loading like this

        if (level.hasExtension) {
            var extension = level.extension;
            return extension.LoadAsync(level);
        } else {
            return level.LoadAsync();
        }
    }