// Load graphics content for the game public override void Activate() { if (_content == null) { _content = new ContentManager(ScreenManager.Game.Services, "Content"); } _gameFont = _content.Load <SpriteFont>("gamefont"); _spriteBatch = new SpriteBatch(ScreenManager.GraphicsDevice); batSprite = new BatSprite(); exitSprite = new ExitSprite(); background = _content.Load <Texture2D>("dark-cave"); explosion = new ExplosionParticleSystem(ScreenManager.Game, 20); ScreenManager.Game.Components.Add(explosion); SoundEffect.MasterVolume = 0.5f; firework = new FireworkParticleSystem(ScreenManager.Game, 20); ScreenManager.Game.Components.Add(firework); //Creates initial coins. System.Random rand = new System.Random(); coins = new CoinSprite[] { new CoinSprite(new Vector2((float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Height)), new CoinSprite(new Vector2((float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Height)), new CoinSprite(new Vector2((float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Height)), new CoinSprite(new Vector2((float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Height)), new CoinSprite(new Vector2((float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Height)), new CoinSprite(new Vector2((float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Height)), new CoinSprite(new Vector2((float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Height)) }; foreach (var coin in coins) { coin.LoadContent(_content); } batSprite.LoadContent(_content); bangers = _content.Load <SpriteFont>("bangers"); exitSprite.LoadContent(_content); coinPickup = _content.Load <SoundEffect>("Pickup_Coin14"); backgroundMusic = _content.Load <Song>("Bio Unit - Docking"); MediaPlayer.IsRepeating = true; MediaPlayer.Play(backgroundMusic); // once the load has finished, we use ResetElapsedTime to tell the game's // timing mechanism that we have just finished a very long frame, and that // it should not try to catch up. ScreenManager.Game.ResetElapsedTime(); }
// Load graphics content for the game public override void Activate() { if (_content == null) { _content = new ContentManager(ScreenManager.Game.Services, "Content"); } _gameFont = _content.Load <SpriteFont>("gamefont"); _spriteBatch = new SpriteBatch(ScreenManager.GraphicsDevice); batSprite = new BatSprite(); exitSprite = new ExitSprite(); batSprite.LoadContent(_content); bangers = _content.Load <SpriteFont>("bangers"); exitSprite.LoadContent(_content); coinPickup = _content.Load <SoundEffect>("Pickup_Coin14"); _foreground = _content.Load <Texture2D>("foreground"); _midground = _content.Load <Texture2D>("midground"); _background = _content.Load <Texture2D>("backgroundscene"); backgroundMusic = _content.Load <Song>("Bio Unit - Docking"); MediaPlayer.IsRepeating = true; MediaPlayer.Play(backgroundMusic); System.Random rand = new System.Random(); coins = new CoinSprite[] { new CoinSprite(new Vector2((float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Height)), new CoinSprite(new Vector2((float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Height)), new CoinSprite(new Vector2((float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Height)), new CoinSprite(new Vector2((float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Height)), new CoinSprite(new Vector2((float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Height)), new CoinSprite(new Vector2((float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Height)), new CoinSprite(new Vector2((float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * ScreenManager.GraphicsDevice.Viewport.Height)) }; foreach (var coin in coins) { coin.LoadContent(_content); } // once the load has finished, we use ResetElapsedTime to tell the game's // timing mechanism that we have just finished a very long frame, and that // it should not try to catch up. ScreenManager.Game.ResetElapsedTime(); }