Example #1
0
        // Should be called at some point before leaving state
        public override void CleanUp(GameManager pGameManager)
        {
            GameManager.PushHighScoreToFont();

            ShipManager.Purge();

            TimerManager.PurgeAllNodes();
            GameObjectManager.PurgeAllNodes();

            SpriteBatch pSBatch = SpriteBatchManager.Find(SpriteBatch.Name.Boxes);

            pSBatch.GetSBNodeManager().PurgeAllNodes();
            pSBatch = SpriteBatchManager.Find(SpriteBatch.Name.Sprites);
            pSBatch.GetSBNodeManager().PurgeAllNodes();

            ColPairManager.PurgeAllNodes();

            DelayedObjectManager.PurgeAll();

            InputSubject pInputSubject = InputManager.GetArrowLeftSubject();

            pInputSubject.PurgeAll();

            pInputSubject = InputManager.GetArrowRightSubject();
            pInputSubject.PurgeAll();

            pInputSubject = InputManager.GetSpaceSubject();
            pInputSubject.PurgeAll();


            Handle(pGameManager);
        }
Example #2
0
        // Should be called at some point after enter a new state
        public override void Initialize(GameManager pGameManager)
        {
            //Debug.WriteLine("Initializing the GamePlay State in {0}", pGameManager.gameMode);

            Font pCredits      = FontManager.Find(Font.Name.Credits);
            Font pScoreHeader1 = FontManager.Find(Font.Name.ScoreHeader1);
            Font pScoreHeader2 = FontManager.Find(Font.Name.ScoreHeader2);

            pScoreHeader1.UpdateMessage("*SCORE<1>*");
            pScoreHeader2.UpdateMessage(" SCORE<2> ");
            LivesManager.DisplayLives(3);

            //---------------------------------------------------------------------------------------------------------
            // Create the player ship and missile
            //---------------------------------------------------------------------------------------------------------
            ShipManager.Create();

            pGameManager.SetActivePlayer(PlayerArtifact.Name.PlayerOne);
            pGameManager.pActiveGameModeStrategy.InitializeLevel(pGameManager);
            pGameManager.poPlayer1.RestoreManagerStates(pGameManager.pGame.GetTime());

            //---------------------------------------------------------------------------------------------------------
            // Add Keyboard Input Observers
            //---------------------------------------------------------------------------------------------------------
            InputSubject pInputSubject = InputManager.GetArrowLeftSubject();

            pInputSubject.Attach(new MoveLeftObserver());

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

            pInputSubject = InputManager.GetSpaceSubject();
            pInputSubject.Attach(new ShootObserver());
        }
Example #3
0
        public static void LoadKeyInputObservers()
        {
            InputSubject inputSubject;

            //CollisionBoxToggle;
            //inputSubject = InputManager.Get_C_KeySubject();
            //inputSubject.Attach(new ToggleCollisionBoxObserver());

            //left arrow key;
            inputSubject = InputManager.GetArrowRightSubject();
            MoveRightObserver pMR_Observer = new MoveRightObserver();

            inputSubject.Attach(pMR_Observer);
            DeathManager.Attach(pMR_Observer);

            //right arrow key;
            inputSubject = InputManager.GetArrowLeftSubject();
            MoveLeftObserver pML_Observer = new MoveLeftObserver();

            inputSubject.Attach(pML_Observer);
            DeathManager.Attach(pML_Observer);

            //Spacebar;
            inputSubject = InputManager.GetSpaceSubject();
            ShootMissileObserver pShoot_Observer = new ShootMissileObserver();

            inputSubject.Attach(pShoot_Observer);
            DeathManager.Attach(pShoot_Observer);


            //C Key;
            inputSubject = InputManager.GetCKeySubject();
            ToggleBoxSpriteObserver pToggleBoxSprites = new ToggleBoxSpriteObserver();

            inputSubject.Attach(pToggleBoxSprites);
            DeathManager.Attach(pToggleBoxSprites);


            //T Key - TestObserver allows debugging certain game actions by pressing the 't' key
            //call any functions within the TestObserver class
            //example: press T key to test pulling a new ship after old one is destroyed and/or triggering a game over;
            inputSubject = InputManager.GetTKeySubject();
            TestInputObserver pTestObserverAction = new TestInputObserver();

            inputSubject.Attach(pTestObserverAction);
            DeathManager.Attach(pTestObserverAction);
        }
        public override void DetachInputObservers()
        {
            InputSubject pInputSubject;

            pInputSubject = InputManager.GetArrowRightSubject();
            pInputSubject.DetachAllObservers();

            pInputSubject = InputManager.GetArrowLeftSubject();
            pInputSubject.DetachAllObservers();

            pInputSubject = InputManager.GetSpaceSubject();
            pInputSubject.DetachAllObservers();

            pInputSubject = InputManager.GetKey1Subject();
            pInputSubject.DetachAllObservers();

            pInputSubject = InputManager.GetKey2Subject();
            pInputSubject.DetachAllObservers();
        }
        public override void AttachInputObservers()
        {
            InputSubject pInputSubject;

            // TODO Remove -- Testing
            pInputSubject = InputManager.GetKeyNSubject();
            pInputSubject.Attach(new ChangeGameStateObserver());

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

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

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

            pInputSubject = InputManager.GetKey1Subject();
            pInputSubject.Attach(new ToggleSpriteBatchDrawObserver(pCollisionBox_SpriteBatch));

            pInputSubject = InputManager.GetKey2Subject();
            pInputSubject.Attach(new ToggleSpriteBatchDrawObserver(pShield_SpriteBatch));
        }
Example #6
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());
        }
