예제 #1
0
        public AlienFactory(SpriteBatch.Name alienSpriteBatchName, SpriteBatch.Name collisionBoxSpriteBatchName, Composite alienComposite)
        {
            this.pAlienSpriteBatch = GameStateManager.GetGame().GetStateSpriteBatchManager().Find(alienSpriteBatchName);
            Debug.Assert(this.pAlienSpriteBatch != null);

            this.pCollisionBoxSpriteBatch = GameStateManager.GetGame().GetStateSpriteBatchManager().Find(collisionBoxSpriteBatchName);
            Debug.Assert(this.pCollisionBoxSpriteBatch != null);

            Debug.Assert(alienComposite != null);
            this.pComposite = alienComposite;
        }
예제 #2
0
        public override void Initialize()
        {
            //this.name = SceneContext.Scene.Play;

            this.numLives = 3;
            this.isDead   = false;

            //---------------------------------------------------------------------------------------------------------
            // Unique Managers
            //---------------------------------------------------------------------------------------------------------

            this.poSpriteBatchMan = new SpriteBatchMan(3, 1);
            SpriteBatchMan.SetActive(this.poSpriteBatchMan);

            this.poGameObjectMan = new GameObjectMan(3, 1);
            GameObjectMan.SetActive(this.poGameObjectMan);

            this.poTimerMan = new TimerMan(3, 1);
            TimerMan.SetActive(this.poTimerMan);

            this.poDelayedObjectMan = new DelayedObjectMan();
            DelayedObjectMan.SetActive(this.poDelayedObjectMan);

            //---------------------------------------------------------------------------------------------------------
            // Initialize Input Keys
            //---------------------------------------------------------------------------------------------------------

            this.poInputMan = new InputMan();
            InputMan.SetActive(this.poInputMan);

            InputSubject pInputSubject;

            pInputSubject = InputMan.GetArrowRightSubject();
            pInputSubject.Attach(new MoveRightObserver());

            pInputSubject = InputMan.GetArrowLeftSubject();
            pInputSubject.Attach(new MoveLeftObserver());

            pInputSubject = InputMan.GetSpaceSubject();
            pInputSubject.Attach(new ShootObserver());

            pInputSubject = InputMan.GetKey_B_Subject();
            pInputSubject.Attach(new Key_B_Observer());

            pInputSubject = InputMan.GetKey_1_Subject();
            pInputSubject.Attach(new Key_1_Observer());

            pInputSubject = InputMan.GetKey_2_Subject();
            pInputSubject.Attach(new Key_2_Observer());

            pInputSubject = InputMan.GetKey_Q_Subject();
            pInputSubject.Attach(new Key_Q_Observer());

            //---------------------------------------------------------------------------------------------------------
            // Sound
            //---------------------------------------------------------------------------------------------------------

            // start up the engine
            SoundEngineMan.Add(SoundEngine.Name.AlienA, "fastinvader1.wav", 0.2f);
            SoundEngineMan.Add(SoundEngine.Name.AlienB, "fastinvader2.wav", 0.2f);
            SoundEngineMan.Add(SoundEngine.Name.AlienC, "fastinvader3.wav", 0.2f);
            SoundEngineMan.Add(SoundEngine.Name.AlienD, "fastinvader4.wav", 0.2f);
            SoundEngineMan.Add(SoundEngine.Name.Shoot, "shoot.wav", 0.2f);
            SoundEngineMan.Add(SoundEngine.Name.Invaderkilled, "invaderkilled.wav", 0.2f);
            SoundEngineMan.Add(SoundEngine.Name.Explosion, "explosion.wav", 0.2f);
            SoundEngineMan.Add(SoundEngine.Name.UFO_HighPitch, "ufo_highpitch.wav", 0.5f);
            SoundEngineMan.Add(SoundEngine.Name.UFO_LowPitch, "ufo_lowpitch.wav", 0.2f);

            //---------------------------------------------------------------------------------------------------------
            // Font
            //---------------------------------------------------------------------------------------------------------

            Texture pTexture = TextureMan.Add(Texture.Name.Consolas36pt, "Consolas36pt.tga");

            GlyphMan.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas36pt);

            //---------------------------------------------------------------------------------------------------------
            // Create Sprites
            //---------------------------------------------------------------------------------------------------------
            this.poGameSpriteMan = new GameSpriteMan(3, 1);
            GameSpriteMan.SetActive(this.poGameSpriteMan);

            // ----- Aliens -----
            GameSpriteMan.Add(GameSprite.Name.SquidOpen, Image.Name.SquidOpen, 50, 550, 22, 22);
            GameSpriteMan.Add(GameSprite.Name.CrabOpen, Image.Name.CrabOpen, 50, 510, 25, 25);
            GameSpriteMan.Add(GameSprite.Name.OctopusOpen, Image.Name.OctopusOpen, 50, 430, 28, 28);

            // ----- UFO -----
            GameSpriteMan.Add(GameSprite.Name.UFO, Image.Name.UFO, 0, 500, 40, 18);

            // ----- Missile -----
            GameSpriteMan.Add(GameSprite.Name.Missile, Image.Name.Missile, 50, 430, 4, 15);

            // ----- Ship -----
            GameSpriteMan.Add(GameSprite.Name.Ship, Image.Name.Ship, 50, 430, 50, 25);

            // ----- Splats -----
            GameSpriteMan.Add(GameSprite.Name.SplatAlien, Image.Name.AlienSplat, 100, 100, 22, 22);
            GameSpriteMan.Add(GameSprite.Name.SplatBomb, Image.Name.BombSplat, 100, 100, 7, 17);
            GameSpriteMan.Add(GameSprite.Name.SplatMissile, Image.Name.MissleSplat, 100, 100, 20, 15);
            GameSpriteMan.Add(GameSprite.Name.SplatUFO, Image.Name.UFOSplat, 100, 100, 40, 18);
            GameSpriteMan.Add(GameSprite.Name.SplatShip, Image.Name.ShipSplat, 100, 100, 50, 25);

            // ----- Bombs -----
            GameSpriteMan.Add(GameSprite.Name.BombDragger, Image.Name.BombDragger, 100, 100, 7, 17);
            GameSpriteMan.Add(GameSprite.Name.BombZigZag, Image.Name.BombZigZag, 100, 100, 7, 17);
            GameSpriteMan.Add(GameSprite.Name.BombRolling, Image.Name.BombRolling, 100, 100, 7, 17);
            GameSpriteMan.Add(GameSprite.Name.BombStraight, Image.Name.BombStraight, 100, 100, 5, 17);

            // ----- Shields -----
            float brick_W = 15.0f;
            float brick_H = 6.0f;

            GameSpriteMan.Add(GameSprite.Name.Brick, Image.Name.Brick, 50, 25, brick_W, brick_H);
            GameSpriteMan.Add(GameSprite.Name.Brick_LeftTop0, Image.Name.BrickLeft_Top0, 50, 25, brick_W, brick_H);
            GameSpriteMan.Add(GameSprite.Name.Brick_LeftTop1, Image.Name.BrickLeft_Top1, 50, 25, brick_W, brick_H);
            GameSpriteMan.Add(GameSprite.Name.Brick_LeftBottom, Image.Name.BrickLeft_Bottom, 50, 25, brick_W, brick_H);
            GameSpriteMan.Add(GameSprite.Name.Brick_RightTop0, Image.Name.BrickRight_Top0, 50, 25, brick_W, brick_H);
            GameSpriteMan.Add(GameSprite.Name.Brick_RightTop1, Image.Name.BrickRight_Top1, 50, 25, brick_W, brick_H);
            GameSpriteMan.Add(GameSprite.Name.Brick_RightBottom, Image.Name.BrickRight_Bottom, 50, 25, brick_W, brick_H);

            //---------------------------------------------------------------------------------------------------------
            // Create SpriteBatch
            //---------------------------------------------------------------------------------------------------------

            SpriteBatch pSB_Aliens  = this.poSpriteBatchMan.Add(SpriteBatch.Name.Aliens, 100);
            SpriteBatch pSB_Shields = this.poSpriteBatchMan.Add(SpriteBatch.Name.Shields, 200);
            SpriteBatch pSB_Texts   = this.poSpriteBatchMan.Add(SpriteBatch.Name.Texts, 300);
            SpriteBatch pSB_Box     = this.poSpriteBatchMan.Add(SpriteBatch.Name.Boxes, 400);

            //---------------------------------------------------------------------------------------------------------
            // Create Aliens
            //---------------------------------------------------------------------------------------------------------

            // Create the Aliens factory
            AlienFactory AF = new AlienFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes);

            // Initialize Grid
            AlienGrid pGrid = (AlienGrid)AF.Create(GameObject.Name.AlienGrid, AlienCategory.Type.Grid);

            // Generate Aliens
            pGrid.GenerateAlien(this.poGameObjectMan);

            MoveCommand pMoveGrid = new MoveCommand(pGrid);

            TimerMan.Add(TimeEvent.Name.MoveGrid, pMoveGrid, 0.5f);

            //---------------------------------------------------------------------------------------------------------
            // Timer
            //---------------------------------------------------------------------------------------------------------

            // Create animation for Squid sprite
            AnimationSprite pAnimSquid = new AnimationSprite(GameSprite.Name.SquidOpen);

            // Attach Squid images to cycle
            pAnimSquid.Attach(Image.Name.SquidOpen);
            pAnimSquid.Attach(Image.Name.SquidClosed);


            // Create animation for Crab sprite
            AnimationSprite pAnimCrab = new AnimationSprite(GameSprite.Name.CrabOpen);

            // Attach Crab images to cycle
            pAnimCrab.Attach(Image.Name.CrabOpen);
            pAnimCrab.Attach(Image.Name.CrabClosed);


            // Create animation for Octopus sprite
            AnimationSprite pAnimOctopus = new AnimationSprite(GameSprite.Name.OctopusOpen);

            // Attach Octopus images to cycle
            pAnimOctopus.Attach(Image.Name.OctopusOpen);
            pAnimOctopus.Attach(Image.Name.OctopusClosed);


            // Add AnimationSprite to timer
            TimerMan.Add(TimeEvent.Name.SwapAliens, pAnimSquid, 0.5f);
            TimerMan.Add(TimeEvent.Name.SwapAliens, pAnimCrab, 0.5f);
            TimerMan.Add(TimeEvent.Name.SwapAliens, pAnimOctopus, 0.5f);

            // Add Grid Tempo
            GridSoundTempoEvent pGridTempo = new GridSoundTempoEvent();

            pGridTempo.Attach(SoundEngine.Name.AlienA);
            pGridTempo.Attach(SoundEngine.Name.AlienB);
            pGridTempo.Attach(SoundEngine.Name.AlienC);
            pGridTempo.Attach(SoundEngine.Name.AlienD);

            TimerMan.Add(TimeEvent.Name.GridSoundTempo, pGridTempo, 0.5f);

            //---------------------------------------------------------------------------------------------------------
            // Create 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);

            //---------------------------------------------------------------------------------------------------------
            // Splat Root
            //---------------------------------------------------------------------------------------------------------
            BombRoot pSplatRoot = new BombRoot(GameObject.Name.SplatRoot, GameSprite.Name.NullObject, 0.0f, 0.0f);

            pSplatRoot.ActivateCollisionSprite(pSB_Box);

            GameObjectMan.Attach(pSplatRoot);

            //---------------------------------------------------------------------------------------------------------
            // Bomb Root
            //---------------------------------------------------------------------------------------------------------
            BombRoot pBombRoot = new BombRoot(GameObject.Name.BombRoot, GameSprite.Name.NullObject, 0.0f, 0.0f);

            pBombRoot.ActivateCollisionSprite(pSB_Box);

            GameObjectMan.Attach(pBombRoot);
            TimerMan.Add(TimeEvent.Name.BombRandom, new BombSpawnEvent(pRandom, pGrid), 1.0f);

            //---------------------------------------------------------------------------------------------------------
            // Create Walls
            //---------------------------------------------------------------------------------------------------------

            // Wall Root
            WallGroup pWallGroup = new WallGroup(GameObject.Name.WallGroup, GameSprite.Name.NullObject, 0.0f, 0.0f);

            pWallGroup.ActivateGameSprite(pSB_Aliens);
            pWallGroup.ActivateCollisionSprite(pSB_Box);

            WallRight pWallRight = new WallRight(GameObject.Name.WallRight, GameSprite.Name.NullObject, 775, 290, 20, 500);

            pWallRight.ActivateCollisionSprite(pSB_Box);

            WallLeft pWallLeft = new WallLeft(GameObject.Name.WallLeft, GameSprite.Name.NullObject, 25, 290, 20, 500);

            pWallLeft.ActivateCollisionSprite(pSB_Box);

            // Add to the composite the children
            pWallGroup.Add(pWallRight);
            pWallGroup.Add(pWallLeft);

            GameObjectMan.Attach(pWallGroup);

            //---------------------------------------------------------------------------------------------------------
            // Create No Score Items
            //---------------------------------------------------------------------------------------------------------

            WallGroup pNoScoreGroup = new WallGroup(GameObject.Name.NoScoreGroup, GameSprite.Name.NullObject, 0.0f, 0.0f);

            pNoScoreGroup.ActivateGameSprite(pSB_Aliens);
            pNoScoreGroup.ActivateCollisionSprite(pSB_Box);

            WallTop pWallTop = new WallTop(GameObject.Name.WallTop, GameSprite.Name.NullObject, 400, 540, 700, 0);

            pWallTop.ActivateCollisionSprite(pSB_Aliens);

            WallBottom pWallBottom = new WallBottom(GameObject.Name.WallBottom, GameSprite.Name.NullObject, 400, 40, 730, 0);

            pWallBottom.ActivateGameSprite(pSB_Aliens);
            pWallBottom.ActivateCollisionSprite(pSB_Box);

            pNoScoreGroup.Add(pWallTop);
            pNoScoreGroup.Add(pWallBottom);

            GameObjectMan.Attach(pNoScoreGroup);

            //---------------------------------------------------------------------------------------------------------
            // Ship
            //---------------------------------------------------------------------------------------------------------

            ShipRoot pShipRoot = new ShipRoot(GameObject.Name.ShipRoot, GameSprite.Name.NullObject, 0.0f, 0.0f);

            pShipRoot.ActivateGameSprite(pSB_Aliens);
            pShipRoot.ActivateCollisionSprite(pSB_Box);

            GameObjectMan.Attach(pShipRoot);

            //ShipMan.Create();

            this.poShipMan = new ShipMan();
            ShipMan.SetActive(this.poShipMan);
            this.poShipMan.pShip = ShipMan.ActivateShip();
            this.poShipMan.pShip.SetState(ShipMan.State.Ready);


            //---------------------------------------------------------------------------------------------------------
            // UFO
            //---------------------------------------------------------------------------------------------------------
            UFORoot pUFORoot = new UFORoot(GameObject.Name.UFORoot, GameSprite.Name.NullObject, 0.0f, 0.0f);

            pUFORoot.ActivateGameSprite(pSB_Aliens);
            pUFORoot.ActivateCollisionSprite(pSB_Box);

            GameObjectMan.Attach(pUFORoot);
            TimerMan.Add(TimeEvent.Name.UFORandom, new UFOSpawnEvent(pRandom), 5.0f);

            //---------------------------------------------------------------------------------------------------------
            // Shields
            //---------------------------------------------------------------------------------------------------------

            Composite pShieldRoot = ShieldsGroupFactory.Create(100, 130, this.poGameObjectMan);

            //---------------------------------------------------------------------------------------------------------
            // ColPair
            //---------------------------------------------------------------------------------------------------------

            // Grid vs Right Left Walls
            ColPair pColPair_GW = ColPairMan.Add(ColPair.Name.Alien_Wall, pGrid, pWallGroup);

            Debug.Assert(pColPair_GW != null);

            pColPair_GW.Attach(new GridDropObserver());

            // Ship vs Right Left Walls
            ColPair pColPair_SW = ColPairMan.Add(ColPair.Name.Ship_Wall, pShipRoot, pWallGroup);

            Debug.Assert(pColPair_SW != null);

            pColPair_SW.Attach(new StopShipMoveObserver());

            // Grid vs Shield
            ColPair pColPair_AS = ColPairMan.Add(ColPair.Name.Bomb_Shield, pGrid, pShieldRoot);

            Debug.Assert(pColPair_AS != null);

            pColPair_AS.Attach(new RemoveBrickObserver());

            // Missile vs Alien
            ColPair pColPair_MA = ColPairMan.Add(ColPair.Name.Missile_Alien, pMissileGroup, pGrid);

            Debug.Assert(pColPair_MA != null);

            pColPair_MA.Attach(new ShipReadyObserver());
            pColPair_MA.Attach(new RemoveAlienObserver(this));
            pColPair_MA.Attach(new ShipRemoveMissileObserver(false));
            pColPair_MA.Attach(new SndAlienHitObserver());
            pColPair_MA.Attach(new SpeedGridObserver());

            // Missile vs UFO
            ColPair pColPair_MU = ColPairMan.Add(ColPair.Name.Missile_UFO, pMissileGroup, pUFORoot);

            Debug.Assert(pColPair_MU != null);

            pColPair_MU.Attach(new ShipReadyObserver());
            pColPair_MU.Attach(new ShipRemoveMissileObserver(false));
            pColPair_MU.Attach(new RemoveUFOObserver());
            pColPair_MU.Attach(new SndAlienHitObserver());

            // Missle vs Bomb
            ColPair pColPair_MB = ColPairMan.Add(ColPair.Name.Missile_Bomb, pMissileGroup, pBombRoot);

            Debug.Assert(pColPair_MB != null);

            pColPair_MB.Attach(new ShipReadyObserver());
            pColPair_MB.Attach(new ShipRemoveMissileObserver(false));
            pColPair_MB.Attach(new BombObserver(true));

            // Missile vs Top Wall
            ColPair pColPair_MW = ColPairMan.Add(ColPair.Name.Missile_Wall, pMissileGroup, pNoScoreGroup);

            Debug.Assert(pColPair_MW != null);

            pColPair_MW.Attach(new ShipReadyObserver());
            pColPair_MW.Attach(new ShipRemoveMissileObserver(true));

            // Missile vs Shield
            ColPair pColPair_MS = ColPairMan.Add(ColPair.Name.Misslie_Shield, pMissileGroup, pShieldRoot);

            Debug.Assert(pColPair_MS != null);

            pColPair_MS.Attach(new ShipRemoveMissileObserver(false));
            pColPair_MS.Attach(new RemoveBrickObserver());
            pColPair_MS.Attach(new ShipReadyObserver());
            pColPair_MS.Attach(new SndAlienHitObserver());

            // Bomb vs Bottom Wall
            ColPair pColPair_BW = ColPairMan.Add(ColPair.Name.Bomb_Wall, pBombRoot, pNoScoreGroup);

            Debug.Assert(pColPair_BW != null);

            pColPair_BW.Attach(new BombObserver(true));

            // Bomb vs Shield
            ColPair pColPair_BS = ColPairMan.Add(ColPair.Name.Bomb_Shield, pBombRoot, pShieldRoot);

            Debug.Assert(pColPair_BS != null);

            pColPair_BS.Attach(new RemoveBombObserver(this));
            pColPair_BS.Attach(new RemoveBrickObserver());
            pColPair_BS.Attach(new SndAlienHitObserver());

            // Bomb vs Player's Ship
            ColPair pColPair_BP = ColPairMan.Add(ColPair.Name.Bomb_Ship, pBombRoot, pShipRoot);

            Debug.Assert(pColPair_BP != null);

            pColPair_BP.Attach(new RemoveShipObserver(this));
            pColPair_BP.Attach(new RemoveBombObserver(this));
            pColPair_BP.Attach(new SndShipHitObserver());
            pColPair_BP.Attach(new ReCreateShipObserver(this));

            //---------------------------------------------------------------------------------------------------------
            // Fonts
            //---------------------------------------------------------------------------------------------------------

            FontMan.Add(Font.Name.ScoreText, SpriteBatch.Name.Texts, "SCORE<1>", Glyph.Name.Consolas36pt, 60, 585);
            pFontScore1 = FontMan.Add(Font.Name.Score1, SpriteBatch.Name.Texts, "0000", Glyph.Name.Consolas36pt, 85, 558);

            FontMan.Add(Font.Name.ScoreText, SpriteBatch.Name.Texts, "HI-SCORE", Glyph.Name.Consolas36pt, 325, 585);
            pFontHighScore = FontMan.Add(Font.Name.HighScore, SpriteBatch.Name.Texts, "0000", Glyph.Name.Consolas36pt, 350, 558);

            FontMan.Add(Font.Name.ScoreText, SpriteBatch.Name.Texts, "SCORE<2>", Glyph.Name.Consolas36pt, 600, 585);
            pFontScore2 = FontMan.Add(Font.Name.Score2, SpriteBatch.Name.Texts, "0000", Glyph.Name.Consolas36pt, 625, 558);

            FontMan.Add(Font.Name.ScoreText, SpriteBatch.Name.Texts, "LIVES: ", Glyph.Name.Consolas36pt, 50, 25);
            pFontLives = FontMan.Add(Font.Name.Lives, SpriteBatch.Name.Texts, "3", Glyph.Name.Consolas36pt, 160, 25);
        }
        public WallFactory(SpriteBatchMan pSpriteBatchMan, SpriteBatch.Name spriteBatchName, SpriteBatch.Name collisionSpriteBatch, Composite pTree)
        {
            this.pSpriteBatch = pSpriteBatchMan.Find(spriteBatchName);
            Debug.Assert(this.pSpriteBatch != null);

            this.pCollisionSpriteBatch = pSpriteBatchMan.Find(collisionSpriteBatch);
            Debug.Assert(this.pCollisionSpriteBatch != null);

            Debug.Assert(pTree != null);
            this.pTree = pTree;
        }
        // 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());
        }
