'); -->

# Level Workflow API

One of the most powerful part of Mad Level Manager is how it can manage level loading. You defined earlier your levels using the Configurator. Now you can take fully advantage of it.

## Common Workflow

There is only one class that you need to know about: MadLevel (click to check out detailed class documentation). This class is defined in MadLevelManager namespace, so don’t forget to put this at the top of your C# file:

    using MadLevelManager;

### Loading first level of your game

Let’s say that you’ve named your first level as First Level. Loading this level is quite straightforward:

    MadLevel.LoadLevelByName("First Level");

It will work, but you need to know level name here. If this is first level of type Level in your level configuration, then you can make it much better:

    MadLevel.LoadFirst(MadLevel.Type.Level);

Now you don’t need to know the name of first level, and this code will work in any projects with level configuration and with at least one level defined. How cool is that?

### Loading next level

Player had just finished your level and he wants to go to the next one. No problem!

    MadLevel.LoadNext(MadLevel.Type.Level);

LoadNext will look for next level with type Level and loads it. It is just that easy! But what if this is last level of your game? Then you can do the following:

    if (MadLevel.HasNext(MadLevel.Type.Level)) {
        MadLevel.LoadNext(MadLevel.Type.Level);
    } else {
        MadLevel.LoadLevelByName("Game Finished");
    }

This code will check if there’s any other level that can be loaded. If not Game Finished level is loaded, which should be of type Other. In this way you’ve complete setup of your level workflow!

### Going back

Do you want to go back to previous level? LoadNext() has its opposite:

    MadLevel.LoadPrevious(MadLevel.Type.Level);

Maybe you want to restart your whole game? Then you want to load the very first level of any type that is defined in your configuration. Here’s how to do it:

    MadLevel.LoadFirst();

## More info

You probably will be interested in looking at full MadLevel API and maybe MadLevelConfiguration API which is available as field MadLevel.activeConfiguration.