Example #7
0
        public Game()
        {   // Demo/Select Screen
            this.roundNum = 1;
            TextureManager.Create(2, 2);
            ImageManager.Create(5, 2);
            SpriteManager.Create(5, 2);
            SpriteBoxManager.Create(1, 1);
            SpriteBatchManager.Create(2, 1);
            TimerManager.Create(3, 1);
            GameObjectManager.Create(3, 1);
            ProxySpriteManager.Create(10, 5);
            CollisionPairManager.Create(2, 1);
            SoundManager.Create(9, 1);
            FontManager.Create(26, 10);
            ScoreManager.Initialize();

            //---------------------------------------------------------------------------------------------------------
            // Load Textures
            //---------------------------------------------------------------------------------------------------------
            Texture pSpritesTexture = TextureManager.Add(TextureName.Sprites, "Sprites.tga");
            Texture pShieldTexture  = TextureManager.Add(TextureName.Shields, "Shield.tga");

            TextureManager.Add(TextureName.Consolas36pt, "consolas36pt.tga");
            FontManager.AddXml("Consolas36pt.xml", FontName.Consolas36pt, TextureName.Consolas36pt);

            //---------------------------------------------------------------------------------------------------------
            // Load Sounds
            //---------------------------------------------------------------------------------------------------------
            SoundManager.Add(SoundName.explosion);
            SoundManager.Add(SoundName.fastInvader1);
            SoundManager.Add(SoundName.fastInvader2);
            SoundManager.Add(SoundName.fastInvader3);
            SoundManager.Add(SoundName.fastInvader4);
            SoundManager.Add(SoundName.invaderKilled);
            SoundManager.Add(SoundName.shoot);
            SoundManager.Add(SoundName.ufoHighPitch);
            SoundManager.Add(SoundName.ufoLowPitch);

            //---------------------------------------------------------------------------------------------------------
            // Create SpriteBatches
            //---------------------------------------------------------------------------------------------------------
            SpriteBatch sbAliens  = SpriteBatchManager.Add(SpriteBatchName.Aliens);
            SpriteBatch sbBoxes   = SpriteBatchManager.Add(SpriteBatchName.Boxes);
            SpriteBatch sbShips   = SpriteBatchManager.Add(SpriteBatchName.Ships);
            SpriteBatch sbSplats  = SpriteBatchManager.Add(SpriteBatchName.Splats);
            SpriteBatch sbShields = SpriteBatchManager.Add(SpriteBatchName.Shields);
            SpriteBatch sbFonts   = SpriteBatchManager.Add(SpriteBatchName.Fonts);

            InitializeImageManager();

            //---------------------------------------------------------------------------------------------------------
            // Create Sprites
            //---------------------------------------------------------------------------------------------------------
            SpriteManager.Add(SpriteBaseName.UFO, ImageName.UFO, 200.0f, 200.0f, 50.0f, 50.0f);
            SpriteManager.Add(SpriteBaseName.UFOBomb, ImageName.Missile, 100.0f, 700.0f, 5.0f, 32.0f);
            SpriteManager.Add(SpriteBaseName.Squid, ImageName.SquidA, 100.0f, 800.0f, 50.0f, 50.0f);
            SpriteManager.Add(SpriteBaseName.Crab, ImageName.CrabA, 100.0f, 750.0f, 50.0f, 50.0f);
            SpriteManager.Add(SpriteBaseName.Octopus, ImageName.OctopusA, 100.0f, 700.0f, 50.0f, 50.0f);
            SpriteManager.Add(SpriteBaseName.Ship, ImageName.Ship, 100.0f, 700.0f, 50.0f, 50.0f);
            SpriteManager.Add(SpriteBaseName.Missile, ImageName.Missile, 100.0f, 700.0f, 5.0f, 32.0f);
            SpriteManager.Add(SpriteBaseName.BombStraight, ImageName.BombStraightA, 100.0f, 100.0f, 10.0f, 60.0f);
            SpriteManager.Add(SpriteBaseName.BombDagger, ImageName.BombDaggerA, 100.0f, 100.0f, 20.0f, 60.0f);
            SpriteManager.Add(SpriteBaseName.BombZigZag, ImageName.BombZigZagA, 200.0f, 200.0f, 20.0f, 60.0f);
            SpriteManager.Add(SpriteBaseName.Brick, ImageName.Brick, 50.0f, 25.0f, 40.0f, 20.0f);
            SpriteManager.Add(SpriteBaseName.BrickLeftTop0, ImageName.BrickLeftTop0, 50.0f, 25.0f, 40.0f, 20.0f);
            SpriteManager.Add(SpriteBaseName.BrickLeftTop1, ImageName.BrickLeftTop1, 50.0f, 25.0f, 40.0f, 20.0f);
            SpriteManager.Add(SpriteBaseName.BrickLeftBottom, ImageName.BrickLeftBottom, 50.0f, 25.0f, 40.0f, 20.0f);
            SpriteManager.Add(SpriteBaseName.BrickRightTop0, ImageName.BrickRightTop0, 50.0f, 25.0f, 40.0f, 20.0f);
            SpriteManager.Add(SpriteBaseName.BrickRightTop1, ImageName.BrickRightTop1, 50.0f, 25.0f, 40.0f, 20.0f);
            SpriteManager.Add(SpriteBaseName.BrickRightBottom, ImageName.BrickRightBottom, 50.0f, 25.0f, 40.0f, 20.0f);
            SpriteManager.Add(SpriteBaseName.Splat, ImageName.AlienExplosion, 200.0f, 200.0f, 50.0f, 50.0f);
            SpriteManager.Add(SpriteBaseName.Explosion, ImageName.ShipExplosion, 200.0f, 200.0f, 50.0f, 50.0f);

            // Input
            InputSubject inputSubject;

            inputSubject = InputManager.GetOneSubject();
            inputSubject.RegisterObserver(new OnePlayerObserver());

            inputSubject = InputManager.GetArrowLeftSubject();
            inputSubject.RegisterObserver(new MoveLeftObserver());

            inputSubject = InputManager.GetArrowRightSubject();
            inputSubject.RegisterObserver(new MoveRightObserver());

            inputSubject = InputManager.GetSpaceSubject();
            inputSubject.RegisterObserver(new ShootObserver());
            //inputSubject = InputManager.GetTwoSubject();
            //inputSubject.RegisterObserver(new TwoPlayerObserver());

            TimerManager.Add(TimerEventName.SetGameState, TimerManager.GetCurrentTime() + 5.0f, TimerManager.GetCurrentTime() + 5.0f, new GameSelectEvent());
        }
