Initialize() public méthode

public Initialize ( ) : void
Résultat void
Exemple #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        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");
            gameFont = Content.Load <SpriteFont> ("Arial");

            // 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;
                }
            }
        }
Exemple #2
0
        private void GameOver()
        {
            if (score.Value > score.RecordScore)
            {
                score.RecordScore = score.Value;

                pause = true;

                Record record = new Record();
                //record.ShowDialog ();

                score.RecordPlayer = record.Player;

                using (StreamWriter writer = File.CreateText("record.dat")) {
                    writer.WriteLine(score.RecordPlayer);
                    writer.WriteLine(score.RecordScore);
                }

                pause = false;
            }
            board.Initialize();
            score.Initialize();
        }
Exemple #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        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;
            }
        }