Exemple #1
0
        public override void Initialize()
        {
            this.poGameObjectManager = new GameObjectManager(3, 1);
            GameObjectManager.SetActive(this.poGameObjectManager);

            this.poTimerManager = new TimerManager(3, 1);
            TimerManager.SetActive(this.poTimerManager);

            this.poCollisionPairManager = new CollisionPairManager(3, 1);
            CollisionPairManager.SetActive(this.poCollisionPairManager);

            //---------------------------------------------------------------------------------------------------------
            // Create SpriteBatch
            //---------------------------------------------------------------------------------------------------------
            this.poSpriteBatchManager = new SpriteBatchManager(3, 1);
            SpriteBatchManager.SetActive(this.poSpriteBatchManager);

            SpriteBatch pAliensBatch  = SpriteBatchManager.Add(SpriteBatch.Name.Aliens, 1);
            SpriteBatch pBoxBatch     = SpriteBatchManager.Add(SpriteBatch.Name.Boxes, 2);
            SpriteBatch pShieldsBatch = SpriteBatchManager.Add(SpriteBatch.Name.Shields, 3);
            SpriteBatch pNullBatch    = SpriteBatchManager.Add(SpriteBatch.Name.NullObjects, 4);
            SpriteBatch pTexts        = SpriteBatchManager.Add(SpriteBatch.Name.Texts, 5);

            pBoxBatch.SetDrawBool(false);

            //---------------------------------------------------------------------------------------------------------
            // Input
            //---------------------------------------------------------------------------------------------------------
            this.poInputManager = new InputManager();
            InputManager.SetActive(this.poInputManager);

            InputSubject pInputSubject;

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

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

            pInputSubject = InputManager.GetSpaceSubject();
            pInputSubject.Attach(new ShootObserver());
            pInputSubject.Attach(new ShootSoundObserver());

            pInputSubject = InputManager.GetCKeySubject();
            pInputSubject.Attach(new ToggleCollisionBoxObserver());

            Simulation.SetState(Simulation.State.Realtime);
            //---------------------------------------------------------------------------------------------------------
            // Create Texts
            //---------------------------------------------------------------------------------------------------------

            this.poFontManager = new FontManager(3, 1);
            FontManager.SetActive(this.poFontManager);

            FontManager.Add(Font.Name.Header, SpriteBatch.Name.Texts, "SCORE<1>       HI-SCORE       SCORE<2>", 20f, SpaceInvaders.ScreenHeight - 20f, 15f, 25f);
            FontManager.Add(Font.Name.Player1Score, SpriteBatch.Name.Texts, "0000", 65f, SpaceInvaders.ScreenHeight - 70f, 15f, 25f);
            FontManager.Add(Font.Name.Player2Score, SpriteBatch.Name.Texts, "0000", SpaceInvaders.ScreenWidth - 156f, SpaceInvaders.ScreenHeight - 70f, 15f, 25f);
            FontManager.Add(Font.Name.HiScore, SpriteBatch.Name.Texts, "0000", 380f, SpaceInvaders.ScreenHeight - 70f, 15f, 25f);
            FontManager.Add(Font.Name.Lives, SpriteBatch.Name.Texts, "3", 40f, 40f, 15f, 25f);


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

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

            pWallGroup.ActivateGameSprite(pAliensBatch);//even need this?
            pWallGroup.ActivateCollisionSprite(pBoxBatch);

            WallRight pWallRight = new WallRight(GameObject.Name.WallRight, GameSprite.Name.NullObject, SpaceInvaders.ScreenWidth - 15, SpaceInvaders.ScreenHeight / 2, 20, SpaceInvaders.ScreenHeight - 110);

            pWallRight.ActivateCollisionSprite(pBoxBatch);

            WallLeft pWallLeft = new WallLeft(GameObject.Name.WallLeft, GameSprite.Name.NullObject, 20, SpaceInvaders.ScreenHeight / 2, 20, SpaceInvaders.ScreenHeight - 110);

            pWallLeft.ActivateCollisionSprite(pBoxBatch);

            WallTop pWallTop = new WallTop(GameObject.Name.WallTop, GameSprite.Name.NullObject, 450, SpaceInvaders.ScreenHeight - 70, SpaceInvaders.ScreenWidth - 10, 30);

            pWallTop.ActivateCollisionSprite(pBoxBatch);

            WallBottom pWallBottom = new WallBottom(GameObject.Name.WallBottom, GameSprite.Name.Ground, 450, 60, SpaceInvaders.ScreenWidth - 10, 5);

            pWallBottom.ActivateGameSprite(pAliensBatch);
            pWallBottom.ActivateCollisionSprite(pBoxBatch);

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

            GameObjectManager.Attach(pWallGroup);

            //---------------------------------------------------------------------------------------------------------
            // Create Bomb Root
            //---------------------------------------------------------------------------------------------------------

            BombRoot pBombRoot = new BombRoot(GameObject.Name.BombRoot, GameSprite.Name.NullObject, 0.0f, 0.0f);

            pBombRoot.ActivateGameSprite(pAliensBatch);//change? even need this?
            pBombRoot.ActivateCollisionSprite(pBoxBatch);

            GameObjectManager.Attach(pBombRoot);

            DropBombEvent pBombEvent = new DropBombEvent();

            TimerManager.Add(TimeEvent.Name.DropBomb, pBombEvent, 3.0f);

            //---------------------------------------------------------------------------------------------------------
            // Create Missile Root
            //---------------------------------------------------------------------------------------------------------

            // Missile Root
            MissileGroup pMissileGroup = new MissileGroup(GameObject.Name.MissileGroup, GameSprite.Name.NullObject, 0.0f, 0.0f);

            pMissileGroup.ActivateGameSprite(pAliensBatch);//change? even need this?
            pMissileGroup.ActivateCollisionSprite(pBoxBatch);

            GameObjectManager.Attach(pMissileGroup);

            //---------------------------------------------------------------------------------------------------------
            // Create Ship Root
            //---------------------------------------------------------------------------------------------------------

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

            pShipRoot.ActivateGameSprite(pAliensBatch);//change? even need this?
            pShipRoot.ActivateCollisionSprite(pBoxBatch);

            GameObjectManager.Attach(pShipRoot);

            ShipManager.ActivateShip();
            ShipManager.ActivateMissile();

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

            pUFORoot.ActivateGameSprite(pAliensBatch);//change? even need this?
            pUFORoot.ActivateCollisionSprite(pBoxBatch);

            GameObjectManager.Attach(pUFORoot);

            OrangeSaucer pUFO = new OrangeSaucer(GameObject.Name.OrangeSaucer, GameSprite.Name.OrangeSaucer, 20f, SpaceInvaders.ScreenHeight - 110f);

            pUFO.ActivateGameSprite(pAliensBatch);//change? even need this?
            pUFO.ActivateCollisionSprite(pBoxBatch);

            pUFORoot.Add(pUFO);
            pUFO.Remove();


            SpawnUFOEvent pUFOEvent = new SpawnUFOEvent();

            TimerManager.Add(TimeEvent.Name.UFOSpawn, pUFOEvent, RandomManager.RandomInt(15, 45));

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

            AlienFactory AF         = new AlienFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes);
            AlienGrid    pAlienGrid = (AlienGrid)AF.Create(GameObject.Name.AlienGrid);


            for (int i = 0; i < 11; i++)
            {
                GameObject pCol = AF.Create(GameObject.Name.AlienColumn);
                GameObject pGameObject;
                pGameObject = AF.Create(GameObject.Name.PurpleOctopus, 50.0f + 66 * i, SpaceInvaders.ScreenHeight - 364f);
                pCol.Add(pGameObject);

                pGameObject = AF.Create(GameObject.Name.PurpleOctopus, 50.0f + 66 * i, SpaceInvaders.ScreenHeight - 298f);
                pCol.Add(pGameObject);

                pGameObject = AF.Create(GameObject.Name.BlueCrab, 50.0f + 66 * i, SpaceInvaders.ScreenHeight - 232f);
                pCol.Add(pGameObject);

                pGameObject = AF.Create(GameObject.Name.BlueCrab, 50.0f + 66 * i, SpaceInvaders.ScreenHeight - 166f);
                pCol.Add(pGameObject);

                pGameObject = AF.Create(GameObject.Name.GreenSquid, 50.0f + 66 * i, SpaceInvaders.ScreenHeight - 100f);
                pCol.Add(pGameObject);

                pAlienGrid.Add(pCol);
            }
            GameObjectManager.Attach(pAlienGrid);

            pAlienGrid.Attach(new MoveAlienSoundObserver());
            pAlienGrid.Attach(new MoveAlienGridObserver());

            AlienGridMoveEvent pGridMoveEvent = new AlienGridMoveEvent();

            TimerManager.Add(TimeEvent.Name.MoveAlienGrid, pGridMoveEvent, pAlienGrid.GetMoveRate());

            //---------------------------------------------------------------------------------------------------------
            // Timer Animations
            //---------------------------------------------------------------------------------------------------------

            // Create an animation sprite
            AnimationSprite pAnimOctopus = new AnimationSprite(GameSprite.Name.PurpleOctopus);
            AnimationSprite pAnimCrab    = new AnimationSprite(GameSprite.Name.BlueCrab);
            AnimationSprite pAnimSquid   = new AnimationSprite(GameSprite.Name.GreenSquid);

            // attach several images to cycle

            pAnimOctopus.Attach(Image.Name.OctopusA);
            pAnimOctopus.Attach(Image.Name.OctopusB);

            pAnimCrab.Attach(Image.Name.AlienA);
            pAnimCrab.Attach(Image.Name.AlienB);

            pAnimSquid.Attach(Image.Name.SquidA);
            pAnimSquid.Attach(Image.Name.SquidB);

            // add AnimationSprite to timer
            TimerManager.Add(TimeEvent.Name.SpriteAnimation, pAnimOctopus, pAlienGrid.GetMoveRate());
            TimerManager.Add(TimeEvent.Name.SpriteAnimation, pAnimCrab, pAlienGrid.GetMoveRate());
            TimerManager.Add(TimeEvent.Name.SpriteAnimation, pAnimSquid, pAlienGrid.GetMoveRate());

            //---------------------------------------------------------------------------------------------------------
            // Shield
            //---------------------------------------------------------------------------------------------------------

            // Create the factory
            Composite pShieldRoot = (Composite) new ShieldRoot(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, 0.0f, 0.0f);

            GameObjectManager.Attach(pShieldRoot);
            ShieldFactory SF = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.Boxes, pShieldRoot);

            float start_x = 160.0f;
            float start_y = 200.0f;
            float off_x;
            float brickWidth  = 12.0f;
            float brickHeight = 7.0f;

            GameObject pShieldGrid;
            GameObject pShieldCol;

            for (int i = 0; i < 4; i++)
            {
                off_x = 0;
                SF.SetParent(pShieldRoot);
                pShieldGrid = SF.Create(GameObject.Name.ShieldGrid);

                //------Col1
                SF.SetParent(pShieldGrid);
                pShieldCol = SF.Create(GameObject.Name.ShieldColumn);
                SF.SetParent(pShieldCol);

                SF.Create(GameObject.Name.ShieldBrick, start_x, start_y);
                SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 2 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 3 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 4 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 5 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 6 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 7 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick_LeftTop1, start_x, start_y + 8 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick_LeftTop0, start_x, start_y + 9 * brickHeight);

                //-------Col2
                SF.SetParent(pShieldGrid);
                pShieldCol = SF.Create(GameObject.Name.ShieldColumn);
                SF.SetParent(pShieldCol);

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

                //-------Col3
                SF.SetParent(pShieldGrid);
                pShieldCol = SF.Create(GameObject.Name.ShieldColumn);
                SF.SetParent(pShieldCol);

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

                //-------Col4
                SF.SetParent(pShieldGrid);
                pShieldCol = SF.Create(GameObject.Name.ShieldColumn);
                SF.SetParent(pShieldCol);

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

                //-------Col5
                SF.SetParent(pShieldGrid);
                pShieldCol = SF.Create(GameObject.Name.ShieldColumn);
                SF.SetParent(pShieldCol);

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

                //-------Col6
                SF.SetParent(pShieldGrid);
                pShieldCol = SF.Create(GameObject.Name.ShieldColumn);
                SF.SetParent(pShieldCol);

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

                //-------Col7
                SF.SetParent(pShieldGrid);
                pShieldCol = SF.Create(GameObject.Name.ShieldColumn);
                SF.SetParent(pShieldCol);

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

                start_x += 170;
            }


            //---------------------------------------------------------------------------------------------------------
            // Create Null Ship Lives
            //---------------------------------------------------------------------------------------------------------

            ScenePlay.ShipLives = 3;

            PlayerLivesComposite pNullObjs = new PlayerLivesComposite();

            Ship pNullShip1 = new Ship(GameObject.Name.Null_Object, GameSprite.Name.Ship, 120.0f, 40.0f);

            pNullShip1.ActivateGameSprite(pNullBatch);
            pNullObjs.Add(pNullShip1);

            Ship pNullShip2 = new Ship(GameObject.Name.Null_Object, GameSprite.Name.Ship, 180.0f, 40.0f);

            pNullShip2.ActivateGameSprite(pNullBatch);
            pNullObjs.Add(pNullShip2);

            GameObjectManager.Attach(pNullObjs);

            //---------------------------------------------------------------------------------------------------------
            // Create CollisionPairs
            //---------------------------------------------------------------------------------------------------------

            //Why does the order that left/right wall are added matter??????? reverse order breaks game
            CollisionPair pShipWallRightPair = CollisionPairManager.Add(CollisionPair.Name.Ship_Wall_Right, pShipRoot, pWallRight);

            Debug.Assert(pShipWallRightPair != null);

            CollisionPair pShipWallLeftPair = CollisionPairManager.Add(CollisionPair.Name.Ship_Wall_Left, pShipRoot, pWallLeft);

            Debug.Assert(pShipWallLeftPair != null);

            CollisionPair pAlienMissilePair = CollisionPairManager.Add(CollisionPair.Name.Alien_Missile, pMissileGroup, pAlienGrid);

            Debug.Assert(pAlienMissilePair != null);

            CollisionPair pMissileWallPair = CollisionPairManager.Add(CollisionPair.Name.Missile_Wall_Top, pMissileGroup, pWallTop);

            Debug.Assert(pMissileWallPair != null);

            CollisionPair pAlienWallPair = CollisionPairManager.Add(CollisionPair.Name.Alien_Wall, pAlienGrid, pWallGroup);

            Debug.Assert(pAlienWallPair != null);

            CollisionPair pAlienWallBottomPair = CollisionPairManager.Add(CollisionPair.Name.Alien_WallBottom, pAlienGrid, pWallBottom);

            Debug.Assert(pAlienWallBottomPair != null);

            CollisionPair pBombWallPair = CollisionPairManager.Add(CollisionPair.Name.Bomb_Wall_Bottom, pBombRoot, pWallBottom);

            Debug.Assert(pBombWallPair != null);

            CollisionPair pBombShieldPair = CollisionPairManager.Add(CollisionPair.Name.Bomb_Shield, pBombRoot, pShieldRoot);

            Debug.Assert(pBombShieldPair != null);

            CollisionPair pMissileShieldPair = CollisionPairManager.Add(CollisionPair.Name.Missile_Shield, pMissileGroup, pShieldRoot);

            Debug.Assert(pMissileShieldPair != null);

            CollisionPair pBombShipPair = CollisionPairManager.Add(CollisionPair.Name.Bomb_Ship, pBombRoot, ShipManager.GetShip());

            Debug.Assert(pBombShipPair != null);

            CollisionPair pBombMissilePair = CollisionPairManager.Add(CollisionPair.Name.Bomb_Missile, pBombRoot, ShipManager.GetMissile());

            Debug.Assert(pBombMissilePair != null);

            CollisionPair pAlienShieldPair = CollisionPairManager.Add(CollisionPair.Name.Alien_Shield, pShieldRoot, pAlienGrid);

            Debug.Assert(pAlienShieldPair != null);

            CollisionPair pUFOMissilePair = CollisionPairManager.Add(CollisionPair.Name.UFO_Missile, pMissileGroup, pUFORoot);

            Debug.Assert(pUFOMissilePair != null);

            //TODO consolidate these news
            pShipWallLeftPair.Attach(new ShipStopLeftObserver());
            pShipWallRightPair.Attach(new ShipStopRightObserver());

            pMissileWallPair.Attach(new ShipRemoveMissileObserver());

            pAlienMissilePair.Attach(new ShipRemoveMissileObserver());
            pAlienMissilePair.Attach(new RemoveAlienObserver());
            pAlienMissilePair.Attach(new DeadAlienSoundObserver());
            pAlienMissilePair.Attach(new AddP1PointsObserver());
            pAlienMissilePair.Attach(new IncreaseAlienSpeedObserver());

            pAlienWallPair.Attach(new GridObserver());

            pBombWallPair.Attach(new RemoveBombObserver());

            pBombShieldPair.Attach(new RemoveBombObserver());
            pBombShieldPair.Attach(new RemoveBrickObserver());

            pMissileShieldPair.Attach(new ShipRemoveMissileObserver());
            pMissileShieldPair.Attach(new RemoveBrickObserver());

            pBombShipPair.Attach(new RemoveBombObserver());
            pBombShipPair.Attach(new RemoveShipObserver());
            pBombShipPair.Attach(new DeadShipSoundObserver());
            pBombShipPair.Attach(new RemoveLifeObserver());
            pBombShipPair.Attach(new ChangeStateObserver());

            pBombMissilePair.Attach(new RemoveBombObserver());
            pBombMissilePair.Attach(new ShipRemoveMissileObserverAltPair());

            pAlienShieldPair.Attach(new RemoveBrickObserver());

            pUFOMissilePair.Attach(new RemoveUFOObserver());
            pUFOMissilePair.Attach(new ShipRemoveMissileObserver());
            pUFOMissilePair.Attach(new AddP1PointsObserver());
            pUFOMissilePair.Attach(new DeadUFOSoundObserver());

            pAlienWallBottomPair.Attach(new DeadShipSoundObserver());
            pAlienWallBottomPair.Attach(new RemoveAllP1LivesObserver());
        }
