Beispiel #1
0
        public AsyncOperation LoadAsync(MadLevelConfiguration.Level level)
        {
#if !UNITY_5 || UNITY_5_0 || UNITY_5_1
            if (Application.isLoadingLevel)
            {
                Debug.LogWarning("The level is already loading");
                return(null);
            }
#endif

            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());
            }
        }
Beispiel #2
0
        public void Load(MadLevelConfiguration.Level level)
        {
            // TODO

            /*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();
            }
        }
Beispiel #3
0
 static AsyncOperation LoadLevelAsync(MadLevelConfiguration.Level level) {
     lastPlayedLevelName = currentLevelName;
     // arguments must be set after reading currentLevelName
     // because reading it may overwrite arguments in result
     // TODO: find a better way to solve this
     arguments = level.arguments;
     currentLevelName = level.name;
     return Application.LoadLevelAsync(level.sceneName); // TODO: change it to scene index
 }
Beispiel #4
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();
        }
    }
Beispiel #5
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 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);
        }
    }
Beispiel #7
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());
            }
        }
Beispiel #8
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();
            }
        }
    private void InitTestMode()
    {
        Debug.Log("Initializing test mode");
        testMode = true;

        if (string.IsNullOrEmpty(testModeLevelToLoad))
        {
            Debug.LogError("Test level name not set");
        }
        else
        {
            nextLevel = MadLevel.activeConfiguration.FindLevelByName(testModeLevelToLoad);
            if (nextLevel == null)
            {
                Debug.LogError("Cannot find level with name " + testModeLevelToLoad);
            }
        }
    }
 public LevelItem(MadLevelConfiguration.Level level) {
     this.level = level;
 }
 public LevelItem(MadLevelConfiguration configuration) {
     this.level = configuration.CreateLevel();
 }
Beispiel #12
0
    private void InitTestMode() {
        Debug.Log("Initializing test mode");
        testMode = true;

        if (string.IsNullOrEmpty(testModeLevelToLoad)) {
            Debug.LogError("Test level name not set");
        } else {
            nextLevel = MadLevel.activeConfiguration.FindLevelByName(testModeLevelToLoad);
            if (nextLevel == null) {
                Debug.LogError("Cannot find level with name " + testModeLevelToLoad);
            }
        }
    }
 public LevelItem(MadLevelConfiguration.Level level)
 {
     this.level = level;
 }
 public LevelItem(MadLevelConfiguration configuration)
 {
     this.level = configuration.CreateLevel();
 }