A uniform grid of tiles with collections of gems and enemies. The level owns the player and controls the game's win and lose conditions as well as scoring.
상속: IDisposable
예제 #1
0
파일: Gem.cs 프로젝트: sq/Fracture
        /// <summary>
        /// Constructs a new gem.
        /// </summary>
        public Gem(Level level, Vector2 position)
        {
            this.level = level;
            this.basePosition = position;

            LoadContent();
        }
예제 #2
0
파일: Enemy.cs 프로젝트: sq/Fracture
        /// <summary>
        /// Constructs a new Enemy.
        /// </summary>
        public Enemy(Level level, Vector2 position, string spriteSet)
        {
            this.level = level;
            this.position = position;

            LoadContent(spriteSet);
        }
예제 #3
0
파일: Player.cs 프로젝트: sq/Fracture
        /// <summary>
        /// Constructors a new player.
        /// </summary>
        public Player(Level level, Vector2 position)
        {
            this.level = level;

            LoadContent();

            Reset(position);
        }
예제 #4
0
        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);
        }