public WallManager() { WallFactory gameSpaceFactory = new WallFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes); this.pGameSpace = (GameSpace)gameSpaceFactory.Create(GameObject.Type.GameSpace, 0, 0, 0, 0); Debug.Assert(this.pGameSpace != null); WallFactory wallFactory = new WallFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, this.pGameSpace); this.pWallLeft = (WallLeft)wallFactory.Create(GameObject.Type.WallLeft, Constants.leftWallXPos, Constants.leftWallYPos, Constants.leftWallWidth, Constants.leftWallHeight); Debug.Assert(this.pWallLeft != null); this.pWallRight = (WallRight)wallFactory.Create(GameObject.Type.WallRight, Constants.rightWallXPos, Constants.rightWallYPos, Constants.rightWallWidth, Constants.rightWallHeight); Debug.Assert(this.pWallRight != null); this.pCeiling = (Ceiling)wallFactory.Create(GameObject.Type.Ceiling, Constants.ceilingXPos, Constants.ceilingYPos, Constants.ceilingWidth, Constants.ceilingHeight); Debug.Assert(this.pCeiling != null); this.pFloor = (Floor)wallFactory.Create(GameObject.Type.Floor, Constants.floorXPos, Constants.floorYPos, Constants.floorWidth, Constants.floorHeight); Debug.Assert(this.pFloor != null); }
public static void initialize(BatchGroup.BatchType type = BatchGroup.BatchType.Collisions) { if (wfInstance == null) { wfInstance = new WallFactory(type); } }
public void loadWalls() { WallFactory wallFactory = FactoryManager.getWallFactry(); Wall wallRoot = wallFactory.createWall(Wall.WallType.WallRoot, GameObject.GameObjectName.WallRoot); wallFactory.setParent(wallRoot); // 0, 448, 900, 850, 30 //wallFactory.createWall(Wall.WallType.WallTop, GameObject.GameObjectName.Wall, 0, 448, 900, 850, 10); wallFactory.createWall(Wall.WallType.WallTop, GameObject.GameObjectName.WallTop, 0, 446, 950, 892, 1); wallFactory.createWall(Wall.WallType.WallDown, GameObject.GameObjectName.WallDown, 0, 446, 1, 1000, 100); // wallFactory.createWall(Wall.WallType.WallRight, GameObject.GameObjectName.WallRight, 2, 892, 500, 1, 1020); wallFactory.createWall(Wall.WallType.WallRight, GameObject.GameObjectName.WallRight, 0, 860, 500, 1, 1024); wallFactory.createWall(Wall.WallType.WallLeft, GameObject.GameObjectName.WallLeft, 0, 20, 510, 1, 1024); // wallFactory.createWall(Wall.WallType.WallRight, GameObject.GameObjectName.WallRight, 0, 625, 500, 50, 900); // wallFactory.createWall(Wall.WallType.WallLeft, GameObject.GameObjectName.WallLeft, 0, 100, 500, 50, 900); }
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(); }
public override void loadContent(Scene pScene) { ManagerFactory managerFactory = new ManagerFactory(); //--------------------------------------------------------------------------------------------------------- // Create SpriteBatch //--------------------------------------------------------------------------------------------------------- SpriteBatch pSB_Box = SpriteBatchMan.Add(SpriteBatch.Name.Boxes); SpriteBatch pSB_ShieldBoxes = SpriteBatchMan.Add(SpriteBatch.Name.ShieldBoxes); SpriteBatchMan.Add(SpriteBatch.Name.Aliens); SpriteBatchMan.Add(SpriteBatch.Name.Walls); SpriteBatchMan.Add(SpriteBatch.Name.Bumps); SpriteBatch pSB_Ship = SpriteBatchMan.Add(SpriteBatch.Name.Ships); SpriteBatch pSB_Missile = SpriteBatchMan.Add(SpriteBatch.Name.Missiles); SpriteBatch pSB_Shield = SpriteBatchMan.Add(SpriteBatch.Name.Shields); SpriteBatch pSB_Bomb = SpriteBatchMan.Add(SpriteBatch.Name.Bombs); SpriteBatchMan.Add(SpriteBatch.Name.PlainTexts); SpriteBatch pSB_Life = SpriteBatchMan.Add(SpriteBatch.Name.Lifes); SpriteBatch pSB_Explosion = SpriteBatchMan.Add(SpriteBatch.Name.Explosions); SpriteBatch pSB_UFO = SpriteBatchMan.Add(SpriteBatch.Name.UFO); //--------------------------------------------------------------------------------------------------------- // Set Input //--------------------------------------------------------------------------------------------------------- InputSubject pInputSubject; pInputSubject = InputMan.GetArrowLeftSubject(); pInputSubject.attach(new MoveLeftObserver()); pInputSubject = InputMan.GetArrowRightSubject(); pInputSubject.attach(new MoveRightObserver()); pInputSubject = InputMan.GetSpaceSubject(); pInputSubject.attach(new ShootObserver()); pInputSubject = InputMan.GetTSubject(); pInputSubject.attach(new ToggleBoxObserver()); //--------------------------------------------------------------------------------------------------------- // Create Ship //--------------------------------------------------------------------------------------------------------- // create ship life group ShipLifeGroup pShipLifeGroup = new ShipLifeGroup(GameObject.Name.ShipLifeGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pShipLifeGroup.activateGameSprite(pSB_Life); pShipLifeGroup.activateCollisionSprite(pSB_Box); GameObjectMan.Attach(pShipLifeGroup); ShipGroup pShipGroup = new ShipGroup(GameObject.Name.ShipGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pShipGroup.activateGameSprite(pSB_Ship); pShipGroup.activateCollisionSprite(pSB_Box); GameObjectMan.Attach(pShipGroup); ShipMan.CreateShipLifes(); //--------------------------------------------------------------------------------------------------------- // Create UFO //--------------------------------------------------------------------------------------------------------- UFORoot pUFORoot = new UFORoot(GameObject.Name.UFORoot, GameSprite.Name.NullObject, 0.0f, 0.0f); UFORoot pUFOGroup = new UFORoot(GameObject.Name.UFORoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pUFORoot.activateGameSprite(pSB_UFO); pUFORoot.activateCollisionSprite(pSB_Box); pUFOGroup.add(pUFORoot); GameObjectMan.Attach(pUFOGroup); //managerFactory.create(Manager.Name.UFOMan); //--------------------------------------------------------------------------------------------------------- // Create Missile //--------------------------------------------------------------------------------------------------------- MissileGroup pMissileGroup = new MissileGroup(GameObject.Name.MissileGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pMissileGroup.activateGameSprite(pSB_Missile); pMissileGroup.activateCollisionSprite(pSB_Box); GameObjectMan.Attach(pMissileGroup); //--------------------------------------------------------------------------------------------------------- // Create Bombs //--------------------------------------------------------------------------------------------------------- BombRoot pBombRoot = new BombRoot(GameObject.Name.BombGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pBombRoot.activateGameSprite(pSB_Bomb); pBombRoot.activateCollisionSprite(pSB_Box); GameObjectMan.Attach(pBombRoot); //managerFactory.create(Manager.Name.BombMan); //--------------------------------------------------------------------------------------------------------- // Create walls //--------------------------------------------------------------------------------------------------------- WallFactory wallFactory = new WallFactory(SpriteBatch.Name.Walls, SpriteBatch.Name.Boxes); GameObject pWallGroup = wallFactory.create(GameObject.Name.WallGroup, WallCategory.Type.WallGroup); pWallGroup.add(wallFactory.create(GameObject.Name.WallLeft, WallCategory.Type.Left, 5, 511, 10, 912)); pWallGroup.add(wallFactory.create(GameObject.Name.WallRight, WallCategory.Type.Right, 891, 511, 10, 912)); pWallGroup.add(wallFactory.create(GameObject.Name.WallTop, WallCategory.Type.Top, 448, 993, 896, 50)); pWallGroup.add(wallFactory.create(GameObject.Name.WallBottom, WallCategory.Type.Bottom, 448, 30, 896, 50)); GameObjectMan.Attach(pWallGroup); //--------------------------------------------------------------------------------------------------------- // Create bumps //--------------------------------------------------------------------------------------------------------- BumpFactory bumpFactory = new BumpFactory(SpriteBatch.Name.Bumps, SpriteBatch.Name.Boxes); GameObject pBumpGroup = bumpFactory.create(GameObject.Name.BumpGroup, BumpCategory.Type.BumpGroup); pBumpGroup.add(bumpFactory.create(GameObject.Name.BumpLeft, BumpCategory.Type.Left, 10, 90, 25, 60)); pBumpGroup.add(bumpFactory.create(GameObject.Name.BumpRight, BumpCategory.Type.Right, 886, 90, 25, 60)); GameObjectMan.Attach(pBumpGroup); //--------------------------------------------------------------------------------------------------------- // Create Aliens //--------------------------------------------------------------------------------------------------------- //managerFactory.create(Manager.Name.AlienMan); AlienFactory alienFactory = new AlienFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes); // create alien groups AlienGroup pAlienGroup = (AlienGroup)alienFactory.create(GameObject.Name.AlienGroup, AlienCategory.Type.Group); pAlienGroup.nextLevel(); AlienGroup pAlienRoot = new AlienGroup(GameObject.Name.AlienGroup, GameSprite.Name.NullObject, 0.0f, 0.0f);; pAlienRoot.add(pAlienGroup); GameObjectMan.Attach(pAlienRoot); //--------------------------------------------------------------------------------------------------------- // create Shield //--------------------------------------------------------------------------------------------------------- ShieldFactory SF = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.ShieldBoxes); ShieldRoot pShieldGroup = (ShieldRoot)SF.Create(ShieldCategory.Type.Root, GameObject.Name.ShieldRoot, 0.0f, 0.0f); pShieldGroup.storeShield(); ShieldRoot pShieldRoot = new ShieldRoot(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pShieldRoot.add(pShieldGroup); GameObjectMan.Attach(pShieldRoot); //--------------------------------------------------------------------------------------------------------- // Create explosion group //--------------------------------------------------------------------------------------------------------- ExplosionGroup pExplosionGroup = new ExplosionGroup(GameObject.Name.ExplosionGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pExplosionGroup.activateGameSprite(pSB_Explosion); pExplosionGroup.activateCollisionSprite(pSB_Box); GameObjectMan.Attach(pExplosionGroup); //--------------------------------------------------------------------------------------------------------- // Attach sprites to Sprite Batch //--------------------------------------------------------------------------------------------------------- //pSB_Boxes.attach(BoxSprite.Name.Box1); // Create animation sprites AnimationSprite pAnimOctopus = new AnimationSprite(GameSprite.Name.Octopus); pAnimOctopus.attach(Image.Name.OctopusMovement); pAnimOctopus.attach(Image.Name.Octopus); pAnimOctopus.attach("fastinvader1.wav"); pAnimOctopus.attach("fastinvader2.wav"); pAnimOctopus.attach("fastinvader3.wav"); pAnimOctopus.attach("fastinvader4.wav"); TimerMan.Add(TimeEvent.Name.OctopusAnimation, pAnimOctopus, 0.75f); AnimationSprite pAnimCrab = new AnimationSprite(GameSprite.Name.Crab); pAnimCrab.attach(Image.Name.CrabMovement); pAnimCrab.attach(Image.Name.Crab); pAnimCrab.attach("fastinvader1.wav"); pAnimCrab.attach("fastinvader2.wav"); pAnimCrab.attach("fastinvader3.wav"); pAnimCrab.attach("fastinvader4.wav"); TimerMan.Add(TimeEvent.Name.CrabAnimation, pAnimCrab, 0.75f); AnimationSprite pAminSquid = new AnimationSprite(GameSprite.Name.Squid); pAminSquid.attach(Image.Name.SquidMovement); pAminSquid.attach(Image.Name.Squid); pAminSquid.attach("fastinvader1.wav"); pAminSquid.attach("fastinvader2.wav"); pAminSquid.attach("fastinvader3.wav"); pAminSquid.attach("fastinvader4.wav"); TimerMan.Add(TimeEvent.Name.SquidAnimation, pAminSquid, 0.75f); // Create Movement sprite MovementSprite pMovementSprite = new MovementSprite(pAlienGroup); TimerMan.Add(TimeEvent.Name.MovementAnimation, pMovementSprite, 0.5f); // Create drop bomb sprite DropBomb pDropBomb = new DropBomb(pAlienGroup); TimerMan.Add(TimeEvent.Name.DropBombAnination, pDropBomb, 1.5f); // Create UFOEvent sprite UFOEvent pUFOEvent = new UFOEvent(); TimerMan.Add(TimeEvent.Name.MovementAnimation, pUFOEvent, UFOMan.getDeltaTime()); //--------------------------------------------------------------------------------------------------------- // Collision Pair //--------------------------------------------------------------------------------------------------------- CollisionPair pColPair = CollisionPairMan.Add(CollisionPair.Name.Alien_Missile, pMissileGroup, pAlienGroup); Debug.Assert(pColPair != null); pColPair.attach(new RemoveAlienObserver()); pColPair.attach(new PlaySoundObserver("invaderkilled.wav")); pColPair.attach(new AlienNumObserver(pAlienGroup, pShieldGroup)); pColPair.attach(new RemoveMissileObserver()); pColPair.attach(new ShipReadyObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Missile_Wall, pMissileGroup, pWallGroup); Debug.Assert(pColPair != null); pColPair.attach(new RemoveMissileObserver()); pColPair.attach(new ShipReadyObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Alien_Wall, pAlienGroup, pWallGroup); Debug.Assert(pColPair != null); pColPair.attach(new AlienGroupObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Ship_Bump, pBumpGroup, pShipGroup); Debug.Assert(pColPair != null); pColPair.attach(new ShipPositionObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Missile_Shield, pMissileGroup, pShieldRoot); Debug.Assert(pColPair != null); pColPair.attach(new RemoveShieldObserver(GameObject.Name.Missile)); pColPair.attach(new PlaySoundObserver("invaderkilled.wav")); pColPair.attach(new RemoveMissileObserver()); pColPair.attach(new ShipReadyObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Bomb_Shield, pBombRoot, pShieldRoot); Debug.Assert(pColPair != null); pColPair.attach(new RemoveShieldObserver(GameObject.Name.Bomb)); pColPair.attach(new PlaySoundObserver("invaderkilled.wav")); pColPair.attach(new RemoveBombObserver()); pColPair.attach(new AlienReadyObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Bomb_Wall, pBombRoot, pWallGroup); Debug.Assert(pColPair != null); pColPair.attach(new RemoveBombObserver()); pColPair.attach(new AlienReadyObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Bomb_Missile, pBombRoot, pMissileGroup); Debug.Assert(pColPair != null); pColPair.attach(new BombExplosionObsever()); pColPair.attach(new AlienReadyObserver()); pColPair.attach(new RemoveMissileObserver()); pColPair.attach(new ShipReadyObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Bomb_Ship, pShipGroup, pBombRoot); Debug.Assert(pColPair != null); pColPair.attach(new RemoveBombObserver()); pColPair.attach(new AlienReadyObserver()); pColPair.attach(new RemoveShipObserver()); pColPair.attach(new PlaySoundObserver("explosion.wav")); pColPair = CollisionPairMan.Add(CollisionPair.Name.UFO_Wall, pWallGroup, pUFORoot); Debug.Assert(pColPair != null); pColPair.attach(new RemoveUFOObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.UFO_Missile, pMissileGroup, pUFORoot); Debug.Assert(pColPair != null); pColPair.attach(new RemoveMissileObserver()); pColPair.attach(new ShipReadyObserver()); pColPair.attach(new UFOExplosionObserver()); pColPair.attach(new PlaySoundObserver("explosion.wav")); //--------------------------------------------------------------------------------------------------------- // Font //--------------------------------------------------------------------------------------------------------- FontMan.Add(Font.Name.Texts, SpriteBatch.Name.PlainTexts, "SCORE<1>", Glyph.Name.Consolas36pt, 20, 1000); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.PlainTexts, "HI-SCORE", Glyph.Name.Consolas36pt, 370, 1000); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.PlainTexts, "SCORE<2>", Glyph.Name.Consolas36pt, 700, 1000); FontMan.Add(Font.Name.ScoreOne, SpriteBatch.Name.PlainTexts, pScene.getScoreOne().ToString("D4"), Glyph.Name.Consolas36pt, 50, 960); FontMan.Add(Font.Name.HighestScore, SpriteBatch.Name.PlainTexts, pScene.getHighestScore().ToString("D4"), Glyph.Name.Consolas36pt, 400, 960); FontMan.Add(Font.Name.ScoreTwo, SpriteBatch.Name.PlainTexts, pScene.getScoreTwo().ToString("D4"), Glyph.Name.Consolas36pt, 730, 960); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.PlainTexts, "CREDIT", Glyph.Name.Consolas36pt, 700, 25); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.PlainTexts, "00", Glyph.Name.Consolas36pt, 830, 25); }
// strategy() public override void LoadContent() { pSpriteBatchMan = new SpriteBatchMan(1, 1); playLives = 3; numOfAliens = 55; //--------------------------------------------------------------------------------------------------------- // Manager initialization //--------------------------------------------------------------------------------------------------------- TimerMan.Create(3, 1); TextureMan.Create(2, 1); ImageMan.Create(5, 2); GameSpriteMan.Create(4, 2); BoxSpriteMan.Create(3, 1); ProxySpriteMan.Create(10, 1); if (GameObjectMan.pInstance != null) { GameObjectMan.Destroy(); } GameObjectMan.Create(3, 1); ColPairMan.Create(1, 1); GlyphMan.Create(3, 1); FontMan.Create(1, 1); //--------------------------------------------------------------------------------------------------------- // Sound Experiment //--------------------------------------------------------------------------------------------------------- // start up the engine // SpaceInvaders.GetInstance().sndEngine = new IrrKlang.ISoundEngine(); //--------------------------------------------------------------------------------------------------------- // Load the Textures //--------------------------------------------------------------------------------------------------------- TextureMan.Add(Texture.Name.Shields, "birds_N_shield.tga"); TextureMan.Add(Texture.Name.Aliens, "aliensNew.tga"); TextureMan.Add(Texture.Name.Consolas36pt, "Consolas36pt.tga"); FontMan.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas36pt); //--------------------------------------------------------------------------------------------------------- // Create Images //--------------------------------------------------------------------------------------------------------- ImageMan.Add(Image.Name.CrabUp, Texture.Name.Aliens, 322.5f, 27.0f, 150.0f, 111.0f); ImageMan.Add(Image.Name.CrabDown, Texture.Name.Aliens, 324.0f, 180.0f, 150.0f, 114.0f); ImageMan.Add(Image.Name.OctopusOut, Texture.Name.Aliens, 54f, 28.5f, 168f, 111f); ImageMan.Add(Image.Name.OctopusIn, Texture.Name.Aliens, 54f, 180f, 168f, 111f); ImageMan.Add(Image.Name.SquidOut, Texture.Name.Aliens, 612f, 25.5f, 117f, 117f); ImageMan.Add(Image.Name.SquidIn, Texture.Name.Aliens, 612f, 180f, 117f, 117f); ImageMan.Add(Image.Name.Missile, Texture.Name.Shields, 73, 53, 5, 4); ImageMan.Add(Image.Name.Ship, Texture.Name.Shields, 10, 93, 30, 18); ImageMan.Add(Image.Name.Wall, Texture.Name.Shields, 40, 185, 20, 10); ImageMan.Add(Image.Name.BombStraight, Texture.Name.Shields, 111, 101, 5, 49); ImageMan.Add(Image.Name.BombZigZag, Texture.Name.Shields, 132, 100, 20, 50); ImageMan.Add(Image.Name.BombCross, Texture.Name.Shields, 219, 103, 19, 47); ImageMan.Add(Image.Name.Brick, Texture.Name.Shields, 20, 210, 10, 5); ImageMan.Add(Image.Name.BrickLeft_Top0, Texture.Name.Shields, 15, 180, 10, 5); ImageMan.Add(Image.Name.BrickLeft_Top1, Texture.Name.Shields, 15, 185, 10, 5); ImageMan.Add(Image.Name.BrickLeft_Bottom, Texture.Name.Shields, 35, 215, 10, 5); ImageMan.Add(Image.Name.BrickRight_Top0, Texture.Name.Shields, 75, 180, 10, 5); ImageMan.Add(Image.Name.BrickRight_Top1, Texture.Name.Shields, 75, 185, 10, 5); ImageMan.Add(Image.Name.BrickRight_Bottom, Texture.Name.Shields, 55, 215, 10, 5); ImageMan.Add(Image.Name.UFO, Texture.Name.Aliens, 84, 505, 225, 96); ImageMan.Add(Image.Name.Splash, Texture.Name.Aliens, 573, 486, 183, 115); ImageMan.Add(Image.Name.TopSplash, Texture.Name.Aliens, 403, 487, 113, 113); ImageMan.Add(Image.Name.PlayerEnd, Texture.Name.Aliens, 558, 336, 222, 110); //--------------------------------------------------------------------------------------------------------- // Create Sprites //--------------------------------------------------------------------------------------------------------- GameSpriteMan.Add(GameSprite.Name.Crab, Image.Name.CrabUp, 500.0f, 300.0f, 18.0f, 18.0f); GameSpriteMan.Add(GameSprite.Name.Octopus, Image.Name.OctopusOut, 50, 200, 20, 20); GameSpriteMan.Add(GameSprite.Name.Squid, Image.Name.SquidOut, 300, 400, 16, 16); GameSpriteMan.Add(GameSprite.Name.Missile, Image.Name.Missile, 0, 0, 2, 10); pShip = GameSpriteMan.Add(GameSprite.Name.ShipImage, Image.Name.Ship, 40, 20, 30, 14); GameSpriteMan.Add(GameSprite.Name.Ship, Image.Name.Ship, 500, 100, 30, 14); GameSpriteMan.Add(GameSprite.Name.WallHorizontal, Image.Name.Wall, 448, 900, 850, 30); GameSpriteMan.Add(GameSprite.Name.WallVertical, Image.Name.Wall, 50, 448, 30, 950); GameSpriteMan.Add(GameSprite.Name.UFO, Image.Name.UFO, 50, 448, 20, 14); GameSpriteMan.Add(GameSprite.Name.BombZigZag, Image.Name.BombZigZag, 200, 200, 10, 20); GameSpriteMan.Add(GameSprite.Name.BombStraight, Image.Name.BombStraight, 100, 100, 5, 20); GameSpriteMan.Add(GameSprite.Name.BombDagger, Image.Name.BombCross, 100, 100, 10, 20); GameSpriteMan.Add(GameSprite.Name.Brick, Image.Name.Brick, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_LeftTop0, Image.Name.BrickLeft_Top0, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_LeftTop1, Image.Name.BrickLeft_Top1, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_LeftBottom, Image.Name.BrickLeft_Bottom, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_RightTop0, Image.Name.BrickRight_Top0, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_RightTop1, Image.Name.BrickRight_Top1, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_RightBottom, Image.Name.BrickRight_Bottom, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Splash, Image.Name.Splash, 0, 0, 18, 18); GameSpriteMan.Add(GameSprite.Name.TopSplash, Image.Name.TopSplash, 0, 0, 20, 14); GameSpriteMan.Add(GameSprite.Name.PlayerEnd, Image.Name.PlayerEnd, 0, 0, 40, 20); //--------------------------------------------------------------------------------------------------------- // Create BoxSprite //--------------------------------------------------------------------------------------------------------- BoxSpriteMan.Add(BoxSprite.Name.Box1, 550.0f, 500.0f, 50.0f, 150.0f, new Azul.Color(1.0f, 1.0f, 1.0f, 1.0f)); BoxSpriteMan.Add(BoxSprite.Name.Box2, 550.0f, 100.0f, 50.0f, 100.0f); //--------------------------------------------------------------------------------------------------------- // Create SpriteBatch //--------------------------------------------------------------------------------------------------------- SpriteBatch pSB_Box = pSpriteBatchMan.Add(SpriteBatch.Name.Boxes); SpriteBatch pSB_Aliens = pSpriteBatchMan.Add(SpriteBatch.Name.Aliens); SpriteBatch pSB_Texts = pSpriteBatchMan.Add(SpriteBatch.Name.Texts); SpriteBatch pSB_Shields = pSpriteBatchMan.Add(SpriteBatch.Name.Shields); SpriteBatch pSB_Walls = pSpriteBatchMan.Add(SpriteBatch.Name.Walls); SpriteBatch pSB_UFOs = pSpriteBatchMan.Add(SpriteBatch.Name.UFOs); SpriteBatch pSB_Bombs = pSpriteBatchMan.Add(SpriteBatch.Name.Bombs); pSB_Aliens.Attach(pShip); pSB_Walls.display = false; pSB_Box.display = false; //--------------------------------------------------------------------------------------------------------- //Font //--------------------------------------------------------------------------------------------------------- FontMan.Add(pSpriteBatchMan, Font.Name.Title, SpriteBatch.Name.Texts, "SCORE<1> HIGH-SCORE SCORE<2>", Glyph.Name.Consolas36pt, 200, 680); FontMan.Add(pSpriteBatchMan, Font.Name.ScoreOne, SpriteBatch.Name.Texts, "00", Glyph.Name.Consolas36pt, 240, 650); FontMan.Add(pSpriteBatchMan, Font.Name.HighestScore, SpriteBatch.Name.Texts, "00", Glyph.Name.Consolas36pt, 440, 650); FontMan.Add(pSpriteBatchMan, Font.Name.ScoreTwo, SpriteBatch.Name.Texts, "00", Glyph.Name.Consolas36pt, 650, 650); FontMan.Add(pSpriteBatchMan, Font.Name.PlayerLives, SpriteBatch.Name.Texts, "X" + playLives, Glyph.Name.Consolas36pt, 52, 20); //--------------------------------------------------------------------------------------------------------- // Input //--------------------------------------------------------------------------------------------------------- InputSubject pInputSubject; pInputSubject = InputMan.GetArrowRightSubject(); pInputSubject.Attach(new MoveRightObserver()); pInputSubject = InputMan.GetArrowLeftSubject(); pInputSubject.Attach(new MoveLeftObserver()); pInputSubject = InputMan.GetSpaceSubject(); pInputSubject.Attach(new ShootObserver()); Simulation.SetState(Simulation.State.Realtime); //--------------------------------------------------------------------------------------------------------- // Bomb //--------------------------------------------------------------------------------------------------------- BombRoot pBombRoot = new BombRoot(GameObject.Name.BombRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); //pBombRoot.ActivateCollisionSprite(pSB_Box); GameObjectMan.Attach(pBombRoot); //--------------------------------------------------------------------------------------------------------- // Walls //--------------------------------------------------------------------------------------------------------- WallGroup pWallGroup = new WallGroup(GameObject.Name.WallGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pWallGroup.ActivateGameSprite(pSB_Walls); //pWallGroup.ActivateCollisionSprite(pSB_Box); WallFactory WF = new WallFactory(pSpriteBatchMan, SpriteBatch.Name.Walls, SpriteBatch.Name.Boxes, pWallGroup); WF.Create(WallCategory.Type.Bottom, GameObject.Name.WallBottom, 448, 20, 850, 30); WF.Create(WallCategory.Type.Top, GameObject.Name.WallTop, 448, 650, 850, 30); WF.Create(WallCategory.Type.Left, GameObject.Name.WallLeft, 50, 448, 30, 950); WF.Create(WallCategory.Type.Right, GameObject.Name.WallRight, 846, 448, 30, 950); GameObjectMan.Attach(pWallGroup); //--------------------------------------------------------------------------------------------------------- // Missile //--------------------------------------------------------------------------------------------------------- // Missile Root MissileGroup pMissileGroup = new MissileGroup(GameObject.Name.MissileGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pMissileGroup.ActivateGameSprite(pSB_Aliens); pMissileGroup.ActivateCollisionSprite(pSB_Box); GameObjectMan.Attach(pMissileGroup); //--------------------------------------------------------------------------------------------------------- // Ship //--------------------------------------------------------------------------------------------------------- ShipRoot pShipRoot = new ShipRoot(GameObject.Name.ShipRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); GameObjectMan.Attach(pShipRoot); pMissileGroup.ActivateGameSprite(pSB_Aliens); pMissileGroup.ActivateCollisionSprite(pSB_Box); ShipMan.Create(pSpriteBatchMan); //pShipRoot.Print(); //--------------------------------------------------------------------------------------------------------- // Shield //--------------------------------------------------------------------------------------------------------- // Create the factory ... prototype Composite pShieldRoot = (Composite) new ShieldRoot(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, 300.0f, 300.0f); GameObjectMan.Attach(pShieldRoot); pShieldRoot.ActivateCollisionSprite(pSB_Box); pShieldRoot.ActivateGameSprite(pSB_Shields); ShieldFactory SF = new ShieldFactory(pSpriteBatchMan, SpriteBatch.Name.Shields, SpriteBatch.Name.Boxes, pShieldRoot); float brickWidth = 10.0f; float brickHeight = 5.0f; for (int i = 0; i < 4; i++) { float start_x = 150.0f + 180 * i; float start_y = 100.0f; float off_x = 0; SF.SetParent(pShieldRoot); GameObject pShieldGrid = SF.Create(ShieldCategory.Type.Grid, GameObject.Name.ShieldGrid); { int j = 0; GameObject pColumn; SF.SetParent(pShieldGrid); pColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); SF.SetParent(pColumn); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.LeftTop1, GameObject.Name.ShieldBrick, start_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.LeftTop0, GameObject.Name.ShieldBrick, start_x, start_y + 9 * brickHeight); SF.SetParent(pShieldGrid); pColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); SF.SetParent(pColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldGrid); pColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); SF.SetParent(pColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.LeftBottom, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldGrid); pColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); SF.SetParent(pColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldGrid); pColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); SF.SetParent(pColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.RightBottom, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldGrid); pColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); SF.SetParent(pColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldGrid); pColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); SF.SetParent(pColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.RightTop1, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.RightTop0, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); } } // load by column //pShieldRoot.Print(); //Debug.WriteLine("-------------------"); //ForwardIterator pFor = new ForwardIterator(pShieldRoot); //Component pNode = pFor.First(); //while (!pFor.IsDone()) //{ // pNode.DumpNode(); // pNode = pFor.Next(); //} //Debug.WriteLine("-------------------"); //ReverseIterator pRev = new ReverseIterator(pShieldRoot); //Component pNode2 = pRev.First(); //while (!pRev.IsDone()) //{ // pNode2.DumpNode(); // pNode2 = pRev.Next(); //} //Debug.WriteLine("-------------------"); //--------------------------------------------------------------------------------------------------------- // display 55 aliens on the screen //--------------------------------------------------------------------------------------------------------- //create the AlienRoot Composite pAlienRoot = (Composite) new AlienRoot(GameObject.Name.AlienRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); AlienFactory AF = new AlienFactory(pSpriteBatchMan, SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes, pAlienRoot); GameObjectMan.Attach(pAlienRoot); GameObject pAlienGrid = AF.Create(AlienCategory.Type.AlienGrid, GameObject.Name.AlienRoot); //create the AlienCloumn GameObject pAlienColumn; for (int i = 0; i < 11; i++) { AF.SetParent(pAlienGrid); pAlienColumn = AF.Create(AlienCategory.Type.AlienColumn, GameObject.Name.AlienColumn); AF.SetParent(pAlienColumn); AF.Create(AlienCategory.Type.Squid, GameObject.Name.Squid, 300.0f + 25 * i, 550.0f); AF.Create(AlienCategory.Type.Crab, GameObject.Name.Crab, 300.0f + 25 * i, 525.0f); AF.Create(AlienCategory.Type.Crab, GameObject.Name.Crab, 300.0f + 25 * i, 500.0f); AF.Create(AlienCategory.Type.Octopus, GameObject.Name.Octopus, 300.0f + 25 * i, 475.0f); AF.Create(AlienCategory.Type.Octopus, GameObject.Name.Octopus, 300.0f + 25 * i, 450.0f); } //create AnimationSprite and attach 2 images to the animation sprite //and add them to the TimerManager //float time; AnimationSprite pAniSquid = new AnimationSprite(GameSprite.Name.Squid); pAniSquid.Attach(Image.Name.SquidIn); pAniSquid.Attach(Image.Name.SquidOut); TimerMan.Add(TimeEvent.Name.SquidAnimation, pAniSquid, 1F); AnimationSprite pAniCrab = new AnimationSprite(GameSprite.Name.Crab); pAniCrab.Attach(Image.Name.CrabDown); pAniCrab.Attach(Image.Name.CrabUp); TimerMan.Add(TimeEvent.Name.CrabAnimation, pAniCrab, 1F); AnimationSprite pAniOcto = new AnimationSprite(GameSprite.Name.Octopus); pAniOcto.Attach(Image.Name.OctopusIn); pAniOcto.Attach(Image.Name.OctopusOut); TimerMan.Add(TimeEvent.Name.OctopusAnimation, pAniOcto, 1F); Movement pAlienMove = new Movement(pAlienRoot, pSB_Bombs, pSB_Box, pBombRoot); TimerMan.Add(TimeEvent.Name.AlienGridMovement, pAlienMove, 1F); //--------------------------------------------------------------------------------------------------------- // UFO //--------------------------------------------------------------------------------------------------------- pUFOGroup = new UFOGroup(GameObject.Name.UFOGroup, GameSprite.Name.NullObject, 1.0f, 1.0f); GameObjectMan.Attach(pUFOGroup); UFODisplay pUFODisplay = new UFODisplay(pSpriteBatchMan, SpriteBatch.Name.UFOs, SpriteBatch.Name.Boxes, GameObject.Name.UFO, GameSprite.Name.UFO, pUFOGroup); TimerMan.Add(TimeEvent.Name.DisplayUFO, pUFODisplay, 40f); //UFODisplay pUFODisplayRight = new UFODisplay(SpriteBatch.Name.UFOs, SpriteBatch.Name.Boxes, GameObject.Name.UFO, GameSprite.Name.UFO, UFOCategory.Type.RightMovingUFO, pUFOGroup); //TimerMan.Add(TimeEvent.Name.DisplayUFO, pUFODisplayRight, 20f); //GameObject pUFO = new LeftUFO(GameObject.Name.UFO, GameSprite.Name.UFO, 800, 700); ////GameObjectMan.Attach(pUFO); //pUFO.ActivateGameSprite(pSB_UFOs); //pUFO.ActivateCollisionSprite(pSB_Box); // UFO pUFO=new UFO(GameObject.Name.UFO, GameSprite.Name.UFO,) //pUFOGroup.ActivateGameSprite(pSB_UFOs); //pUFOGroup.ActivateCollisionSprite(pSB_Box); //GameObjectMan.Attach(pUFOGroup); //--------------------------------------------------------------------------------------------------------- // ColPair //--------------------------------------------------------------------------------------------------------- ColPair pColPair; // associate in a collision pair //bomb vs ship(player) pColPair = ColPairMan.Add(ColPair.Name.Bombs_Player, pBombRoot, pShipRoot); pColPair.Attach(new CheckPlayerStatusObserver(pSpriteBatchMan)); pColPair.Attach(new SndObserver(SpaceInvaders.GetInstance().sndEngine, "explosion.wav")); pColPair.Attach(new SwitchToSplashObserver(GameSprite.Name.PlayerEnd, pSpriteBatchMan)); pColPair.Attach(new RemoveBombObserver(pSpriteBatchMan)); pColPair.Attach(new ShipEndObserver()); // Missile vs Wall pColPair = ColPairMan.Add(ColPair.Name.Missile_Wall, pMissileGroup, pWallGroup); Debug.Assert(pColPair != null); pColPair.Attach(new RemoveMissileObserver(pSpriteBatchMan)); pColPair.Attach(new ShipReadyObserver()); pColPair.Attach(new SndObserver(SpaceInvaders.GetInstance().sndEngine, "shoot.wav")); //pColPair.Attach(new SwitchToSplashObserver(GameSprite.Name.TopSplash)); // Bomb vs Bottom pColPair = ColPairMan.Add(ColPair.Name.Bomb_Wall, pBombRoot, pWallGroup); pColPair.Attach(new RemoveBombObserver(pSpriteBatchMan)); // Missile vs Shield pColPair = ColPairMan.Add(ColPair.Name.Misslie_Shield, pMissileGroup, pShieldRoot); pColPair.Attach(new RemoveMissileObserver(pSpriteBatchMan)); pColPair.Attach(new RemoveBrickObserver(pSpriteBatchMan)); pColPair.Attach(new ShipReadyObserver()); //pColPair.Attach(new SndObserver(SpaceInvaders.GetInstance().sndEngine, "fastinvader1.wav")); // pColPair.Attach(new SndObserver(sndEngine, "fastinvader1.wav")); //bomb vs shield pColPair = ColPairMan.Add(ColPair.Name.Bomb_Shield, pBombRoot, pShieldRoot); pColPair.Attach(new RemoveBrickObserver(pSpriteBatchMan)); pColPair.Attach(new RemoveBombObserver(pSpriteBatchMan)); //pColPair.Attach(new SndObserver(SpaceInvaders.GetInstance().sndEngine, "fastinvader1.wav")); //alien vs wall pColPair = ColPairMan.Add(ColPair.Name.Aleins_Wall, pAlienRoot, pWallGroup); pColPair.Attach(new GridObserver()); //UFO vs wall pColPair = ColPairMan.Add(ColPair.Name.UFO_Wall, pUFOGroup, pWallGroup); pColPair.Attach(new RemoveUFOObserver(pSpriteBatchMan)); //Aliens vs missile pColPair = ColPairMan.Add(ColPair.Name.Aliens_Missiles, pAlienRoot, pMissileGroup); //pColPair.Attach(new RemoveAlienObserver()); pColPair.Attach(new RemoveMissileObserver(pSpriteBatchMan)); pColPair.Attach(new ShipReadyObserver()); pColPair.Attach(new SndObserver(SpaceInvaders.GetInstance().sndEngine, "shoot.wav")); pColPair.Attach(new SwitchToSplashObserver(GameSprite.Name.Splash, pSpriteBatchMan)); pColPair.Attach(new AddScoreObserver()); //missile vs UFO pColPair = ColPairMan.Add(ColPair.Name.Missiles_UFOs, pMissileGroup, pUFOGroup); pColPair.Attach(new SndObserver(SpaceInvaders.GetInstance().sndEngine, "shoot.wav")); pColPair.Attach(new SwitchToSplashObserver(GameSprite.Name.Splash, pSpriteBatchMan)); pColPair.Attach(new RemoveMissileObserver(pSpriteBatchMan)); pColPair.Attach(new ShipReadyObserver()); pColPair.Attach(new AddScoreObserver()); //missile vs bomb pColPair = ColPairMan.Add(ColPair.Name.Bombs_Missiles, pBombRoot, pMissileGroup); pColPair.Attach(new SndObserver(SpaceInvaders.GetInstance().sndEngine, "shoot.wav")); pColPair.Attach(new SwitchToSplashObserver(GameSprite.Name.Splash, pSpriteBatchMan)); pColPair.Attach(new RemoveMissileObserver(pSpriteBatchMan)); pColPair.Attach(new ShipReadyObserver()); ////aliengrid vs brickshields //pColPair = ColPairMan.Add(ColPair.Name.Aliens_Shields, pAlienRoot, pShieldRoot); //pColPair.Attach(new RemoveShieldsObserver()); }
//----------------------------------------------------------------------------- // Game::LoadContent() // Allows you to load all content needed for your engine, // such as objects, graphics, etc. //----------------------------------------------------------------------------- public override void LoadContent() { //--------------------------------------------------------------------------------------------------------- // Setup Managers //--------------------------------------------------------------------------------------------------------- TextureMan.Create(1, 1); ImageMan.Create(5, 2); GameSpriteMan.Create(4, 2); BoxSpriteMan.Create(3, 1); SpriteBatchMan.Create(3, 1); TimerMan.Create(3, 1); ProxyMan.Create(10, 1); GameObjectMan.Create(10, 5); ColPairMan.Create(3, 1); GlyphMan.Create(3, 1); FontMan.Create(1, 1); //--------------------------------------------------------------------------------------------------------- // Sound Experiment //--------------------------------------------------------------------------------------------------------- SoundMan.Create(5, 3); SoundMan.LoadAll(); // play a sound file SoundMan.PlayMusic(Sound.Name.Snd_Theme); SoundMan.Find(Sound.Name.Snd_Theme).SetVolume(0.2f); //--------------------------------------------------------------------------------------------------------- // Load the Textures //--------------------------------------------------------------------------------------------------------- TextureMan.Add(Texture.Name.Birds, "Birds.tga"); TextureMan.Add(Texture.Name.PacMan, "PacMan.tga"); TextureMan.Add(Texture.Name.Consolas, "Consolas20pt.tga"); TextureMan.Add(Texture.Name.Invader_3, "Invaders_3.tga"); TextureMan.Add(Texture.Name.Invader_4, "Invaders_4.tga"); TextureMan.LoadTexture(); //--------------------------------------------------------------------------------------------------------- // Create Images //--------------------------------------------------------------------------------------------------------- // --- angry birds --- ImageMan.Add(Image.Name.RedBird, Texture.Name.Birds, 47, 41, 48, 46); ImageMan.Add(Image.Name.YellowBird, Texture.Name.Birds, 124, 34, 60, 56); ImageMan.Add(Image.Name.GreenBird, Texture.Name.Birds, 246, 135, 99, 72); ImageMan.Add(Image.Name.WhiteBird, Texture.Name.Birds, 139, 131, 84, 97); ImageMan.Add(Image.Name.BlueBird, Texture.Name.Birds, 301, 49, 33, 33); // --- Pacman Ghosts --- ImageMan.Add(Image.Name.RedGhost, Texture.Name.PacMan, 616, 148, 33, 33); ImageMan.Add(Image.Name.PinkGhost, Texture.Name.PacMan, 663, 148, 33, 33); ImageMan.Add(Image.Name.BlueGhost, Texture.Name.PacMan, 710, 148, 33, 33); ImageMan.Add(Image.Name.OrangeGhost, Texture.Name.PacMan, 757, 148, 33, 33); // --- Alians --- ImageMan.LoadImage(); //--------------------------------------------------------------------------------------------------------- // Create Sprites //--------------------------------------------------------------------------------------------------------- // --- BoxSprites --- BoxSpriteMan.Add(550.0f, 500.0f, 50.0f, 150.0f, new Azul.Color(1.0f, 1.0f, 1.0f, 1.0f)); BoxSpriteMan.Add(550.0f, 100.0f, 50.0f, 100.0f); GameSpriteMan.Add(GameSprite.Name.RedBird, Image.Name.RedBird, 50, 500, 50, 50); GameSpriteMan.Add(GameSprite.Name.YellowBird, Image.Name.YellowBird, 300, 400, 50, 50); GameSpriteMan.Add(GameSprite.Name.GreenBird, Image.Name.GreenBird, 400, 200, 50, 50); GameSpriteMan.Add(GameSprite.Name.WhiteBird, Image.Name.WhiteBird, 600, 200, 100, 100); GameSpriteMan.Add(GameSprite.Name.BlueBird, Image.Name.BlueBird, 50, 50, 50, 50); GameSpriteMan.Add(GameSprite.Name.RedGhost, Image.Name.RedGhost, 100, 300, 100, 100); GameSpriteMan.Add(GameSprite.Name.PinkGhost, Image.Name.PinkGhost, 300, 300, 100, 100); GameSpriteMan.Add(GameSprite.Name.BlueGhost, Image.Name.BlueGhost, 500, 300, 100, 100); GameSpriteMan.Add(GameSprite.Name.OrangeGhost, Image.Name.OrangeGhost, 700, 300, 100, 100); GameSpriteMan.LoadGameSprite(); // Create SpriteBatch //--------------------------------------------------------------------------------------------------------- SpriteBatch pSB_Texts = SpriteBatchMan.Add(SpriteBatch.Name.Batch_Texts); SpriteBatch pSB_Birds = SpriteBatchMan.Add(SpriteBatch.Name.Batch_AngryBirds); SpriteBatch pSB_Alieans = SpriteBatchMan.Add(SpriteBatch.Name.Batch_Aliens); SpriteBatch pSB_Box = SpriteBatchMan.Add(SpriteBatch.Name.Batch_Boxes); //--------------------------------------------------------------------------------------------------------- // Attach to Sprite Batch //--------------------------------------------------------------------------------------------------------- pSB_Birds.Attach(GameSprite.Name.RedBird); pSB_Birds.Attach(GameSprite.Name.YellowBird); pSB_Birds.Attach(GameSprite.Name.GreenBird); pSB_Birds.Attach(GameSprite.Name.WhiteBird); //--------------------------------------------------------------------------------------------------------- // Proxy //--------------------------------------------------------------------------------------------------------- // create 10 proxies for (int i = 0; i < 10; i++) { ProxySprite pProxy = ProxyMan.Add(GameSprite.Name.YellowBird); pProxy.x = 50.0f + 70 * i; pProxy.y = 100.0f; pSB_Birds.Attach(pProxy); } //--------------------------------------------------------------------------------------------------------- // Game Object //--------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------- // Create Birds //--------------------------------------------------------------------------------------------------------- // create the factory BirdFactory BF = new BirdFactory(SpriteBatch.Name.Batch_AngryBirds); BirdGrid pGrid = (BirdGrid)BF.Create(GameObject.Name.BirdGrid, BirdCategory.Type.Grid); GameObjectMan.Attach(pGrid); BF.LoadAll(pGrid); AliensFactory af = new AliensFactory(SpriteBatch.Name.Batch_Aliens); GameObject pAlienGrid = af.Create(GameObject.Name.Aliens_Grid, AlienCategory.Type.Grid); GameObjectMan.Attach(pAlienGrid); af.LoadAll(pAlienGrid); //pAlienGrid.Print(); //--------------------------------------------------------------------------------------------------------- // Create Walls //--------------------------------------------------------------------------------------------------------- // Wall Root WallFactory WF = new WallFactory(); WallGrid pWallGrid = (WallGrid)WF.Create(GameObject.Name.Wall_Grid, WallCategory.Type.Wall_Grid, 0.0f, 0.0f); GameObjectMan.Attach(pWallGrid); WallLeft pWallLeft = (WallLeft)WF.Create(GameObject.Name.Wall_Left, WallCategory.Type.Wall_Left, 20, 280, 20, 500); WallRight pWallRight = (WallRight)WF.Create(GameObject.Name.Wall_Right, WallCategory.Type.Wall_Right, 780, 280, 20, 500); WallTop pWallTop = (WallTop)WF.Create(GameObject.Name.Wall_Top, WallCategory.Type.Wall_Top, 400, 530, 700, 20); WallBottom pWallBottom = (WallBottom)WF.Create(GameObject.Name.Wall_Bottom, WallCategory.Type.Wall_Bottom, 400, 20, 700, 20); // Add to the composite the children pWallGrid.Add(pWallRight); pWallGrid.Add(pWallLeft); pWallGrid.Add(pWallTop); pWallGrid.Add(pWallBottom); //--------------------------------------------------------------------------------------------------------- // Create Missile //--------------------------------------------------------------------------------------------------------- MissileFactory MF = new MissileFactory(SpriteBatch.Name.Batch_Aliens); MissileGrid pMissileGrid = (MissileGrid)MF.Create(GameObject.Name.Missile_Grid, MissileCategory.Type.Missile_Grid); GameObjectMan.Attach(pMissileGrid); Missile pMissile = (Missile)MF.Create(GameObject.Name.Missile, MissileCategory.Type.Missile, 405, 100); pMissileGrid.Add(pMissile); Debug.WriteLine("-------------------"); //--------------------------------------------------------------------------------------------------------- // ColPair //--------------------------------------------------------------------------------------------------------- // associate in a collision pair ColPair pair = ColPairMan.Add(pMissileGrid, pAlienGrid); pair.Attach(new MissileHitAlienAnim()); pair.Attach(new MissileHitAlienSnd()); ColPairMan.Add(pWallGrid, pAlienGrid); ColPairMan.Add(pWallGrid, pMissileGrid); //--------------------------------------------------------------------------------------------------------- // Font Experiment //--------------------------------------------------------------------------------------------------------- GlyphMan.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Batch_Texts, "ABC", Glyph.Name.Consolas36pt, 500, 500); FontMan.Add(Font.Name.TestOneOff, SpriteBatch.Name.Batch_Texts, "XYZ1234!#=+ZYX", Glyph.Name.Consolas36pt, 200, 200); }