예제 #5
0
        public Composite CreateShield(float start_x, float start_y)
        {
            Composite pShieldRoot = this.pTree;
            int       j           = 0;

            GameObject pColumn;

            SetParent(pShieldRoot);
            pColumn = Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++);

            SetParent(pColumn);

            float off_x       = 0;
            float brickWidth  = 10.0f;
            float brickHeight = 5.0f;

            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 2 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 3 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 4 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 5 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 6 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 7 * brickHeight);
            Create(ShieldCategory.Type.LeftTop1, GameObject.Name.ShieldBrick, start_x, start_y + 8 * brickHeight);
            Create(ShieldCategory.Type.LeftTop0, GameObject.Name.ShieldBrick, start_x, start_y + 9 * brickHeight);

            SetParent(pShieldRoot);
            pColumn = Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++);

            SetParent(pColumn);

            off_x += brickWidth;
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

            SetParent(pShieldRoot);
            pColumn = Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++);

            SetParent(pColumn);

            off_x += brickWidth;
            Create(ShieldCategory.Type.LeftBottom, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

            SetParent(pShieldRoot);
            pColumn = Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++);

            SetParent(pColumn);

            off_x += brickWidth;
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

            SetParent(pShieldRoot);
            pColumn = Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++);

            SetParent(pColumn);

            off_x += brickWidth;
            Create(ShieldCategory.Type.RightBottom, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

            SetParent(pShieldRoot);
            pColumn = Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++);

            SetParent(pColumn);

            off_x += brickWidth;
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

            SetParent(pShieldRoot);
            pColumn = Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++);

            SetParent(pColumn);

            off_x += brickWidth;
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
            Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
            Create(ShieldCategory.Type.RightTop1, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
            Create(ShieldCategory.Type.RightTop0, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

            return(pShieldRoot);
        }
예제 #6
0
        public override void LoadContent()
        {
            ShipMan.Create();
            GraveyardMan.Create();

            SpriteBatch pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);

            pSB_Aliens.bToggle = true;

            SpriteBatch pSB_Boxes = SpriteBatchMan.Find(SpriteBatch.Name.Boxes);

            pSB_Boxes.bToggle = false;

            SpriteBatch pSB_Shields = SpriteBatchMan.Find(SpriteBatch.Name.Shields);

            pSB_Shields.bToggle = true;

            SpriteBatch pSB_InGame = SpriteBatchMan.Find(SpriteBatch.Name.InGameScreen);

            pSB_InGame.bToggle = true;

            SpriteBatch pSB_Projectiles = SpriteBatchMan.Find(SpriteBatch.Name.Projectiles);

            pSB_Projectiles.bToggle = true;

            //SpriteBatch pSB_Splats = SpriteBatchMan.Find(SpriteBatch.Name.Splats);
            //pSB_Splats.bToggle = true;

            SpaceInvaders pGame = GameMan.GetGame();

            IrrKlang.ISoundEngine pSndEngine = pGame.GetSndEngine();

            //-------------------------------------------------------------------------------------------------------
            //create factory
            //--------------------------------------------------------------------------------------------------------

            Composite pAlienGroup = (Composite)GONodeMan.Find(GameObject.Name.AlienGrid);

            AlienFactory AF = new AlienFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes, pAlienGroup);

            GameObject pGameObj;

            //AF.SetParent(pAlienGroup);
            //GameObject pCol = AF.Create(GameObject.Name.Column_1, AlienCategory.Type.Column, 0.0f, 0.0f);

            //AF.SetParent(pCol);

            //pGameObj = AF.Create(GameObject.Name.Octopus, AlienCategory.Type.Octopus, 70.0f, 600);

            //Column Creation 1 - 11
            for (int i = 0; i < 11; i++)
            {
                AF.SetParent(pAlienGroup);
                GameObject pCol = AF.Create(GameObject.Name.Column_1 + i, AlienCategory.Type.Column, 0.0f, 0.0f, i);

                AF.SetParent(pCol);

                pGameObj = AF.Create(GameObject.Name.Octopus, AlienCategory.Type.Octopus, 70.0f + i * 43.0f, 600);
                pGameObj = AF.Create(GameObject.Name.Crab, AlienCategory.Type.Crab, 70.0f + i * 43.0f, 560);
                pGameObj = AF.Create(GameObject.Name.Crab, AlienCategory.Type.Crab, 70.0f + i * 43.0f, 520);
                pGameObj = AF.Create(GameObject.Name.Squid, AlienCategory.Type.Squid, 70.0f + i * 43.0f, 480);
                pGameObj = AF.Create(GameObject.Name.Squid, AlienCategory.Type.Squid, 70.0f + i * 43.0f, 440);
            }

            //Debug.WriteLine("-------------------");
            //pAlienGroup.Print();

            //---------------------------------------------------------------------------------------------------------
            // Shields
            //---------------------------------------------------------------------------------------------------------

            float posX = 80;
            float posY = 120;

            for (int i = 0; i < 4; i++)
            {
                ShieldFactory.ShieldCreator(posX, posY, GameObject.Name.ShieldGrid_1 + i);
                posX += 130;
            }

            //Debug.WriteLine("-------------------");
            //GameObject pShieldRoot = GONodeMan.Find(GameObject.Name.ShieldRoot);
            //pShieldRoot.Print();

            //--------------------------------------------------------------------------------------------------------------
            //Time Events
            //--------------------------------------------------------------------------------------------------------------

            UFORoot pUFORoot = (UFORoot)GONodeMan.Find(GameObject.Name.UFORoot);

            MoveGrid pMove = new MoveGrid(pAlienGroup, pSndEngine);

            SendUFO pSendIt = new SendUFO(pUFORoot);

            //BombDrop pBombDrop0 = new BombDrop((AlienGroup)pAlienGroup);
            BombDrop pBombDrop1 = new BombDrop((AlienGroup)pAlienGroup);
            BombDrop pBombDrop2 = new BombDrop((AlienGroup)pAlienGroup);

            SpeedUpCheck pSpeedCheck = new SpeedUpCheck((AlienGroup)pAlienGroup);

            //---------------------------------------------------------------------------------------------------------
            //Add Events
            //---------------------------------------------------------------------------------------------------------

            AnimateCrab  pAnimCrab  = (AnimateCrab)AnimMan.Find(Animation.Name.AnimateCrab);
            AnimateSquid pAnimSquid = (AnimateSquid)AnimMan.Find(Animation.Name.AnimateSquid);
            AnimateOcto  pAnimOcto  = (AnimateOcto)AnimMan.Find(Animation.Name.AnimateOcto);


            TimerMan.Add(TimeEvent.Name.AnimateOcto, pAnimOcto, 0.60f);
            TimerMan.Add(TimeEvent.Name.AnimateSquid, pAnimSquid, 0.60f);
            TimerMan.Add(TimeEvent.Name.AnimateCrab, pAnimCrab, 0.60f);
            TimerMan.Add(TimeEvent.Name.MoveGrid, pMove, 0.60f);

            //TimerMan.Add(TimeEvent.Name.ColumnShoot, pBombDrop0, 1.0f);
            TimerMan.Add(TimeEvent.Name.ColumnShoot, pBombDrop1, 2.0f);
            TimerMan.Add(TimeEvent.Name.ColumnShoot, pBombDrop2, 4.0f);

            TimerMan.Add(TimeEvent.Name.SpeedCheck, pSpeedCheck, 12.0f);
            TimerMan.Add(TimeEvent.Name.SendUFO, pSendIt, 25.0f);
        }