Exemple #2
0
        private ShieldRoot GenerateShield(PCSTree pRootTree, float startX, float startY, int idx)
        {
            ShieldRoot pShieldRoot = new ShieldRoot(GameObjectName.ShieldRoot, SpriteBaseName.Null, 0.0f, 0.0f, idx);

            pRootTree.Insert(pShieldRoot, null);
            GameObjectManager.AttachTree(pShieldRoot);
            ShieldFactory shieldFactory = new ShieldFactory(SpriteBatchName.Shields, SpriteBatchName.Boxes, pRootTree);

            shieldFactory.SetParent(pShieldRoot);
            ShieldCategory pShieldGrid = shieldFactory.Create(ShieldType.Grid, GameObjectName.ShieldGrid);

            int            j = 0;
            ShieldCategory pCol;

            shieldFactory.SetParent(pShieldGrid);
            pCol = shieldFactory.Create(ShieldType.Column, GameObjectName.ShieldColumn, j++);
            shieldFactory.SetParent(pCol);

            int i = 0;

            float start_x     = startX;
            float start_y     = startY;
            float off_x       = 0;
            float brickWidth  = 15.0f;
            float brickHeight = 10.0f;

            for (int x = 0; x < 8; x++)
            {
                shieldFactory.Create(ShieldType.Brick, GameObjectName.ShieldBrick, start_x, start_y + x * brickHeight, i++);
            }
            shieldFactory.Create(ShieldType.LeftTop1, GameObjectName.ShieldBrick, start_x, start_y + 8 * brickHeight, i++);
            shieldFactory.Create(ShieldType.LeftTop0, GameObjectName.ShieldBrick, start_x, start_y + 9 * brickHeight, i++);
            shieldFactory.SetParent(pShieldGrid);
            pCol = shieldFactory.Create(ShieldType.Column, GameObjectName.Column, j++);
            shieldFactory.SetParent(pCol);

            off_x += brickWidth;
            for (int x = 0; x < 10; x++)
            {
                shieldFactory.Create(ShieldType.Brick, GameObjectName.ShieldBrick, start_x + off_x, start_y + x * brickHeight, i++);
            }
            shieldFactory.SetParent(pShieldGrid);
            pCol = shieldFactory.Create(ShieldType.Column, GameObjectName.Column, j++);
            shieldFactory.SetParent(pCol);

            off_x += brickWidth;
            shieldFactory.Create(ShieldType.LeftBottom, GameObjectName.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight);
            for (int x = 3; x < 10; x++)
            {
                shieldFactory.Create(ShieldType.Brick, GameObjectName.ShieldBrick, start_x + off_x, start_y + x * brickHeight, i++);
            }
            shieldFactory.SetParent(pShieldGrid);
            pCol = shieldFactory.Create(ShieldType.Column, GameObjectName.Column, j++);
            shieldFactory.SetParent(pCol);

            off_x += brickWidth;
            for (int x = 3; x < 10; x++)
            {
                shieldFactory.Create(ShieldType.Brick, GameObjectName.ShieldBrick, start_x + off_x, start_y + x * brickHeight, i++);
            }
            shieldFactory.SetParent(pShieldGrid);
            pCol = shieldFactory.Create(ShieldType.Column, GameObjectName.Column, j++);
            shieldFactory.SetParent(pCol);

            off_x += brickWidth;
            shieldFactory.Create(ShieldType.RightBottom, GameObjectName.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight, i++);
            for (int x = 3; x < 10; x++)
            {
                shieldFactory.Create(ShieldType.Brick, GameObjectName.ShieldBrick, start_x + off_x, start_y + x * brickHeight, i++);
            }
            shieldFactory.SetParent(pShieldGrid);
            pCol = shieldFactory.Create(ShieldType.Column, GameObjectName.Column, j++);
            shieldFactory.SetParent(pCol);

            off_x += brickWidth;
            for (int x = 0; x < 10; x++)
            {
                shieldFactory.Create(ShieldType.Brick, GameObjectName.ShieldBrick, start_x + off_x, start_y + x * brickHeight, i++);
            }
            shieldFactory.SetParent(pShieldGrid);
            pCol = shieldFactory.Create(ShieldType.Column, GameObjectName.Column, j++);
            shieldFactory.SetParent(pCol);

            off_x += brickWidth;
            for (int x = 0; x < 8; x++)
            {
                shieldFactory.Create(ShieldType.Brick, GameObjectName.ShieldBrick, start_x + off_x, start_y + x * brickHeight, i++);
            }
            shieldFactory.Create(ShieldType.RightTop1, GameObjectName.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
            shieldFactory.Create(ShieldType.RightTop0, GameObjectName.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

            return(pShieldRoot);
        }
        //need to create the root node first before using
        public static void ShieldCreator(float startX, float startY, GameObject.Name shieldName)
        {
            Composite pShieldRoot = (Composite)GONodeMan.Find(GameObject.Name.ShieldRoot);

            Debug.Assert(pShieldRoot != null);

            ShieldFactory SF = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.Boxes, pShieldRoot);

            GameObject pShieldGrid;

            SF.SetParent(pShieldRoot);
            pShieldGrid = SF.Create(ShieldCategory.Type.Grid, shieldName);

            //j represents the columns
            int j = 0;

            GameObject pShieldColumn;

            SF.SetParent(pShieldGrid);
            pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_1 + j++);

            SF.SetParent(pShieldColumn);

            float start_x     = startX;
            float start_y     = startY;
            float off_x       = 0;
            float brickWidth  = 10.0f;
            float brickHeight = 5.0f;


            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.LeftTop2, GameObject.Name.ShieldBrick, start_x, start_y + 8 * brickHeight);
            SF.Create(ShieldCategory.Type.LeftTop1, GameObject.Name.ShieldBrick, start_x, start_y + 9 * brickHeight);

            SF.SetParent(pShieldGrid);
            pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_1 + j++);

            SF.SetParent(pShieldColumn);

            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);
            pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_1 + j++);

            SF.SetParent(pShieldColumn);

            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);
            pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_1 + j++);

            SF.SetParent(pShieldColumn);

            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);
            pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_1 + j++);

            SF.SetParent(pShieldColumn);

            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);
            pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_1 + j++);

            SF.SetParent(pShieldColumn);

            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);
            pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_1 + j++);

            SF.SetParent(pShieldColumn);

            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.RightTop2, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
            SF.Create(ShieldCategory.Type.RightTop1, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);
        }
