Tetris.Engine.LoadContent C# (CSharp) Method

LoadContent() protected method

LoadContent will be called once per game and is the place to load all of your content.
protected LoadContent ( ) : void
return void
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Add the SpriteBatch service
            Services.AddService(typeof(SpriteBatch), spriteBatch);            

            //Load 2D textures
            tetrisBackground = Content.Load<Texture2D>("background");
            tetrisTextures = Content.Load<Texture2D>("tetris");

            // Load game font
            gameFont = Content.Load<SpriteFont>("font");

            // Create game field
            board = new Board(this, ref tetrisTextures, blockRectangles);
            board.Initialize();
            Components.Add(board);

            // Save player's score and game level
            score = new Score(this, gameFont);
            score.Initialize();
            Components.Add(score);

            // Load game record
            using (StreamReader streamReader = File.OpenText("record.dat"))
            {
                string player = null;
                if ((player = streamReader.ReadLine()) != null)
                    score.RecordPlayer = player;
                int record = 0;
                if ((record = Convert.ToInt32(streamReader.ReadLine())) != 0)
                    score.RecordScore = record;
            }
        }