/// <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> /// 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(); }
/// <summary> /// constructor for the alienSquad which are rows of aliens /// </summary> /// <param name="game"></param> public AlienSquad(Game1 game, int numAliens, BombFactory bombFactory) : base(game) { this.game = game; this.numAlien = numAliens; squads = new AlienSprite[numAlien, 12]; this.bombFactory = bombFactory; }
/// <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; }
public Bomb getActivatedBomb() { bomb = (Bomb)GhostManager.find(GameObject.GameObjectName.Bomb); GhostManager.remove(bomb); BombFactory bombF = FactoryManager.getBombFactry(); bombF.activate(bomb); return(bomb); }
/// <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> /// 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; }
public void loadBombs() { BombFactory bombFactory = FactoryManager.getBombFactry(); Bomb bombRoot = bombFactory.createBomb(Bomb.BombType.BombRoot, GameObject.GameObjectName.BombRoot); bombFactory.setParent(bombRoot); Bomb ZigZag = null; ZigZag = bombFactory.createBomb(Bomb.BombType.ZigZag, GameObject.GameObjectName.Bomb, 0, 996, 1024); ActivateBombSprite abs = new ActivateBombSprite(ZigZag); TimerManager.sortedAdd(TimerEvent.TimerEventName.ActivateGameEnd, abs, 1); Bomb FlippingBomb = null; FlippingBomb = bombFactory.createBomb(Bomb.BombType.Flipping, GameObject.GameObjectName.Bomb, 1, 996, 1024); ActivateBombSprite abs2 = new ActivateBombSprite(FlippingBomb); TimerManager.sortedAdd(TimerEvent.TimerEventName.ActivateGameEnd, abs2, 3); Bomb plungerBomb = null; plungerBomb = bombFactory.createBomb(Bomb.BombType.Plunger, GameObject.GameObjectName.Bomb, 2, 996, 1024); ActivateBombSprite abs3 = new ActivateBombSprite(plungerBomb); TimerManager.sortedAdd(TimerEvent.TimerEventName.ActivateGameEnd, abs3, 5); Bomb ZigZag1 = null; ZigZag1 = bombFactory.createBomb(Bomb.BombType.ZigZag, GameObject.GameObjectName.Bomb, 0, 996, 1024); ActivateBombSprite abs4 = new ActivateBombSprite(ZigZag1); TimerManager.sortedAdd(TimerEvent.TimerEventName.ActivateGameEnd, abs4, 6); Bomb FlippingBomb1 = null; FlippingBomb1 = bombFactory.createBomb(Bomb.BombType.Flipping, GameObject.GameObjectName.Bomb, 1, 996, 1024); ActivateBombSprite abs5 = new ActivateBombSprite(FlippingBomb1); TimerManager.sortedAdd(TimerEvent.TimerEventName.ActivateGameEnd, abs5, 7); Bomb plungerBomb1 = null; plungerBomb1 = bombFactory.createBomb(Bomb.BombType.Plunger, GameObject.GameObjectName.Bomb, 2, 996, 1024); ActivateBombSprite abs6 = new ActivateBombSprite(plungerBomb1); TimerManager.sortedAdd(TimerEvent.TimerEventName.ActivateGameEnd, abs6, 8); }
private FactoryManager() { SpriteBatch alienBatch = SpriteBatchManager.add(SpriteBatch.SpriteBatchName.Aliens); PCSTree alienPcsTree = new PCSTree(); this.alienFactory = new AlienFactory(alienPcsTree, alienBatch); SpriteBatch bombBatch = SpriteBatchManager.add(SpriteBatch.SpriteBatchName.Bombs); PCSTree bombPcsTree = new PCSTree(); this.bombFactory = new BombFactory(bombPcsTree, bombBatch); SpriteBatch missileBatch = SpriteBatchManager.add(SpriteBatch.SpriteBatchName.Missiles); PCSTree missilePcsTree = new PCSTree(); this.missileFactory = new MissileFactory(missilePcsTree, missileBatch); SpriteBatch shieldBatch = SpriteBatchManager.add(SpriteBatch.SpriteBatchName.Shields); PCSTree shieldPcsTree = new PCSTree(); this.shieldFactory = new ShieldFactory(shieldPcsTree, shieldBatch); SpriteBatch shipBatch = SpriteBatchManager.add(SpriteBatch.SpriteBatchName.Ships); PCSTree shipPcsTree = new PCSTree(); this.shipFactory = new ShipFactory(shipPcsTree, shipBatch); SpriteBatch wallBatch = SpriteBatchManager.add(SpriteBatch.SpriteBatchName.Walls); PCSTree wallPcsTree = new PCSTree(); this.wallFactory = new WallFactory(wallPcsTree, wallBatch); SpriteBatch ufoBatch = SpriteBatchManager.add(SpriteBatch.SpriteBatchName.UFOs); PCSTree ufoPcsTree = new PCSTree(); this.ufoFactory = new UFOFactory(ufoPcsTree, ufoBatch); sndEngine = new IrrKlang.ISoundEngine(); }
/// <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> /// Creates a bonus with a specified bomb. /// </summary> /// <param name="game">The game</param> /// <param name="bomb">Its bomb</param> public Bonus(Game1 game, BombFactory bomb) : base(game) { this.game = game; this.bomb = bomb; }
protected virtual void PlayerTwoInit(GameManager pGameManager) { float levelSpeed = 0.75f / pGameManager.pActivePlayer.level; pGameManager.poPlayer2.pGrid = InvaderGridManager.GenerateGrid(pGameManager.pActivePlayer.level); //Debug.WriteLine("Generated Grid ({0}) for P2", pGameManager.poPlayer2.pGrid.GetHashCode()); pGameManager.poPlayer2.pShieldZone = ShieldBuilder.CreateShieldZone(175, 300, 150, 4); //--------------------------------------------------------------------------------------------------------- // Create GameSpace and Wall Objects //--------------------------------------------------------------------------------------------------------- WallManager pWallMan = new WallManager(); //Debug.WriteLine("WallLeft Consts x: {0}, y:{1}, width:{2}, height:{3}", Constants.leftWallXPos, Constants.leftWallYPos, Constants.leftWallWidth, Constants.leftWallHeight); //Debug.WriteLine("WallRight Consts x: {0}, y:{1}, width:{2}, height:{3}", Constants.rightWallXPos, Constants.rightWallYPos, Constants.rightWallWidth, Constants.rightWallHeight); //Debug.WriteLine("Ceiling Consts x: {0}, y:{1}, width:{2}, height:{3}", Constants.ceilingXPos, Constants.ceilingYPos, Constants.ceilingWidth, Constants.ceilingHeight); //Debug.WriteLine("Floor Consts x: {0}, y:{1}, width:{2}, height:{3}", Constants.floorXPos, Constants.floorYPos, Constants.floorWidth, Constants.floorHeight); //--------------------------------------------------------------------------------------------------------- // Set up Sprite Animations //--------------------------------------------------------------------------------------------------------- // Set up animations for the 3 basic Invaders AnimationSprite pSmInvaderAnim = new AnimationSprite(Sprite.Name.SmallInvader); pSmInvaderAnim.Attach(Image.Name.SmallInvader1); pSmInvaderAnim.Attach(Image.Name.SmallInvader2); AnimationSprite pMedInvaderAnim = new AnimationSprite(Sprite.Name.MediumInvader); pMedInvaderAnim.Attach(Image.Name.MediumInvader1); pMedInvaderAnim.Attach(Image.Name.MediumInvader2); AnimationSprite pLgInvaderAnim = new AnimationSprite(Sprite.Name.LargeInvader); pLgInvaderAnim.Attach(Image.Name.LargeInvader1); pLgInvaderAnim.Attach(Image.Name.LargeInvader2); // Add the Invader animations as timed events to the TimerManager TimerManager.Add(TimeEvent.Name.SmInvaderMarchAnimation, pSmInvaderAnim, levelSpeed); TimerManager.Add(TimeEvent.Name.MedInvaderMarchAnimation, pMedInvaderAnim, levelSpeed); TimerManager.Add(TimeEvent.Name.LgInvaderMarchAnimation, pLgInvaderAnim, levelSpeed); // Set up bomb animations AnimationSprite pBombZigZagAnim = new AnimationSprite(Sprite.Name.BombZigZag); pBombZigZagAnim.Attach(Image.Name.BombZigZag1); pBombZigZagAnim.Attach(Image.Name.BombZigZag2); pBombZigZagAnim.Attach(Image.Name.BombZigZag3); pBombZigZagAnim.Attach(Image.Name.BombZigZag4); AnimationSprite pBombDaggerAnim = new AnimationSprite(Sprite.Name.BombDagger); pBombDaggerAnim.Attach(Image.Name.BombDagger1); pBombDaggerAnim.Attach(Image.Name.BombDagger2); pBombDaggerAnim.Attach(Image.Name.BombDagger3); pBombDaggerAnim.Attach(Image.Name.BombDagger4); AnimationSprite pBombRollingAnim = new AnimationSprite(Sprite.Name.BombRolling); pBombRollingAnim.Attach(Image.Name.BombRolling1); pBombRollingAnim.Attach(Image.Name.BombRolling2); // Add the bomb animations as timed events to the TimerManager TimerManager.Add(TimeEvent.Name.BombAnimation, pBombZigZagAnim, 0.25f); TimerManager.Add(TimeEvent.Name.BombAnimation, pBombDaggerAnim, 0.25f); TimerManager.Add(TimeEvent.Name.BombAnimation, pBombRollingAnim, 0.25f); //--------------------------------------------------------------------------------------------------------- // Set up TimedSoundEffects //--------------------------------------------------------------------------------------------------------- TimedSoundEffects pGridMarchingSounds = new TimedSoundEffects(); pGridMarchingSounds.Attach(Sound.Name.InvaderMarch4); pGridMarchingSounds.Attach(Sound.Name.InvaderMarch3); pGridMarchingSounds.Attach(Sound.Name.InvaderMarch2); pGridMarchingSounds.Attach(Sound.Name.InvaderMarch1); TimerManager.Add(TimeEvent.Name.GridMarchSoundEffects, pGridMarchingSounds, levelSpeed); //--------------------------------------------------------------------------------------------------------- // Setting up the collisions for the player ship and missile //--------------------------------------------------------------------------------------------------------- Ship pShip = ShipManager.ActivateShip(); Missile pMissile = ShipManager.GetMissile(); //--------------------------------------------------------------------------------------------------------- // Add Collision Pairs and their Observers //--------------------------------------------------------------------------------------------------------- // Applies to both players // ship vs left wall ColPair pShip_WallLeftColPair = ColPairManager.Add(ColPair.Name.Ship_WallLeft, pShip, pWallMan.GetWallLeft()); Debug.Assert(pShip_WallLeftColPair != null); pShip_WallLeftColPair.Attach(new Ship_WallLeftObserver()); // ship vs Right wall ColPair pShip_WallRightColPair = ColPairManager.Add(ColPair.Name.Ship_WallRight, pShip, pWallMan.GetWallRight()); Debug.Assert(pShip_WallRightColPair != null); pShip_WallRightColPair.Attach(new Ship_WallRightObserver()); // Missile vs Ceiling ColPair pMissile_CeilingColPair = ColPairManager.Add(ColPair.Name.Missile_Ceiling, pMissile, pWallMan.GetCeiling()); Debug.Assert(pMissile_CeilingColPair != null); pMissile_CeilingColPair.Attach(new ShipMissileReadyObserver()); pMissile_CeilingColPair.Attach(new ShipRemoveMissileObserver()); //--------------------------------------------------------------------------------------------------------- // Set up Random UFO Spawns //--------------------------------------------------------------------------------------------------------- RandomlySpawnUFO pRandomUfoEvent = new RandomlySpawnUFO(30.0f, pMissile, pWallMan); TimerManager.Add(TimeEvent.Name.RandomlySpawnUFO, pRandomUfoEvent, 10.0f); //--------------------------------------------------------------------------------------------------------- // Create Alien Grid and random bomb drops //--------------------------------------------------------------------------------------------------------- BombFactory pBombFactory = new BombFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pGameManager.poPlayer2.pGrid, pWallMan); RandomlySpawnBomb pRandomBombEvent = new RandomlySpawnBomb(2.0f, pBombFactory); TimerManager.Add(TimeEvent.Name.RandomBombSpawn, pRandomBombEvent, 2.0f); // Applies to players seperately // Set up timing for Grid and UFO motion TimeBasedMover pGridMover = new TimeBasedMover(pGameManager.poPlayer2.pGrid); TimerManager.Add(TimeEvent.Name.TimedGridMover, pGridMover, levelSpeed); //--------------------------------------------------------------------------------------------------------- // Create the Shields //--------------------------------------------------------------------------------------------------------- // Applies to each player seperately // grid vs leftwall ColPair pGrid_WallLeftColPair = ColPairManager.Add(ColPair.Name.Grid_WallLeft, pGameManager.poPlayer2.pGrid, pWallMan.GetWallLeft()); Debug.Assert(pGrid_WallLeftColPair != null); pGrid_WallLeftColPair.Attach(new Grid_WallLeftObserver()); // Grid vs rightwall ColPair pGrid_WallRightcolPair = ColPairManager.Add(ColPair.Name.Grid_WallRight, pGameManager.poPlayer2.pGrid, pWallMan.GetWallRight()); Debug.Assert(pGrid_WallRightcolPair != null); pGrid_WallRightcolPair.Attach(new Grid_WallRightObserver()); // Grid vs ship ColPair pShip_GridColPair = ColPairManager.Add(ColPair.Name.Ship_Grid, pShip, pGameManager.poPlayer2.pGrid); Debug.Assert(pShip_GridColPair != null); pShip_GridColPair.Attach(new RemoveShipObserver()); // Grid vs Missile ColPair pMissile_GridColPair = ColPairManager.Add(ColPair.Name.Missile_Grid, pMissile, pGameManager.poPlayer2.pGrid); Debug.Assert(pMissile_GridColPair != null); pMissile_GridColPair.Attach(new ShipRemoveMissileObserver()); pMissile_GridColPair.Attach(new ShipMissileReadyObserver()); pMissile_GridColPair.Attach(new RemoveInvaderObserver()); pMissile_GridColPair.Attach(new AwardPointsObserver()); // Grid vs Shields ColPair pGrid_ShieldZoneColPair = ColPairManager.Add(ColPair.Name.Grid_ShieldZone, pGameManager.poPlayer2.pGrid, pGameManager.poPlayer2.pShieldZone); pGrid_ShieldZoneColPair.Attach(new RemoveShieldBrickObserver()); // Missile vs Shields ColPair pMissile_ShieldZoneColPair = ColPairManager.Add(ColPair.Name.Missile_ShieldZone, pMissile, pGameManager.poPlayer2.pShieldZone); pMissile_ShieldZoneColPair.Attach(new ShipMissileReadyObserver()); pMissile_ShieldZoneColPair.Attach(new ShipRemoveMissileObserver()); pMissile_ShieldZoneColPair.Attach(new RemoveShieldBrickObserver()); // STORE Current State of managers into manager mementos pGameManager.poPlayer2.ArchiveManagerStates(pGameManager.pGame.GetTime()); }
/// <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 bombFactory /// </summary> /// <param name="bombFactory">Class that holds all the bombs</param> public void addBombFactory(BombFactory bombFactory) { this.bombFactory = bombFactory; }
public RandomlySpawnBomb(float timeRange, BombFactory pBombFactory) : base(timeRange) { this.pBombFactory = pBombFactory; Debug.Assert(this.pBombFactory != null); }