private void LoadCollisionData(FileFormats.Levels.LevelFile levelData) { Level = new Level(levelData.Width, levelData.Height); for (int y = 0; y < levelData.CollisionMap.Height; y++) { for (int x = 0; x < levelData.CollisionMap.Width; x++) { Level.Cells[x, y] = levelData.CollisionMap.Data[y][x]; } } }
public void LoadLevel(FileFormats.Levels.LevelFile levelData) { Entities.Clear(); Entities.Add(new Crate(new Vector(600, 330))); Entities.Add(new WeaponCollectable(WeaponType.Shotgun, new Vector(300, 330))); Entities.Add(new ArmorCollectable(new Vector(200, 330))); Entities.Add(new MedpackCollectable(new Vector(240, 330))); LoadCollisionData(levelData); LoadEnemies(levelData.Enemies); InitializePlayer(); }
public static void Save(LevelFile level, string file) { var jsonLevel = JsonConvert.SerializeObject(level, Formatting.Indented); File.WriteAllText(file, jsonLevel, Encoding.UTF8); }