Пример #1
0
        /// <summary>
        /// Clears the current level and generates a new level
        /// </summary>
        /// <param name="numRows">Number of tile rows</param>
        /// <param name="numCols">Number of tile columns</param>
        /// <param name="defaultTileReferenceCode">Default tile to populate the GameLevel</param>
        public void NewLevel(int numRows, int numCols, byte defaultTileReferenceCode)
        {
            ClearLevel();
            _camera = new Camera2D(Graphics);
            _mainLayer = new GameLayerTiled(this, numRows, numCols, defaultTileReferenceCode);

            // Verification WriteLine
            Console.WriteLine("New level created!\n Tile rows: " + numRows + "\nTile cols: " + numCols);
        }
Пример #2
0
        /// <summary>
        /// Completely clears this GameLevel
        /// </summary>
        private void ClearLevel()
        {
            _mainLayer = null;
            _gameLayers.Clear();
            _camera = null;

            // Verification WriteLine
            Console.WriteLine("Current level cleared!");
        }
Пример #3
0
        /// <summary>
        /// Load a GameLevel from a specified file
        /// </summary>
        /// <param name="filename">File to load from</param>
        public void LoadLevel(string filename)
        {
            string loadPath = "Levels\\" + filename;
            GameLevelData levelData = Content.Load<GameLevelData>(loadPath);

            ClearLevel();
            _camera = new Camera2D(Graphics);
            _mainLayer = new GameLayerTiled(this, levelData.MainLayerData);

            // Verification WriteLine
            Console.WriteLine("Load successfull!\n" + loadPath);
        }