Example #8
0
        public override void LoadContent()
        {
            // -----------------------------------------------------------------------------
            // ---------------------- Sound Setup ------------------------------------------
            // -----------------------------------------------------------------------------

            SoundManager.Add(Sound.Name.Fastinvader1, "fastinvader1.wav");
            SoundManager.Add(Sound.Name.Fastinvader2, "fastinvader2.wav");
            SoundManager.Add(Sound.Name.Fastinvader3, "fastinvader3.wav");
            SoundManager.Add(Sound.Name.Fastinvader4, "fastinvader4.wav");
            SoundManager.Add(Sound.Name.Shoot, "shoot.wav");
            SoundManager.Add(Sound.Name.Explosion, "explosion.wav");
            SoundManager.Add(Sound.Name.InvaderKilled, "invaderkilled.wav");
            SoundManager.Add(Sound.Name.UFO_HighPitch, "ufo_highpitch.wav");
            SoundManager.Add(Sound.Name.UFO_LowPitch, "ufo_lowpitch.wav");


            // -----------------------------------------------------------------------------
            // ------------------- Load the Textures ---------------------------------------
            // -----------------------------------------------------------------------------

            TextureManager.Add(Texture.Name.SpaceInvaders, "SpaceInvaders.tga");
            TextureManager.Add(Texture.Name.Invaders, "birds_N_shield.tga");
            Texture pTexture = TextureManager.Add(Texture.Name.Consolas36pt, "Consolas36pt.tga");

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

            // -----------------------------------------------------------------------------
            // -------------------- Creating Images ----------------------------------------
            // -----------------------------------------------------------------------------

            ImageManager.Add(Image.Name.OctopusA, Texture.Name.SpaceInvaders, 3, 3, 12, 8);
            ImageManager.Add(Image.Name.OctopusB, Texture.Name.SpaceInvaders, 18, 3, 12, 8);
            ImageManager.Add(Image.Name.AlienA, Texture.Name.SpaceInvaders, 33, 3, 11, 8);
            ImageManager.Add(Image.Name.AlienB, Texture.Name.SpaceInvaders, 47, 3, 11, 8);
            ImageManager.Add(Image.Name.SquidA, Texture.Name.SpaceInvaders, 61, 3, 8, 8);
            ImageManager.Add(Image.Name.SquidB, Texture.Name.SpaceInvaders, 72, 3, 8, 8);
            ImageManager.Add(Image.Name.AlienExplosion, Texture.Name.SpaceInvaders, 83, 3, 13, 8);
            ImageManager.Add(Image.Name.Saucer, Texture.Name.SpaceInvaders, 99, 3, 16, 8);
            ImageManager.Add(Image.Name.SaucerExplosion, Texture.Name.SpaceInvaders, 118, 3, 21, 8);

            ImageManager.Add(Image.Name.Ship, Texture.Name.SpaceInvaders, 3, 14, 13, 8);
            ImageManager.Add(Image.Name.ShipExplosionA, Texture.Name.SpaceInvaders, 19, 14, 16, 8);
            ImageManager.Add(Image.Name.ShipExplosionB, Texture.Name.SpaceInvaders, 38, 14, 16, 8);
            ImageManager.Add(Image.Name.Missile, Texture.Name.SpaceInvaders, 3, 29, 1, 4);
            ImageManager.Add(Image.Name.MissileExplosion, Texture.Name.SpaceInvaders, 7, 25, 8, 8);

            ImageManager.Add(Image.Name.Wall, Texture.Name.Invaders, 40, 185, 20, 10);

            ImageManager.Add(Image.Name.BombStraight, Texture.Name.Invaders, 111, 101, 5, 49);
            ImageManager.Add(Image.Name.BombZigZagA, Texture.Name.SpaceInvaders, 18, 26, 3, 7);
            ImageManager.Add(Image.Name.BombZigZagB, Texture.Name.SpaceInvaders, 24, 26, 3, 7);
            ImageManager.Add(Image.Name.BombZigZagC, Texture.Name.SpaceInvaders, 30, 26, 3, 7);
            ImageManager.Add(Image.Name.BombZigZagD, Texture.Name.SpaceInvaders, 36, 26, 3, 7);
            ImageManager.Add(Image.Name.BombDaggerA, Texture.Name.SpaceInvaders, 42, 27, 3, 6);
            ImageManager.Add(Image.Name.BombDaggerB, Texture.Name.SpaceInvaders, 48, 27, 3, 6);
            ImageManager.Add(Image.Name.BombDaggerC, Texture.Name.SpaceInvaders, 54, 27, 3, 6);
            ImageManager.Add(Image.Name.BombDaggerD, Texture.Name.SpaceInvaders, 60, 27, 3, 6);
            ImageManager.Add(Image.Name.BombRollingA, Texture.Name.SpaceInvaders, 65, 26, 3, 7);
            ImageManager.Add(Image.Name.BombRollingB, Texture.Name.SpaceInvaders, 70, 26, 3, 7);
            ImageManager.Add(Image.Name.BombRollingC, Texture.Name.SpaceInvaders, 75, 26, 3, 7);
            ImageManager.Add(Image.Name.BombRollingD, Texture.Name.SpaceInvaders, 80, 26, 3, 7);
            ImageManager.Add(Image.Name.BombExplosion, Texture.Name.SpaceInvaders, 86, 25, 6, 8);

            ImageManager.Add(Image.Name.Brick, Texture.Name.Invaders, 20, 210, 10, 5);
            ImageManager.Add(Image.Name.BrickLeft_Top0, Texture.Name.Invaders, 15, 180, 10, 5);
            ImageManager.Add(Image.Name.BrickLeft_Top1, Texture.Name.Invaders, 15, 185, 10, 5);
            ImageManager.Add(Image.Name.BrickLeft_Bottom, Texture.Name.Invaders, 35, 215, 10, 5);
            ImageManager.Add(Image.Name.BrickRight_Top0, Texture.Name.Invaders, 75, 180, 10, 5);
            ImageManager.Add(Image.Name.BrickRight_Top1, Texture.Name.Invaders, 75, 185, 10, 5);
            ImageManager.Add(Image.Name.BrickRight_Bottom, Texture.Name.Invaders, 55, 215, 10, 5);



            // -----------------------------------------------------------------------------
            // ---------------------- Creating GameSprites ---------------------------------
            // -----------------------------------------------------------------------------
            float dim = 33.0f;
            float sm  = dim;
            float md  = dim * 1.15f;
            float lg  = dim * 1.30f;


            GameSpriteManager.Add(GameSprite.Name.Squid, Image.Name.SquidA, 200, 400, sm, sm);
            GameSpriteManager.Add(GameSprite.Name.Alien, Image.Name.AlienA, 200, 200, md, md);
            GameSpriteManager.Add(GameSprite.Name.Octopus, Image.Name.OctopusA, 200, 300, lg, lg);

            GameSpriteManager.Add(GameSprite.Name.Saucer, Image.Name.Saucer, 300, 250, 60, 30);
            GameSpriteManager.Add(GameSprite.Name.SaucerExplosion, Image.Name.SaucerExplosion, 300, 250, 60, 30);
            GameSpriteManager.Add(GameSprite.Name.AlienExplosion, Image.Name.AlienExplosion, -10, -10, dim, dim);

            // Utility for ship state movement

            float projWidth  = 8.0f;
            float projHeight = 16.0f;

            GameSpriteManager.Add(GameSprite.Name.Missile, Image.Name.Missile, 0, 0, 0.5f * projWidth, 0.75f * projHeight);
            GameSpriteManager.Add(GameSprite.Name.MissileExplosion, Image.Name.MissileExplosion, 0, 0, 0.7f * dim, 0.7f * dim);
            GameSpriteManager.Add(GameSprite.Name.Ship, Image.Name.Ship, 400, 100, 60, 21);
            GameSpriteManager.Add(GameSprite.Name.ShipExplosionA, Image.Name.ShipExplosionA, 400, 100, 90, 31);
            GameSpriteManager.Add(GameSprite.Name.ShipExplosionB, Image.Name.ShipExplosionB, 400, 100, 90, 31);

            GameSpriteManager.Add(GameSprite.Name.Wall, Image.Name.Wall, 448, 100, 850, 4);

            GameSpriteManager.Add(GameSprite.Name.BombStraight, Image.Name.BombStraight, 100, 100, projWidth, projHeight);
            GameSpriteManager.Add(GameSprite.Name.BombZigZag, Image.Name.BombZigZagA, 200, 200, projWidth, projHeight);
            GameSpriteManager.Add(GameSprite.Name.BombDagger, Image.Name.BombDaggerA, 100, 100, projWidth, projHeight);
            GameSpriteManager.Add(GameSprite.Name.BombRolling, Image.Name.BombRollingA, 100, 100, projWidth, projHeight);
            GameSpriteManager.Add(GameSprite.Name.BombExplosion, Image.Name.BombExplosion, 100, 100, 0.5f * dim, 0.7f * dim);



            float brick_w = 12.0f;
            float brick_h = 6.0f;

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



            // -----------------------------------------------------------------------------
            // ---------------------- Create Sprite Node Batches ---------------------------
            // -----------------------------------------------------------------------------



            SpriteNodeBatch pBatch_Texts      = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.Texts, 2);
            SpriteNodeBatch pBatch_Player     = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.Players, 5);
            SpriteNodeBatch pBatch_TheSwarm   = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.TheSwarm, 10);
            SpriteNodeBatch pBatch_Explosions = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.Explosions, 20);
            SpriteNodeBatch pBatch_Shields    = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.Shields, 200);
            SpriteNodeBatch pBatch_Boxes      = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.Boxes, 400);

            pBatch_Boxes.SetDrawStatus(false);
            Debug.WriteLine("Finished : Loading Sprite Batches");

            // -----------------------------------------------------------------------------
            // ---------------------- Instantiate Local GameObject Manager -----------------
            // -----------------------------------------------------------------------------

            // Moved to CreateManagers()


            // -----------------------------------------------------------------------------
            // ---------------------- Font Setup ------------------------------------------
            // -----------------------------------------------------------------------------

            Font pFont;

            int topTextLine = 980;

            pFont = FontManager.Add(Font.Name.Score1_Title, SpriteNodeBatch.Name.Texts, "SCORE<1>", Glyph.Name.Consolas36pt, 100, topTextLine);
            pFont = FontManager.Add(Font.Name.HighScore_Title, SpriteNodeBatch.Name.Texts, "HI-SCORE<1>", Glyph.Name.Consolas36pt, 350, topTextLine);
            pFont = FontManager.Add(Font.Name.Score2_Title, SpriteNodeBatch.Name.Texts, "SCORE<2>", Glyph.Name.Consolas36pt, 650, topTextLine);


            int scoreTextLine = 940;
            int x_shift       = 40;

            pFont = FontManager.Add(Font.Name.Score1, SpriteNodeBatch.Name.Texts, "0000", Glyph.Name.Consolas36pt, 100 + x_shift, scoreTextLine);
            pFont = FontManager.Add(Font.Name.HighScore, SpriteNodeBatch.Name.Texts, "0000", Glyph.Name.Consolas36pt, 350 + x_shift, scoreTextLine);
            pFont = FontManager.Add(Font.Name.Score2, SpriteNodeBatch.Name.Texts, "0000", Glyph.Name.Consolas36pt, 650 + x_shift, scoreTextLine);


            FontManager.Add(Font.Name.LifeCount, SpriteNodeBatch.Name.Texts, "3", Glyph.Name.Consolas36pt, 100, 50);



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

            pBombRoot.ActivateCollisionSprite(pBatch_Boxes);
            GameObjectManager.Attach(pBombRoot);



            // -----------------------------------------------------------------------------
            // ---------------------- Create Explosion GameObjects -------------------------------
            // -----------------------------------------------------------------------------
            ExplosionFactory EF             = new ExplosionFactory(SpriteNodeBatch.Name.Explosions, SpriteNodeBatch.Name.Boxes);
            GameObject       pExplosionRoot = EF.Build(GameObject.Name.ExplosionRoot, 0.0f, 0.0f);


            // -----------------------------------------------------------------------------
            // ---------------------- Create Grids of Nested GameObjects -------------------
            // -----------------------------------------------------------------------------



            GameObject   pWallGroup;
            GameObject   pSwarmGrid;
            GameObject   pUFOGrid;
            GameObject   pShieldRoot;
            MissileGroup pMissileGroup = CreateMissleGroup(pBatch_Player, pBatch_Boxes);
            GameObject   pBumperGroup  = CreateBumperGroup(pBatch_Player, pBatch_Boxes);

            pWallGroup = CreateWalls(pBatch_TheSwarm, pBatch_Boxes);
            Debug.WriteLine("Finished : Creating the walls");



            AlienFactory AF = new AlienFactory(SpriteNodeBatch.Name.TheSwarm, SpriteNodeBatch.Name.Boxes);

            pSwarmGrid = AF.Build(GameObject.Name.AlienGrid);
            AF.swarmAnimation(pSwarmGrid);
            Debug.WriteLine("Finished : Creating the Swarm");



            pUFOGrid = AF.Build(GameObject.Name.UFOGrid);
            AF.UFOAnimation(pUFOGrid);
            Debug.WriteLine("Finished : Creating the UfO Boss");



            Debug.WriteLine("Create Animations Gamesprites");
            pShieldRoot = new ShieldRoot(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, 0.0f, 0.0f);
            ShieldFactory SF = new ShieldFactory(SpriteNodeBatch.Name.Shields, SpriteNodeBatch.Name.Boxes, pShieldRoot);

            pShieldRoot = SF.Build(GameObject.Name.ShieldRoot);

            // -----------------------------------------------------------------------------
            // ---------------------- Create Ship GameObject ----------------------
            // -----------------------------------------------------------------------------

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

            GameObjectManager.Attach(pShipRoot);
            ShipMan.Create();
            Debug.WriteLine("Finished : Creating the ShipRoot and Ship");



            // -----------------------------------------------------------------------------
            // ---------------------- Collision Pairs --------------------------------------
            // -----------------------------------------------------------------------------


            // Alien vs Missile
            CollPair pAttackAliens = CollPairManager.Add(CollPair.Name.Alien_Missle, pMissileGroup, pSwarmGrid);

            Debug.Assert(pAttackAliens != null);
            pAttackAliens.Attach(new ShipReadyObserver());
            pAttackAliens.Attach(new RemoveMissileObserver());
            pAttackAliens.Attach(new RemoveAlienObserver());
            pAttackAliens.Attach(new SoundObserverKillAlien());
            pAttackAliens.Attach(new ExplosionSpriteObserver(GameSprite.Name.AlienExplosion));

            // Alien vs Shild
            CollPair pAlienHitShield = CollPairManager.Add(CollPair.Name.Alien_Shield, pSwarmGrid, pShieldRoot);

            pAlienHitShield.Attach(new RemoveBrickObserver());
            pAlienHitShield.Attach(new SoundObserverExplosion());

            // AlienGrid vs Left/Right Wall
            CollPair pHitWall = CollPairManager.Add(CollPair.Name.Alien_SideWalls, pSwarmGrid, pWallGroup);

            Debug.Assert(pHitWall != null);
            pHitWall.Attach(new GridObserver());


            //// AlienGrid vs Bottom Wall
            //CollPair pBottomWall = CollPairManager.Add(CollPair.Name.Alien_BottomWall, pSwarmGrid, pWallGroup);
            //Debug.Assert(pHitWall != null);
            //pBottomWall.Attach(new GameOverObserver());


            // Bumper vs Ship
            CollPair pHitBumper = CollPairManager.Add(CollPair.Name.Bumper_Ship, pBumperGroup, pShipRoot);

            pHitBumper.Attach(new BumperObserver());


            // Bomb vs Ship
            CollPair pHitShip = CollPairManager.Add(CollPair.Name.Bomb_Ship, pBombRoot, pShipRoot);

            pHitShip.Attach(new RemoveBombObserver());
            pHitShip.Attach(new ExplosionSpriteObserver(GameSprite.Name.BombExplosion));
            pHitShip.Attach(new SoundObserverExplosion());
            pHitShip.Attach(new ShipTakeDamageObserver());  // triggers GAMEOVER
            pHitShip.Attach(new ExplosionSpriteObserver(GameSprite.Name.ShipExplosionA));
            pHitShip.Attach(new ExplosionSpriteObserver(GameSprite.Name.ShipExplosionB, 0.4f));
            //pHitShip.Attach(new GameOverObserver());


            // Bomb vs Bottom
            CollPair pHitBottom = CollPairManager.Add(CollPair.Name.Bomb_WallBottom, pBombRoot, pWallGroup);

            pHitBottom.Attach(new RemoveBombObserver());
            pHitBottom.Attach(new ExplosionSpriteObserver(GameSprite.Name.BombExplosion));

            // Bomb vs Missile
            CollPair pBombvsMissile = CollPairManager.Add(CollPair.Name.Bomb_Missile, pBombRoot, pMissileGroup);

            pBombvsMissile.Attach(new ShipReadyObserver());
            pBombvsMissile.Attach(new RemoveBombObserver());
            pBombvsMissile.Attach(new RemoveMissileObserver());
            pBombvsMissile.Attach(new ExplosionSpriteObserver(GameSprite.Name.BombExplosion));
            pBombvsMissile.Attach(new SoundObserverExplosion());


            // Bomb vs Shield
            CollPair pHitBombShield = CollPairManager.Add(CollPair.Name.Bomb_Shield, pBombRoot, pShieldRoot);

            pHitBombShield.Attach(new RemoveBombObserver());
            pHitBombShield.Attach(new RemoveBrickObserver());
            pHitBombShield.Attach(new SoundObserverExplosion());
            pHitBombShield.Attach(new ExplosionSpriteObserver(GameSprite.Name.BombExplosion));


            // Missile vs Top-Wall
            CollPair pHitTopWall = CollPairManager.Add(CollPair.Name.Missile_WallTop, pMissileGroup, pWallGroup);

            Debug.Assert(pHitTopWall != null);
            pHitTopWall.Attach(new ShipReadyObserver());
            pHitTopWall.Attach(new RemoveMissileObserver());  //ShipRemoveMissileObserver()
            pHitTopWall.Attach(new ExplosionSpriteObserver(GameSprite.Name.MissileExplosion));


            // Missile vs Shield
            CollPair pColPair = CollPairManager.Add(CollPair.Name.Missile_Shield, pMissileGroup, pShieldRoot);

            pColPair.Attach(new ShipReadyObserver());
            pColPair.Attach(new RemoveMissileObserver());
            pColPair.Attach(new RemoveBrickObserver());
            pColPair.Attach(new SoundObserverExplosion());



            // UFO vs WallGroup
            CollPair pUFOvsWall = CollPairManager.Add(CollPair.Name.Saucer_Wall, pUFOGrid, pWallGroup);

            pUFOvsWall.Attach(new GridObserverUFO());



            // UFO vs Missile
            CollPair pUFOvsMissile = CollPairManager.Add(CollPair.Name.Missile_UFO, pMissileGroup, pUFOGrid);

            pUFOvsMissile.Attach(new ShipReadyObserver());
            pUFOvsMissile.Attach(new RemoveMissileObserver());
            pUFOvsMissile.Attach(new RemoveUFOObserver());
            pUFOvsMissile.Attach(new SoundObserverKillAlien());
            pUFOvsMissile.Attach(new ExplosionSpriteObserver(GameSprite.Name.SaucerExplosion));

            Debug.WriteLine("Finished : Loading Collision Pairs");



            // -----------------------------------------------------------------------------
            // ---------------------- Test Input Handles -----------------------------------
            // -----------------------------------------------------------------------------

            // Creation moved to createManagers()

            InputSubject pInputSubject;

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

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

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

            pInputSubject = InputManager.GetBkeySubject();
            pInputSubject.Attach(new RenderCollisionBoxesObserver());


            Simulation.SetState(Simulation.State.Realtime);

            Debug.WriteLine("Finished : Loading Input Subject");
        }
