/// <summary> /// Creates a new level screen /// </summary> /// <param name="game">Game to bind to</param> /// <param name="data">Level data</param> public LevelScreen(Game game, Level data) : base(game) { _levelData = data; _camera = new Camera2D(game); _background = new Layer(game, _camera); _foreground = new Layer(game, _camera); _overlay = new Layer(game); this.Exited += new EventHandler(LevelScreen_Exited); }
/// <summary> /// Reads a level from a file /// </summary> /// <param name="path">The path to the file</param> /// <returns>The level</returns> public static Level ReadLevel(string path) { StreamReader reader = new StreamReader(TitleContainer.OpenStream(path)); int width = 20; int height = 15; var level = new Level(width, height); for (int y = 0; y < height; y++) { string line = reader.ReadLine(); for (int x = 0; x < width; x++) level[x, y] = line[x]; } level.Description = reader.ReadLine(); return level; }