예제 #7
0
        public override void Notify()
        {
            // Delete missile
            //Debug.WriteLine("RemoveAlienObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);

            // This cast will throw an exception if wrong
            this.pAlien     = (Alien)this.pSubject.pObjA;
            this.pComposite = null;

            // Remove Alien from composite
            Composite       pAlienGrid = GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.AlienGrid);
            ForwardIterator pFwdIter   = new ForwardIterator(pAlienGrid);

            Component pNode = pFwdIter.First();

            while (!pFwdIter.IsDone())
            {
                if (pNode.containerType == Component.Container.LEAF)
                {
                    // If Component is target alien
                    if (pNode.GetHashCode() == this.pAlien.GetHashCode())
                    {
                        // Remove Alien from column
                        pNode.pParent.Remove(pNode);

                        Component parentComposite = pNode.pParent;
                        // If column is now empty, delete column
                        if (parentComposite.GetFirstChild() == null)
                        {
                            // Delete empty column from parent composite
                            if (parentComposite.pParent != null)
                            {
                                parentComposite.pParent.Remove(parentComposite);
                            }

                            if (!((GameObject)parentComposite).IsMarkedForDeath())
                            {
                                // Delay - remove object later
                                this.pComposite = (GameObject)parentComposite;
                                this.pComposite.MarkForDeath();
                            }
                        }

                        break;
                    }
                }

                pNode = pFwdIter.Next();
            }

            if (!pAlien.IsMarkedForDeath())
            {
                pAlien.MarkForDeath();

                // Delay - remove object later
                RemoveAlienObserver pObserver = new RemoveAlienObserver(this);
                GameStateManager.GetGame().GetStateDelayedObjectManager().Attach(pObserver);
            }

            // Faster grid speed (shorter delta)
            float newSpeed = GameStateManager.GetGame().GetStateAlienGridSpeed() - 0.013f;

            if (newSpeed > 0.0f)
            {
                // Increase Alien Grid Speed
                GameStateManager.GetGame().SetStateAlienGridSpeed(newSpeed);
            }
        }