Exemple #4
0
        public static GameObject RecreateShield(float start_x = 0.0f, float start_y = 0.0f)
        {
            GhostManager      pGhostManager      = GameStateManager.GetGame().GetStateGhostManager();
            GameObjectManager pGameObjectManager = GameStateManager.GetGame().GetStateGameObjectManager();

            Composite pShieldRoot = (Composite)pGhostManager.Find(GameObject.Name.ShieldRoot);

            pGhostManager.Detach(pShieldRoot);

            GameStateManager.GetGame().GetStateGameObjectManager().Attach(pShieldRoot);
            pShieldRoot.ActivateSprite(GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.Shield));
            pShieldRoot.ActivateCollisionSprite(GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.CollisionBox));

            ShieldFactory SF = new ShieldFactory(SpriteBatch.Name.Shield, SpriteBatch.Name.CollisionBox, pShieldRoot);

            // load by column

            GameObject pColumn;

            SF.SetParent(pShieldRoot);
            pColumn = SF.Recreate(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn);

            SF.SetParent(pColumn);

            float off_x       = 0;
            float brickWidth  = 12.0f;
            float brickHeight = 6.0f;

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

            SF.SetParent(pShieldRoot);
            pColumn = SF.Recreate(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn);

            SF.SetParent(pColumn);

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

            SF.SetParent(pShieldRoot);
            pColumn = SF.Recreate(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn);

            SF.SetParent(pColumn);

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

            SF.SetParent(pShieldRoot);
            pColumn = SF.Recreate(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn);

            SF.SetParent(pColumn);

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

            SF.SetParent(pShieldRoot);
            pColumn = SF.Recreate(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn);

            SF.SetParent(pColumn);

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

            SF.SetParent(pShieldRoot);
            pColumn = SF.Recreate(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn);

            SF.SetParent(pColumn);

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

            SF.SetParent(pShieldRoot);
            pColumn = SF.Recreate(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn);

            SF.SetParent(pColumn);

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

            return(pShieldRoot);
        }
        //public ShieldGroupFactory()
        //{
        //}

        public static Composite Create(float startPosX, float startPosY, GameObjectMan pGameObjectMan)
        {
            //if (shieldsCreated == false)
            //{
            pShieldRoot = (Composite) new ShieldRoot(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, 0.0f, 0.0f);
            GameObjectMan.Attach(pShieldRoot);

            ShieldFactory SF = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.Boxes, pShieldRoot);

            float start_x = startPosX;
            float start_y = startPosY;

            // load by column
            for (int i = 0; i < 4; i++)
            {
                int j = 0;

                GameObject pColumn;

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

                SF.SetParent(pColumn);

                start_x = 100.0f + i * 170;

                float off_x       = 0;
                float brickWidth  = 15.0f;
                float brickHeight = 6.0f;

                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(pShieldRoot);
                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(pShieldRoot);
                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(pShieldRoot);
                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(pShieldRoot);
                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(pShieldRoot);
                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(pShieldRoot);
                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);
            }

            //    shieldsCreated = true;
            //}

            return(pShieldRoot);
        }
        // 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());
        }