Beispiel #1
0
 /// <summary>
 /// AlienSquad's constructor.
 /// </summary>
 /// <param name="game">The game it is attached to.</param>
 /// <param name="bomb">The bombs dropped by the aliens.</param>
 public AlienSquad(Game1 game, BombFactory bomb, LaserFactory laser)
     : base(game)
 {
     this.game          = game;
     this.bomb          = bomb;
     laser.AlienKilled += onAlienHit;
 }
Beispiel #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()
        {
            // TODO: Add your initialization logic here
            player = new PlayerSprite(this);
            bombFactory = new BombFactory(this);
            laserFactory = new LaserFactory(this);
            squad = new AlienSquad(this, numAlians, bombFactory);
            score = new ScoreSprite(this);

            bombFactory.addPlayer(player);
            laserFactory.addSquad(squad);
            player.addLaserFactory(laserFactory);
            squad.addLaserFactory(laserFactory);
            score.addFactory(laserFactory);
            score.addPlayer(player);
            score.addSquad(squad);
            squad.addScoreSprite(score);
            laserFactory.addScoreScrprite(score);
            bombFactory.addScoreScrprite(score);

            Components.Add(laserFactory);
            Components.Add(bombFactory);
            Components.Add(player);
            Components.Add(squad);
            Components.Add(score);
            base.Initialize();
        }
Beispiel #3
0
 /// <summary>
 /// AlienSquad's constructor.
 /// </summary>
 /// <param name="game">The game it is attached to.</param>
 /// <param name="bomb">The bombs dropped by the aliens.</param>
 public AlienSquad(Game1 game, BombFactory bomb, LaserFactory laser)
     : base(game)
 {
     this.game = game;
     this.bomb = bomb;
     laser.AlienKilled += onAlienHit;
 }
 /// <summary>
 /// AlienSprite's constructor. Creates an alien with an image,
 /// starting at the specified position.
 /// </summary>
 /// <param name="game">The game it is attached to.</param>
 /// <param name="imageAlien">The image representing the alien.</param>
 /// <param name="positionX">The X position of the alien.</param>
 /// <param name="positionY">The Y position of the alien.</param>
 public MotherShipSprite(Game1 game, BombFactory bomb, LaserFactory laser)
     : base(game)
 {
     this.game            = game;
     this.bomb            = bomb;
     this.Point           = 100;
     laser.MotherShipHit += onShipHit;
     AlienSquad.NewWave  += onNewWave;
 }
 /// <summary>
 /// AlienSprite's constructor. Creates an alien with an image,
 /// starting at the specified position.
 /// </summary>
 /// <param name="game">The game it is attached to.</param>
 /// <param name="imageAlien">The image representing the alien.</param>
 /// <param name="positionX">The X position of the alien.</param>
 /// <param name="positionY">The Y position of the alien.</param>
 public MotherShipSprite(Game1 game,BombFactory bomb, LaserFactory laser)
     : base(game)
 {
     this.game = game;
     this.bomb = bomb;
     this.Point = 100;
     laser.MotherShipHit += onShipHit;
     AlienSquad.NewWave += onNewWave;
 }
Beispiel #6
0
 /// <summary>
 /// ScoreSprite's constructor.
 /// </summary>
 /// <param name="game">The game</param>
 public ScoreSprite(Game1 game, LaserFactory laser, BombFactory bomb,
                    BombFactory motherShipBomb, BombFactory bonusBomb)
     : base(game)
 {
     this.game                 = game;
     bomb.PlayerHit           += onPlayerHit;
     motherShipBomb.PlayerHit += onPlayerHit;
     bonusBomb.PlayerHit      += onPlayerHit;
     laser.AlienKilled        += onAlienHit;
     laser.MotherShipHit      += onAlienHit;
     AlienSquad.NewWave       += onNewWave;
 }
Beispiel #7
0
 /// <summary>
 /// ScoreSprite's constructor.
 /// </summary>
 /// <param name="game">The game</param>
 public ScoreSprite(Game1 game, LaserFactory laser, BombFactory bomb,
                    BombFactory motherShipBomb, BombFactory bonusBomb)
     : base(game)
 {
     this.game = game;
     bomb.PlayerHit += onPlayerHit;
     motherShipBomb.PlayerHit += onPlayerHit;
     bonusBomb.PlayerHit += onPlayerHit;
     laser.AlienKilled += onAlienHit;
     laser.MotherShipHit += onAlienHit;
     AlienSquad.NewWave += onNewWave;
 }
Beispiel #8
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();
        }
 public void addLaserFactory(LaserFactory pewpew)
 {
     this.pewpew = pewpew;
 }
Beispiel #10
0
 /// <summary>
 /// PlayerSprite's constructor.
 /// </summary>
 /// <param name="game">The game it is attached to.</param>
 /// <param name="laser">The player's laser.</param>
 public PlayerSprite(Game1 game, LaserFactory laser)
     : base(game)
 {
     this.game  = game;
     this.laser = laser;
 }
Beispiel #11
0
 /// <summary>
 /// PlayerSprite's constructor.
 /// </summary>
 /// <param name="game">The game it is attached to.</param>
 /// <param name="laser">The player's laser.</param>
 public PlayerSprite(Game1 game, LaserFactory laser)
     : base(game)
 {
     this.game = game;
     this.laser = laser;
 }
Beispiel #12
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();
        }
 /// <summary>
 /// adds a laserFactory
 /// </summary>
 /// <param name="laser"></param>
 public void addFactory(LaserFactory laser)
 {
     this.laser = laser;
 }
 /// <summary>
 /// Adds a laser factory
 /// </summary>
 /// <param name="factory">Class that holds all the lasers</param>
 public void addLaserFactory(LaserFactory factory)
 {
     this.laserFactory = factory;
 }