예제 #8
0
        public UFODisplay(SpriteBatchMan pSpriteBatchMan, SpriteBatch.Name spriteBatchName, SpriteBatch.Name collisionSpriteBatch, GameObject.Name name, GameSprite.Name spriteName, Composite pTree)
        {
            this.pSpriteBatch = pSpriteBatchMan.Find(spriteBatchName);
            Debug.Assert(this.pSpriteBatch != null);

            this.pCollisionSpriteBatch = pSpriteBatchMan.Find(collisionSpriteBatch);
            Debug.Assert(this.pCollisionSpriteBatch != null);

            //this.type = type;
            this.gameObjectName = name;
            this.spriteName     = spriteName;
            this.pTree          = pTree;
            this.flag           = true;
        }
예제 #9
0
        public override void LoadContent()
        {
            //make the next wave more difficult
            //change grid movement speed and add more bombs
            GraveyardMan.RaiseDead();

            //can be finicky might need to replace
            //GraveyardMan.RebuildShields();

            //-------------------------------------------------------------------------------------------------------
            //create factory
            //--------------------------------------------------------------------------------------------------------

            Composite pAlienGroup = (Composite)GONodeMan.Find(GameObject.Name.AlienGrid);

            //AlienFactory AF = new AlienFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes, pAlienGroup);

            //GameObject pGameObj;

            //AF.SetParent(pAlienGroup);
            //GameObject pCol = AF.Create(GameObject.Name.Column_1, AlienCategory.Type.Column, 0.0f, 0.0f);

            //AF.SetParent(pCol);

            //pGameObj = AF.Create(GameObject.Name.Octopus, AlienCategory.Type.Octopus, 70.0f, 600);

            //Column Creation 1 - 11
            //for (int i = 0; i < 1; i++)
            //{
            //    AF.SetParent(pAlienGroup);
            //    GameObject pCol = AF.Create(GameObject.Name.Column_1 + i, AlienCategory.Type.Column, 0.0f, 0.0f, i);

            //    AF.SetParent(pCol);

            //    pGameObj = AF.Create(GameObject.Name.Octopus, AlienCategory.Type.Octopus, 70.0f + i * 43.0f, 660);
            //    pGameObj = AF.Create(GameObject.Name.Crab, AlienCategory.Type.Crab, 70.0f + i * 43.0f, 620);
            //    pGameObj = AF.Create(GameObject.Name.Crab, AlienCategory.Type.Crab, 70.0f + i * 43.0f, 580);
            //    pGameObj = AF.Create(GameObject.Name.Squid, AlienCategory.Type.Squid, 70.0f + i * 43.0f, 540);
            //    pGameObj = AF.Create(GameObject.Name.Squid, AlienCategory.Type.Squid, 70.0f + i * 43.0f, 500);
            //}

            //Debug.WriteLine("-------------------");
            //pAlienGroup.Print();

            //---------------------------------------------------------------------------------------------------------
            // Shields
            //---------------------------------------------------------------------------------------------------------

            //float posX = 80;
            //float posY = 120;

            //for (int i = 0; i < 1; i++)
            //{
            //    ShieldFactory.ShieldCreator(posX, posY, GameObject.Name.ShieldGrid_1 + i);
            //    posX += 130;
            //}

            //Debug.WriteLine("-------------------");

            //GameObject pShieldRoot = GONodeMan.Find(GameObject.Name.ShieldRoot);
            //pShieldRoot.Print();


            //---------------------------------------------------------------------------------
            //Event/Difficulty Modifiers
            //----------------------------------------------------------------------------------
            TimeEvent pE1 = TimerMan.Find(TimeEvent.Name.AnimateSquid);
            TimeEvent pE2 = TimerMan.Find(TimeEvent.Name.AnimateOcto);
            TimeEvent pE3 = TimerMan.Find(TimeEvent.Name.AnimateCrab);

            TimeEvent pE4 = TimerMan.Find(TimeEvent.Name.MoveGrid);

            pE1.SetTriggerTime(0.50f);
            pE2.SetTriggerTime(0.50f);
            pE3.SetTriggerTime(0.50f);
            pE4.SetTriggerTime(0.50f);

            //pAlienGroup.SetDeltaMove(18.0f);
            BombDrop pBombDrop1 = new BombDrop((AlienGroup)pAlienGroup);
            BombDrop pBombDrop2 = new BombDrop((AlienGroup)pAlienGroup);
            BombDrop pBombDrop3 = new BombDrop((AlienGroup)pAlienGroup);

            TimerMan.Add(TimeEvent.Name.ColumnShoot, pBombDrop1, 1.0f);
            TimerMan.Add(TimeEvent.Name.ColumnShoot, pBombDrop2, 3.0f);
            TimerMan.Add(TimeEvent.Name.ColumnShoot, pBombDrop3, 5.0f);
        }