ActionScene( Game game, Texture2D theTexture, Texture2D backgroundTexture, SpriteFont font, Vector2 gameoverPosition) : base(game) { this._audio = (AudioLibrary)Game.Services.GetService(typeof(AudioLibrary)); this._background = new ImageComponent(game, backgroundTexture, ImageComponent.DrawMode.Stretch); Components.Add(this._background); this._actionTexture = theTexture; this._spriteBatch = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch)); this._meteors = new MeteorsManager(Game, ref this._actionTexture); Components.Add(this._meteors); this._scoreFont = font; this._gameoverPosition = gameoverPosition; this._scorePlayer1 = new Score(game, font, Color.Blue) { Position = new Vector2(10, 10) }; Components.Add(this._scorePlayer1); this._rumblePad = new SimpleRumblePad(game); Components.Add(this._rumblePad); this._powerSource = new PowerSource(game, ref this._actionTexture); Components.Add(this._powerSource); #if DEBUG this._positionDebugText = new TextComponent(game, this._scoreFont, new Vector2(), Color.Red); Components.Add(this._positionDebugText); #endif }
/// <summary> /// Default Constructor /// </summary> /// <param name="game">The main game object</param> /// <param name="theTexture">Texture with the sprite elements</param> /// <param name="backgroundTexture">Texture for the background</param> /// <param name="font">Font used in the score</param> public ActionScene(Game game, Texture2D theTexture, Texture2D backgroundTexture, SpriteFont font) : base(game) { background = new ImageComponent(game, backgroundTexture, ImageComponent.DrawMode.Stretch); Components.Add(background); actionTexture = theTexture; // Get the current sprite batch spriteBatch = (SpriteBatch) Game.Services.GetService(typeof(SpriteBatch)); // Get the audio library audio = (AudioLibrary) Game.Services.GetService(typeof(AudioLibrary)); meteors = new MeteorsManager(Game, ref actionTexture); Components.Add(meteors); player1 = new Player(Game, ref actionTexture, PlayerIndex.One, new Rectangle(323, 15, 30, 30)); player1.Initialize(); Components.Add(player1); player2 = new Player(Game, ref actionTexture, PlayerIndex.Two, new Rectangle(360, 17, 30, 30)); player2.Initialize(); Components.Add(player2); scorePlayer1 = new Score(game, font, Color.Blue); scorePlayer1.Position = new Vector2(10, 10); Components.Add(scorePlayer1); scorePlayer2 = new Score(game, font, Color.Red); scorePlayer2.Position = new Vector2( Game.Window.ClientBounds.Width - 200, 10); Components.Add(scorePlayer2); rumblePad = new SimpleRumblePad(game); Components.Add(rumblePad); powerSource = new PowerSource(game, ref actionTexture); powerSource.Initialize(); Components.Add(powerSource); }