Exemple #1
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            sprites = new SpriteManager(Game);
            Game.Components.Add(sprites);

            player = new Player(Game, this);
            Game.Components.Add(player);

            this.background = new Background(Game);
            Game.Components.Add(background);

            this.obstacles = new Obstacles(Game as Game1);
            Game.Components.Add(obstacles);

            AdGameComponent.Initialize(this.Game, "test_client");
            Game.Components.Add(AdGameComponent.Current);

            highscores = new HighscoreDisplay(Game);
            Game.Components.Add(highscores);
            CreateAd();

            spriteBatch = new SpriteBatch(Game.GraphicsDevice);

            this.sound = Game.Services.GetService(typeof(SoundManager)) as SoundManager;

            Enabled = false;
            Visible = true;

            base.Initialize();
        }
Exemple #2
0
        public void Restart()
        {
            Game.Components.Remove(sprites);
            Game.Components.Remove(player);
            Game.Components.Remove(background);
            Game.Components.Remove(obstacles);
            Game.Components.Remove(highscores);

            highscores = new HighscoreDisplay(Game);
            highscores.Enabled = true;
            Game.Components.Add(highscores);

            sprites = new SpriteManager(Game);
            Game.Components.Add(sprites);

            player = new Player(Game, this);

            player.Restart();

            Game.Components.Add(player);

            this.background = new Background(Game);
            Game.Components.Add(background);

            this.obstacles = new Obstacles(Game as Game1);
            Game.Components.Add(obstacles);
        }