Level save + load

This commit is contained in:
2023-06-16 17:08:56 +03:00
parent d9fbd99072
commit 0eb8b1d4ee
132 changed files with 20138 additions and 15 deletions

View File

@@ -31,6 +31,7 @@ namespace Level
private int height;
private LayoutCell[][] layout;
private Vector3Int firstCellPos;
private LevelSaveSystem levelSaveSystem = new LevelSaveSystem();
// Properties
public static LevelBuilder Instance => instance;
@@ -59,6 +60,11 @@ namespace Level
EditCellAt(worldMousePosition);
}
if (Input.GetKeyDown(KeyCode.T))
{
Save();
}
}
@@ -135,6 +141,25 @@ namespace Level
}
public void Save()
{
LevelData levelData = CreateLevelData();
Save(levelData);
}
public void Save(LevelData levelData)
{
levelSaveSystem.Save(levelData);
}
public void Load()
{
levelSaveSystem.Load();
}
public LayoutCell GetCellAtLayout(Vector2Int layoutPosition)
{
// Check that cell with these indices exists in array