-
-
Notifications
You must be signed in to change notification settings - Fork 5
Creating and loading levels
After having initialized a Database
, you may access its loaded levels by doing database.UserLevels
, which returns a LevelCollection
. You may also create your own database which refers to database files in a custom path like this:
string gameManagerPath = "your path here"; // the path of the CCGameManager.dat file which contains everything else
string localLevelsPath = "your path here"; // the path of the CCLocalLevels.dat file which contains the levels you can edit
Database database = new Database(gameManagerPath, localLevelsPath);
database.UserLevels = new LevelCollection();
It is important to note that the path have to refer to actual files so that they be loaded. Soon you will be able to refer to paths that do not already exist and start from there.
As soon as the Database
instance is initialized, it will try to load all the information that is provided from the specified (or default) file paths that contain the database info. In other words, new Database()
will automatically initialize the process of getting the gamesave and local levels info.
To create a new level, you may simply do
Level newLevel = database.CreateLevel();
which will create a new level and return the instance of it. Editing newLevel
's properties and such will also have its effect applied in the database instance. For them to be saved, you'll need to do database.WriteLevelData();
, which will write the current data on the specified file path.
WARNING: This overwrites the old data. Make sure to store backups to avoid potential bugs.