Example #9
0
        //This loadContent is called in the actual Game.cs
        //So its done before the player even presses input
        // and only called once
        public override void LoadContent()
        {
            //---------------------------------------------------------------------------------------------------------
            // Create Managers
            //---------------------------------------------------------------------------------------------------------

            TextureMan.Create(6, 1);
            ImageMan.Create(25, 2);
            GameSpriteMan.Create(20, 1);

            //i'm grossly inefficient at this point
            //------------------------------------------------
            BoxSpriteMan.Create(200, 100);
            ProxySpriteMan.Create(200, 100);
            //-------------------------------------------------
            SpriteBatchMan.Create(8, 1);
            GlyphMan.Create();
            FontMan.Create(12, 1);

            GONodeMan.Create(10, 3);
            TimerMan.Create(7, 3);
            ColPairMan.Create(16, 1);

            //Experimental managers
            AnimMan.Create(3, 1);
            Simulation.Create();
            PlayerMan.Create();

            SpaceInvaders pGame = GameMan.GetGame();

            IrrKlang.ISoundEngine pSndEngine = pGame.GetSndEngine();


            //---------------------------------------------------------------------------------------------------------
            // Load the Textures and Font {Consolas20pt}
            //---------------------------------------------------------------------------------------------------------

            TextureMan.Add(Texture.Name.Aliens14x14, "aliens14x14.tga");
            TextureMan.Add(Texture.Name.Aliens, "SpaceInvadersSprites.tga");

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

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



            //---------------------------------------------------------------------------------------------------------
            // Load Images
            //---------------------------------------------------------------------------------------------------------

            ImageMan.Add(Image.Name.CrabU, Texture.Name.Aliens14x14, 318, 180, 160, 116);
            ImageMan.Add(Image.Name.CrabD, Texture.Name.Aliens14x14, 318, 24, 160, 116);
            ImageMan.Add(Image.Name.OctopusU, Texture.Name.Aliens14x14, 610, 25, 122, 115);
            ImageMan.Add(Image.Name.OctopusD, Texture.Name.Aliens14x14, 610, 180, 119, 112);
            ImageMan.Add(Image.Name.SquidU, Texture.Name.Aliens14x14, 51, 24, 175, 116);
            ImageMan.Add(Image.Name.SquidD, Texture.Name.Aliens14x14, 51, 180, 175, 110);

            ImageMan.Add(Image.Name.Ship, Texture.Name.Aliens14x14, 52, 336, 194, 114);
            ImageMan.Add(Image.Name.UFO, Texture.Name.Aliens14x14, 81, 502, 229, 98);
            ImageMan.Add(Image.Name.Missile, Texture.Name.Aliens14x14, 378, 798, 14, 98);

            ImageMan.Add(Image.Name.AlienSplat, Texture.Name.Aliens14x14, 573, 490, 183, 110);
            ImageMan.Add(Image.Name.ShipSplat, Texture.Name.Aliens, 651, 942, 117, 72);
            ImageMan.Add(Image.Name.BombSplat, Texture.Name.Aliens, 350, 90, 49, 72);
            ImageMan.Add(Image.Name.UFOSplat, Texture.Name.Aliens, 224, 230, 187, 77);

            ImageMan.Add(Image.Name.BombStraight, Texture.Name.Aliens, 216, 94, 16, 56);
            ImageMan.Add(Image.Name.BombZigZag, Texture.Name.Aliens, 349, 161, 23, 59);
            ImageMan.Add(Image.Name.BombCross, Texture.Name.Aliens, 210, 163, 30, 48);

            ImageMan.Add(Image.Name.Brick, Texture.Name.Aliens, 50, 120, 20, 10);
            ImageMan.Add(Image.Name.BrickLeft_Top1, Texture.Name.Aliens, 40, 100, 20, 10);
            ImageMan.Add(Image.Name.BrickLeft_Top2, Texture.Name.Aliens, 40, 110, 20, 10);
            ImageMan.Add(Image.Name.BrickLeft_Bottom, Texture.Name.Aliens, 75, 190, 15, 10);
            ImageMan.Add(Image.Name.BrickRight_Top1, Texture.Name.Aliens, 189, 125, 20, 10);
            ImageMan.Add(Image.Name.BrickRight_Top2, Texture.Name.Aliens, 186, 126, 20, 10);
            ImageMan.Add(Image.Name.BrickRight_Bottom, Texture.Name.Aliens, 130, 190, 20, 10);


            //---------------------------------------------------------------------------------------------------------
            // Create Sprites
            //---------------------------------------------------------------------------------------------------------

            GameSpriteMan.Add(GameSprite.Name.UFO, Image.Name.UFO, 400, 550, 50.0f, 25.0f);
            GameSpriteMan.Add(GameSprite.Name.Ship, Image.Name.Ship, 400, 25, 40.0f, 25.0f);

            GameSpriteMan.Add(GameSprite.Name.Crab, Image.Name.CrabU, 700, 480, 35, 20);
            GameSpriteMan.Add(GameSprite.Name.Squid, Image.Name.SquidU, 325, 350, 35, 20);
            GameSpriteMan.Add(GameSprite.Name.Octopus, Image.Name.OctopusU, 260, 350, 25, 20);

            GameSpriteMan.Add(GameSprite.Name.AlienSplat, Image.Name.AlienSplat, 50, 50, 30, 20);
            GameSpriteMan.Add(GameSprite.Name.ShipSplat, Image.Name.ShipSplat, 50, 50, 40, 25);
            GameSpriteMan.Add(GameSprite.Name.UFOsplat, Image.Name.UFOSplat, 50, 50, 50, 25);
            GameSpriteMan.Add(GameSprite.Name.BombSplat, Image.Name.BombSplat, 50, 50, 10, 15);

            GameSpriteMan.Add(GameSprite.Name.Missile, Image.Name.Missile, 100, 100, 5.0f, 15.0f);
            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_LeftTop1, Image.Name.BrickLeft_Top1, 50, 25, 10, 5);
            GameSpriteMan.Add(GameSprite.Name.Brick_LeftTop2, Image.Name.BrickLeft_Top2, 50, 25, 10, 5);
            GameSpriteMan.Add(GameSprite.Name.Brick_LeftBottom, Image.Name.BrickLeft_Bottom, 50, 25, 10, 5);
            GameSpriteMan.Add(GameSprite.Name.Brick_RightTop1, Image.Name.BrickRight_Top1, 50, 25, 10, 5);
            GameSpriteMan.Add(GameSprite.Name.Brick_RightTop2, Image.Name.BrickRight_Top2, 50, 25, 10, 5);
            GameSpriteMan.Add(GameSprite.Name.Brick_RightBottom, Image.Name.BrickRight_Bottom, 50, 25, 10, 5);


            //------------------------------------------------------------------------------------------
            //Attaching the sprites/batches
            //------------------------------------------------------------------------------------------

            SpriteBatch pSB_Intro = SpriteBatchMan.Add(SpriteBatch.Name.IntroScreen);


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

            pSB_Aliens.bToggle = false;

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

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

            pSB_Shields.bToggle = false;

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

            pSB_InGame.bToggle = false;

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

            pSB_Projectiles.bToggle = false;

            SpriteBatch pSB_GameOver = SpriteBatchMan.Add(SpriteBatch.Name.GameOver);

            pSB_GameOver.bToggle = false;

            //SpriteBatch pSB_Splats = SpriteBatchMan.Add(SpriteBatch.Name.Splats);
            //pSB_Splats.bToggle = false;

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

            FontMan.Add(Font.Name.Title, SpriteBatch.Name.IntroScreen, "Space Invaders", Glyph.Name.Consolas36pt, 200, 700);
            FontMan.Add(Font.Name.NumOfPlayers, SpriteBatch.Name.IntroScreen, "Press 1 for Single Player", Glyph.Name.Consolas36pt, 120, 650);
            FontMan.Add(Font.Name.ShootButton, SpriteBatch.Name.IntroScreen, "Space <Bar> To Shoot", Glyph.Name.Consolas36pt, 140, 580);
            FontMan.Add(Font.Name.MoveButtons, SpriteBatch.Name.IntroScreen, "Left and Right Arrows To Move", Glyph.Name.Consolas36pt, 60, 540);
            FontMan.Add(Font.Name.SquidScore, SpriteBatch.Name.IntroScreen, "Squid = 30 points", Glyph.Name.Consolas36pt, 200, 480);
            FontMan.Add(Font.Name.CrabScore, SpriteBatch.Name.IntroScreen, "Crab = 40 points", Glyph.Name.Consolas36pt, 200, 440);
            FontMan.Add(Font.Name.OctoScore, SpriteBatch.Name.IntroScreen, "Octo = 50 points", Glyph.Name.Consolas36pt, 200, 400);
            FontMan.Add(Font.Name.UFOScore, SpriteBatch.Name.IntroScreen, "UFO = 100 points", Glyph.Name.Consolas36pt, 200, 360);
            FontMan.Add(Font.Name.TBD, SpriteBatch.Name.IntroScreen, "2 Player Coming Soon!", Glyph.Name.Consolas36pt, 160, 300);


            FontMan.Add(Font.Name.ScoreP1, SpriteBatch.Name.InGameScreen, "<P1 Score>", Glyph.Name.Consolas36pt, 20, 720);
            FontMan.Add(Font.Name.LivesP1, SpriteBatch.Name.InGameScreen, "P1 Lives:", Glyph.Name.Consolas36pt, 20, 20);
            FontMan.Add(Font.Name.P1Points, SpriteBatch.Name.InGameScreen, "0", Glyph.Name.Consolas36pt, 20, 680);

            FontMan.Add(Font.Name.HiScore, SpriteBatch.Name.InGameScreen, "<HiScore>", Glyph.Name.Consolas36pt, 230, 720);
            FontMan.Add(Font.Name.HiPoints, SpriteBatch.Name.InGameScreen, "0", Glyph.Name.Consolas36pt, 250, 680);

            FontMan.Add(Font.Name.ScoreP2, SpriteBatch.Name.InGameScreen, "<P2 Score>", Glyph.Name.Consolas36pt, 425, 720);
            FontMan.Add(Font.Name.LivesP2, SpriteBatch.Name.InGameScreen, "P2 Lives:", Glyph.Name.Consolas36pt, 400, 20);
            FontMan.Add(Font.Name.P2Points, SpriteBatch.Name.InGameScreen, "0", Glyph.Name.Consolas36pt, 400, 680);

            FontMan.Add(Font.Name.GameOver, SpriteBatch.Name.GameOver, "Game, Set and Match", Glyph.Name.Consolas36pt, 100, 450);
            FontMan.Add(Font.Name.Credits, SpriteBatch.Name.GameOver, "Created By: James Corcoran", Glyph.Name.Consolas36pt, 100, 350);
            FontMan.Add(Font.Name.Thankyou, SpriteBatch.Name.GameOver, "Thanks for Playing!!!", Glyph.Name.Consolas36pt, 100, 250);

            //----------------------------------------------------------------------
            //Missile
            //----------------------------------------------------------------------

            MissileGroup pMissileGroup = new MissileGroup(GameObject.Name.MissileGroup, GameSprite.Name.NullObject, 0, 0.0f, 0.0f);

            pMissileGroup.ActivateGameSprite(pSB_Projectiles);
            pMissileGroup.ActivateCollisionSprite(pSB_Boxes);

            GONodeMan.Attach(pMissileGroup);


            Debug.WriteLine("-------------------");
            pMissileGroup.Print();

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

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

            GONodeMan.Attach(pShipRoot);

            Debug.WriteLine("-------------------");
            pShipRoot.Print();

            //----------------------------------------------------------------------
            //UFO
            //----------------------------------------------------------------------

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

            GONodeMan.Attach(pUFORoot);

            Debug.WriteLine("-------------------");
            pUFORoot.Print();

            //---------------------------------------------------------------------------------------------------------
            // Bomb
            //---------------------------------------------------------------------------------------------------------

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

            GONodeMan.Attach(pBombRoot);

            Debug.WriteLine("-------------------");
            pBombRoot.Print();

            //---------------------------------------------------------------------
            //Wall Creation
            //---------------------------------------------------------------------

            WallRoot pTWallRoot = new WallRoot(GameObject.Name.WallRoot, GameSprite.Name.NullObject, 0.0f, 0.0f);

            GONodeMan.Attach(pTWallRoot);

            TopWall pTWall = new TopWall(GameObject.Name.TopWall, GameSprite.Name.NullObject, 336, 748, 600, 40);

            pTWall.ActivateCollisionSprite(pSB_Boxes);
            pTWallRoot.Add(pTWall);

            WallRoot pLWallRoot = new WallRoot(GameObject.Name.WallRoot, GameSprite.Name.NullObject, 0.0f, 0.0f);

            GONodeMan.Attach(pLWallRoot);

            LeftWall pLWall = new LeftWall(GameObject.Name.LeftWall, GameSprite.Name.NullObject, 20, 384, 40, 700);

            pLWall.ActivateCollisionSprite(pSB_Boxes);
            pLWallRoot.Add(pLWall);

            WallRoot pRWallRoot = new WallRoot(GameObject.Name.WallRoot, GameSprite.Name.NullObject, 0.0f, 0.0f);

            GONodeMan.Attach(pRWallRoot);

            RightWall pRWall = new RightWall(GameObject.Name.RightWall, GameSprite.Name.NullObject, 653, 384, 40, 700);

            pRWall.ActivateCollisionSprite(pSB_Boxes);
            pRWallRoot.Add(pRWall);

            WallRoot pBWallRoot = new WallRoot(GameObject.Name.WallRoot, GameSprite.Name.NullObject, 0.0f, 0.0f);

            GONodeMan.Attach(pBWallRoot);

            BottomWall pBWall = new BottomWall(GameObject.Name.BottomWall, GameSprite.Name.NullObject, 336, 20, 700, 40);

            pBWall.ActivateCollisionSprite(pSB_Boxes);
            pBWallRoot.Add(pBWall);

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

            //---------------------------------------------------------------------
            //AlienRoot(Group) and ShieldRoot
            //---------------------------------------------------------------------

            Composite pAlienGroup = new AlienGroup(GameObject.Name.AlienGrid, GameSprite.Name.NullObject, 0.0f, 0.0f);

            pAlienGroup.ActivateCollisionSprite(pSB_Boxes);
            GONodeMan.Attach(pAlienGroup);


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

            GONodeMan.Attach(pShieldRoot);


            //Composite pSplatRoot = new SplatRoot(GameObject.Name.SplatRoot, GameSprite.Name.NullObject, 0.0f, 0.0f);
            //GONodeMan.Attach(pSplatRoot);

            //--------------------------------------------------------------------------
            // Collision Pair
            //--------------------------------------------------------------------------

            ColPair pGrid_V_LWall = ColPairMan.Add(ColPair.Name.Aliens_V_LWall, pAlienGroup, pLWallRoot);

            Debug.Assert(pGrid_V_LWall != null);
            pGrid_V_LWall.Attach(new GridObserver());

            ColPair pGrid_V_RWall = ColPairMan.Add(ColPair.Name.Aliens_V_RWall, pAlienGroup, pRWallRoot);

            Debug.Assert(pGrid_V_RWall != null);
            pGrid_V_RWall.Attach(new GridObserver());

            ColPair pGrid_V_BWall = ColPairMan.Add(ColPair.Name.Aliens_V_BWall, pAlienGroup, pBWallRoot);

            Debug.Assert(pGrid_V_BWall != null);
            pGrid_V_BWall.Attach(new GridObserver());

            ColPair pMissile_V_Alien = ColPairMan.Add(ColPair.Name.Missile_V_Alien, pMissileGroup, pAlienGroup);

            Debug.Assert(pMissile_V_Alien != null);
            pMissile_V_Alien.Attach(new SplatObserver());
            pMissile_V_Alien.Attach(new RemoveAlienObserver());
            pMissile_V_Alien.Attach(new RemoveMissileObserver());
            pMissile_V_Alien.Attach(new ShipReadyObserver());
            pMissile_V_Alien.Attach(new SndObserver(pSndEngine, "invaderkilled.wav"));


            ColPair pAlien_V_Shield = ColPairMan.Add(ColPair.Name.Aliens_V_Shield, pAlienGroup, pShieldRoot);

            Debug.Assert(pAlien_V_Shield != null);
            pAlien_V_Shield.Attach(new RemoveBrickObserver());
            //pAlien_V_Shield.Attach(new SndObserver(pSndEngine, "explosion.wav"));

            ColPair pAlien_V_Ship = ColPairMan.Add(ColPair.Name.Aliens_V_Ship, pAlienGroup, pShipRoot);

            Debug.Assert(pAlien_V_Ship != null);
            pAlien_V_Ship.Attach(new SplatShipObserver());
            pAlien_V_Ship.Attach(new HitShipObserver());
            pAlien_V_Ship.Attach(new SndObserver(pSndEngine, "explosion.wav"));
            pAlien_V_Ship.Attach(new P1GameOverObs());

            //--------------------------------------------------------------------------------------------------------------

            ColPair pCollide_UFO_RWall = ColPairMan.Add(ColPair.Name.UFO_V_RWall, pUFORoot, pRWallRoot);

            Debug.Assert(pCollide_UFO_RWall != null);
            pCollide_UFO_RWall.Attach(new MissedUFOobserver());
            pCollide_UFO_RWall.Attach(new RemoveSndUFO());

            ColPair pCollide_UFO_LWall = ColPairMan.Add(ColPair.Name.UFO_V_LWall, pUFORoot, pLWallRoot);

            Debug.Assert(pCollide_UFO_LWall != null);
            pCollide_UFO_LWall.Attach(new MissedUFOobserver());
            pCollide_UFO_LWall.Attach(new RemoveSndUFO());

            ColPair pCollide_Missile_V_UFO = ColPairMan.Add(ColPair.Name.Missile_V_UFO, pMissileGroup, pUFORoot);

            Debug.Assert(pCollide_Missile_V_UFO != null);
            pCollide_Missile_V_UFO.Attach(new RemoveMissileObserver());
            pCollide_Missile_V_UFO.Attach(new RemoveUFOobserver());
            pCollide_Missile_V_UFO.Attach(new ShipReadyObserver());
            pCollide_Missile_V_UFO.Attach(new UFOSplatObs());
            pCollide_Missile_V_UFO.Attach(new SndObserver(pSndEngine, "invaderkilled.wav"));
            pCollide_Missile_V_UFO.Attach(new RemoveSndUFO());

            //-----------------------------------------------------------------------------------------------------------------
            ColPair pMissile_V_TWall = ColPairMan.Add(ColPair.Name.Missile_V_TWall, pMissileGroup, pTWallRoot);

            Debug.Assert(pMissile_V_TWall != null);
            pMissile_V_TWall.Attach(new ShipReadyObserver());
            pMissile_V_TWall.Attach(new RemoveMissileObserver());

            ColPair pBomb_V_Wall = ColPairMan.Add(ColPair.Name.Bomb_V_Wall, pBombRoot, pBWallRoot);

            Debug.Assert(pBomb_V_Wall != null);
            pBomb_V_Wall.Attach(new BombObserver());

            ColPair pMissile_V_Shield = ColPairMan.Add(ColPair.Name.Missile_V_Shield, pMissileGroup, pShieldRoot);

            Debug.Assert(pMissile_V_Shield != null);
            pMissile_V_Shield.Attach(new RemoveBrickObserver());
            pMissile_V_Shield.Attach(new RemoveMissileObserver());
            pMissile_V_Shield.Attach(new ShipReadyObserver());
            pMissile_V_Shield.Attach(new SndObserver(pSndEngine, "explosion.wav"));

            ColPair pBomb_V_Shield = ColPairMan.Add(ColPair.Name.Bomb_V_Shield, pBombRoot, pShieldRoot);

            Debug.Assert(pBomb_V_Shield != null);
            pBomb_V_Shield.Attach(new RemoveBrickObserver());
            pBomb_V_Shield.Attach(new BombObserver());
            pBomb_V_Shield.Attach(new SndObserver(pSndEngine, "explosion.wav"));

            ColPair pBomb_V_Ship = ColPairMan.Add(ColPair.Name.Ship_V_Bomb, pBombRoot, pShipRoot);

            Debug.Assert(pBomb_V_Ship != null);
            pBomb_V_Ship.Attach(new SplatShipObserver());
            pBomb_V_Ship.Attach(new BombObserver());
            pBomb_V_Ship.Attach(new HitShipObserver());
            pBomb_V_Ship.Attach(new SndObserver(pSndEngine, "explosion.wav"));
            pBomb_V_Ship.Attach(new P1GameOverObs());


            ColPair pBomb_V_Missile = ColPairMan.Add(ColPair.Name.Bomb_V_Missile, pBombRoot, pMissileGroup);

            Debug.Assert(pBomb_V_Missile != null);
            pBomb_V_Missile.Attach(new BombSplatObs());
            pBomb_V_Missile.Attach(new BombMissileObserver());
            pBomb_V_Missile.Attach(new SndObserver(pSndEngine, "explosion.wav"));
            pBomb_V_Missile.Attach(new ShipReadyObserver());
            //------------------------------------------------------------------------------------------------------------------

            ColPair pShip_V_LWall = ColPairMan.Add(ColPair.Name.Ship_V_LWall, pShipRoot, pLWallRoot);

            Debug.Assert(pShip_V_LWall != null);
            pShip_V_LWall.Attach(new ShipMovementObserver());

            ColPair pShip_V_RWall = ColPairMan.Add(ColPair.Name.Ship_V_RWall, pShipRoot, pRWallRoot);

            Debug.Assert(pShip_V_RWall != null);
            pShip_V_RWall.Attach(new ShipMovementObserver());

            //----------------------------------------------------------------------------------------------------------
            //Animate Sprites and Movement Commands
            //----------------------------------------------------------------------------------------------------------

            //Tests on my Animation Manager
            AnimateCrab pAnimS1 = new AnimateCrab(Animation.Name.AnimateCrab, GameSprite.Name.Crab);

            pAnimS1.Attach(Image.Name.CrabD);
            pAnimS1.Attach(Image.Name.CrabU);

            AnimateSquid pAnimS2 = new AnimateSquid(Animation.Name.AnimateSquid, GameSprite.Name.Squid);

            pAnimS2.Attach(Image.Name.SquidD);
            pAnimS2.Attach(Image.Name.SquidU);

            AnimateOcto pAnimS3 = new AnimateOcto(Animation.Name.AnimateOcto, GameSprite.Name.Octopus);

            pAnimS3.Attach(Image.Name.OctopusD);
            pAnimS3.Attach(Image.Name.OctopusU);

            AnimMan.Attach(pAnimS1);
            AnimMan.Attach(pAnimS2);
            AnimMan.Attach(pAnimS3);

            //---------------------------------------------------------------------------------------------------------
            //Add Input
            //---------------------------------------------------------------------------------------------------------
            InputSubject pInputSubject;

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

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

            pInputSubject = InputManager.GetSpaceBarSubject();
            pInputSubject.Attach(new ShootObserver());

            //first player
            pInputSubject = InputManager.Get1keySubject();
            pInputSubject.Attach(new Player1Observer());

            //add second player observer
            pInputSubject = InputManager.Get2keySubject();
            pInputSubject.Attach(new Player2Observer());


            pInputSubject = InputManager.GetCkeySubject();
            pInputSubject.Attach(new ToggleColObserver());


            //Simulator
            //I am testing because i think we will need to pause the game
            //for the timer manager and the lives for the ship
            Simulation.SetState(Simulation.State.RealTime);
        }