/// <summary> /// Constructs a new gem. /// </summary> public Gem(Level level, Vector2 position) { this.level = level; this.basePosition = position; LoadContent(); }
/// <summary> /// Constructs a new Enemy. /// </summary> public Enemy(Level level, Vector2 position, string spriteSet) { this.level = level; this.position = position; LoadContent(spriteSet); }
/// <summary> /// Constructors a new player. /// </summary> public Player(Level level, Vector2 position) { this.level = level; LoadContent(); Reset(position); }
private void LoadNextLevel() { // Find the path of the next level. string levelPath; // Loop here so we can try again when we can't find a level. while (true) { // Try to find the next level. They are sequentially numbered txt files. levelPath = String.Format("Levels/{0}.txt", ++levelIndex); levelPath = Path.Combine("Content/", levelPath); try { using (var stream = TitleContainer.OpenStream(levelPath)) break; } catch (FileNotFoundException) { } // If there isn't even a level 0, something has gone wrong. if (levelIndex == 0) throw new Exception("No levels found."); // Whenever we can't find a level, start over again at 0. levelIndex = -1; } // Unloads the content for the current level before loading the next one. if (level != null) level.Dispose(); // Load the level. level = new Level(Services, levelPath); }