Commit e95beb60 authored by Maxime POULAIN's avatar Maxime POULAIN
Browse files

wip loading on fly of levels

parent 4bfb4ef9
......@@ -50,7 +50,7 @@ namespace ZZZZZZ.Worlds
public void Load(string level)
{
Unload();
//Unload();
var filename = Path.GetFileNameWithoutExtension(level);
var path = Path.GetDirectoryName(level);
......@@ -64,27 +64,25 @@ namespace ZZZZZZ.Worlds
{
for (int j = levelY - 1; j <= levelY + 1; j++)
{
var filePathToLoad = Path.Combine(path, $"{splitted[0]}_{i}-{j}.tmx");
var tmxLevel = Application.Current.ResourceCache.GetTmxFile2D(filePathToLoad, false);
if (tmxLevel != null)
{
var _level = new Level(filePathToLoad, j, i);
Loaded.Add(_level);
if (i == levelX && j == levelY)
Current = _level;
if (!Loaded.Exists(x => x.WorldX == i && x.WorldY == j))
{
var filePathToLoad = Path.Combine(path, $"{splitted[0]}_{i}-{j}.tmx");
var tmxLevel = Application.Current.ResourceCache.GetTmxFile2D(filePathToLoad, false);
if (tmxLevel != null)
{
var _level = new Level(filePathToLoad, j, i);
Loaded.Add(_level);
if (i == levelX && j == levelY)
Current = _level;
}
}
}
}
}
private void CollisionHandler_CollisionBoxTriggered(CollisionBoxTriggeredEventArgs obj)
{
/*if (Current != null)
Current.Dispose();
Current = new Level(Assets.Levels.BasePath + obj.Goto);
*/
//To do => unload unused levels in neighborhood
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment