Exemple #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs
        /// to before starting to run. This is where it can query for
        /// any required services and load any non-graphic related content.
        /// Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Texture2D motherShipBombsTexture = this.Content.Load <Texture2D>
                                                   ("motherShipBombs");
            Texture2D alienBombsTexture = this.Content.Load <Texture2D>("laser2");
            Texture2D bonusImage        = this.Content.Load <Texture2D>("bonus1");

            playerLaser = new LaserFactory(this);
            alienBomb   = new BombFactory(this, alienBombsTexture, 1, 3);
            shipBomb    = new BombFactory(this, motherShipBombsTexture, 2, 3);
            bonusBomb   = new BombFactory(this, bonusImage, -1, 2);
            player      = new PlayerSprite(this, playerLaser);
            bonus       = new Bonus(this, bonusBomb);
            aliens      = new AlienSquad(this, alienBomb, playerLaser);
            score       = new ScoreSprite(this, playerLaser, alienBomb, shipBomb, bonusBomb);
            ship        = new MotherShipSprite(this, shipBomb, playerLaser);

            Components.Add(bonus);
            Components.Add(player);
            Components.Add(aliens);
            Components.Add(playerLaser);
            Components.Add(alienBomb);
            Components.Add(score);
            Components.Add(ship);
            Components.Add(shipBomb);
            Components.Add(bonusBomb);

            playerLaser.AddOpponent(aliens);
            playerLaser.AddOpponent(ship);
            alienBomb.AddOpponent(player);
            shipBomb.AddOpponent(player);
            bonusBomb.AddOpponent(player);

            ScoreSprite.GameOver += onGameOver;
            AlienSquad.GameOver  += onGameOver;
            AlienSquad.NewWave   += onNewWave;

            base.Initialize();
        }
Exemple #2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs
        /// to before starting to run. This is where it can query for
        /// any required services and load any non-graphic related content.
        /// Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Texture2D motherShipBombsTexture = this.Content.Load<Texture2D>
                                                ("motherShipBombs");
            Texture2D alienBombsTexture = this.Content.Load<Texture2D>("laser2");
            Texture2D bonusImage = this.Content.Load<Texture2D>("bonus1");

            playerLaser = new LaserFactory(this);
            alienBomb = new BombFactory(this, alienBombsTexture, 1, 3);
            shipBomb = new BombFactory(this, motherShipBombsTexture, 2, 3);
            bonusBomb = new BombFactory(this, bonusImage, -1, 2);
            player = new PlayerSprite(this, playerLaser);
            bonus = new Bonus(this, bonusBomb);
            aliens = new AlienSquad(this, alienBomb, playerLaser);
            score = new ScoreSprite(this, playerLaser, alienBomb, shipBomb, bonusBomb);
            ship = new MotherShipSprite(this, shipBomb, playerLaser);

            Components.Add(bonus);
            Components.Add(player);
            Components.Add(aliens);
            Components.Add(playerLaser);
            Components.Add(alienBomb);
            Components.Add(score);
            Components.Add(ship);
            Components.Add(shipBomb);
            Components.Add(bonusBomb);

            playerLaser.AddOpponent(aliens);
            playerLaser.AddOpponent(ship);
            alienBomb.AddOpponent(player);
            shipBomb.AddOpponent(player);
            bonusBomb.AddOpponent(player);

            ScoreSprite.GameOver += onGameOver;
            AlienSquad.GameOver += onGameOver;
            AlienSquad.NewWave += onNewWave;

            base.Initialize();
        }