コード例 #1
0
        public static void initialize(int toCreate, int willCreate)
        {
            Debug.Assert(toCreate > 0);
            Debug.Assert(willCreate > 0);

            if (iGOMan == null)
            {
                iGOMan = new GameObjectManager(toCreate, willCreate);
            }
        }
コード例 #2
0
ファイル: Player.cs プロジェクト: frobro98/School-Projects
        public Player(PlayerNum type = PlayerNum.One)
        {
            batchMan = new SpriteBatchManager(9, 1);
            gameObjMan = new GameObjectManager(11, 1);
            timeMan = new TimeEventManager(4, 2);
            colPairMan = new CollisionPairManager(13, 1);
            hookupManagers();
            initialPlayerSetup();

            playerType = type;
            currNumLives = maxLives;
        }
 public IncreaseAlienSpeedObserver()
 {
     this.pGrid = (AlienGrid)GameObjectManager.Find(GameObject.Name.AlienGrid);
 }
コード例 #4
0
        public override void LoadContent()
        {
            SpriteNodeBatch pSB_Texts = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.Texts);

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

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



            TextureManager.Add(Texture.Name.SpaceInvaders, "SpaceInvaders.tga");
            ImageManager.Add(Image.Name.SquidA, Texture.Name.SpaceInvaders, 61, 3, 8, 8);
            ImageManager.Add(Image.Name.AlienA, Texture.Name.SpaceInvaders, 33, 3, 11, 8);
            ImageManager.Add(Image.Name.OctopusA, Texture.Name.SpaceInvaders, 3, 3, 12, 8);
            ImageManager.Add(Image.Name.Saucer, Texture.Name.SpaceInvaders, 99, 3, 16, 8);


            //----------------------------------------------------------------------------------
            // Print Space Invaders Title Scene
            //----------------------------------------------------------------------------------

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


            int playTextLine = topTextLine - 200;

            pFont = FontManager.Add(Font.Name.Play, SpriteNodeBatch.Name.Texts, "PLAY", Glyph.Name.Consolas36pt, 400, playTextLine);
            pFont = FontManager.Add(Font.Name.GameTitle, SpriteNodeBatch.Name.Texts, "SPACE   INVADERS", Glyph.Name.Consolas36pt, 300, playTextLine - 60);


            int advTableTop = topTextLine - 430;

            pFont = FontManager.Add(Font.Name.ScoreTable, SpriteNodeBatch.Name.Texts, "*SCORE   ADVANCE   TABLE*", Glyph.Name.Consolas36pt, 200, advTableTop);


            int   leftAlignPoints = 335;
            float size            = 36.0f;


            GameSpriteManager.Add(GameSprite.Name.Saucer, Image.Name.Saucer, leftAlignPoints, advTableTop - 50, 60, 30);
            pFont = FontManager.Add(Font.Name.UFO_Points, SpriteNodeBatch.Name.Texts, "  =? MYSTERY", Glyph.Name.Consolas36pt, leftAlignPoints, advTableTop - 50);


            GameSpriteManager.Add(GameSprite.Name.Squid, Image.Name.SquidA, leftAlignPoints, advTableTop - 100, size, size);
            pFont = FontManager.Add(Font.Name.Squid_Points, SpriteNodeBatch.Name.Texts, "  =30 POINTS", Glyph.Name.Consolas36pt, leftAlignPoints, advTableTop - 100);


            GameSpriteManager.Add(GameSprite.Name.Alien, Image.Name.AlienA, leftAlignPoints, advTableTop - 150, size, size);
            pFont = FontManager.Add(Font.Name.Alien_Points, SpriteNodeBatch.Name.Texts, "  =20 POINTS", Glyph.Name.Consolas36pt, leftAlignPoints, advTableTop - 150);


            GameSpriteManager.Add(GameSprite.Name.Octopus, Image.Name.OctopusA, leftAlignPoints, advTableTop - 200, size, size);
            pFont = FontManager.Add(Font.Name.Octopus_Points, SpriteNodeBatch.Name.Texts, "  =10 POINTS", Glyph.Name.Consolas36pt, leftAlignPoints, advTableTop - 200);
            pFont.SetColor(0.1f, 0.9f, 0.1f);



            // -----------------------------------------------------------------------------
            // ---------------------- 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_Shields = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.Shields, 200);
            SpriteNodeBatch pSB_Invaders = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.Invaders, 100);
            SpriteNodeBatch pBatch_Boxes = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.Boxes, 400);

            pBatch_Boxes.SetDrawStatus(false);


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

            AlienColumn pAlienCol = (AlienColumn)AF.Create(GameObject.Name.Column_0, AlienCategory.Type.Column);
            GameObject  pGameObj;

            pGameObj = AF.Create(GameObject.Name.Saucer, AlienCategory.Type.Saucer, leftAlignPoints - 9, advTableTop - 50);
            pAlienCol.Add(pGameObj);
            pGameObj = AF.Create(GameObject.Name.Squid, AlienCategory.Type.Squid, leftAlignPoints, advTableTop - 100);
            pAlienCol.Add(pGameObj);
            pGameObj = AF.Create(GameObject.Name.Alien, AlienCategory.Type.Alien, leftAlignPoints, advTableTop - 150);
            pAlienCol.Add(pGameObj);
            pGameObj = AF.Create(GameObject.Name.Octopus, AlienCategory.Type.Octopus, leftAlignPoints, advTableTop - 200);
            pAlienCol.Add(pGameObj);

            GameObjectManager.Attach(pAlienCol);
        }
コード例 #5
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");
        }
コード例 #6
0
        //CHANGE THIS
        public static void Remove(GameObject pNode)
        {
            // Keenan(delete.E)
            Debug.Assert(pNode != null);
            GameObjectManager pMan = GameObjectManager.pActiveMan;

            GameObject pSafetyNode = pNode;

            // OK so we have a linked list of trees (Remember that)

            // 1) find the tree root (we already know its the most parent)

            GameObject pTmp  = pNode;
            GameObject pRoot = null;

            while (pTmp != null)
            {
                pRoot = pTmp;
                pTmp  = (GameObject)Iterator.GetParent(pTmp);
            }

            // 2) pRoot is the tree we are looking for
            // now walk the active list looking for pRoot

            GameObjectNode pTree = (GameObjectNode)pMan.BaseGetActive();

            while (pTree != null)
            {
                if (pTree.pGameObj == pRoot)
                {
                    // found it
                    break;
                }
                // Goto Next tree
                pTree = (GameObjectNode)pTree.pNext;
            }

            // 3) pTree is the tree that holds pNode
            //  Now remove the node from that tree

            Debug.Assert(pTree != null);
            Debug.Assert(pTree.pGameObj != null);

            // Is pTree.poGameObj same as the node we are trying to delete?
            // Answer: should be no... since we always have a group (that was a good idea)

            Debug.Assert(pTree.pGameObj != pNode);

            GameObject pParent = (GameObject)Iterator.GetParent(pNode);

            Debug.Assert(pParent != null);

            GameObject pChild = (GameObject)Iterator.GetChild(pNode);

            Debug.Assert(pChild == null);

            // remove the node
            pParent.Remove(pNode);

            // TODO - Recycle pNode
        }
コード例 #7
0
 public override void Update(float systemTime)
 {
     // walk through all objects and push to flyweight
     GameObjectManager.Update();
 }
コード例 #8
0
        public static PCSTree GetRootTree()
        {
            GameObjectManager goMan = GameObjectManager.GetInstance();

            return(goMan.pRoot);
        }
コード例 #9
0
        public static void Destroy()
        {
            GameObjectManager goMan = GameObjectManager.GetInstance();

            goMan.BaseDestroy();
        }
コード例 #10
0
        //-----------------------------------------------------------------------------
        // Game::LoadContent()
        //		Allows you to load all content needed for your engine,
        //	    such as objects, graphics, etc.
        //-----------------------------------------------------------------------------
        public override void LoadContent()
        {
            ScreenWidth  = this.GetScreenWidth();
            ScreenHeight = this.GetScreenHeight();

            //---------------------------------------------------------------------------------------------------------
            // Init Managers
            //---------------------------------------------------------------------------------------------------------

            //Constant Managers
            TextureManager.Create(1, 1);
            ImageManager.Create(5, 2);
            SoundManager.Create(3, 1);
            GameSpriteManager.Create(4, 2);
            BoxSpriteManager.Create(3, 1);
            CollisionStateManager.Create();
            GlyphManager.Create(3, 1);
            Simulation.Create();
            RandomManager.Create();
            BombManager.Create();
            ShipManager.Create();

            //State-unique Managers
            SpriteBatchManager.Create();
            GameObjectManager.Create();
            InputManager.Create();
            FontManager.Create();
            TimerManager.Create();
            CollisionPairManager.Create();



            //ProxySpriteManager.Create(10, 1);//not in use currently

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

            TextureManager.Add(Texture.Name.SpaceInvaders, "SpaceInvaders.tga");

            //---------------------------------------------------------------------------------------------------------
            // Load Sounds
            //---------------------------------------------------------------------------------------------------------

            SoundManager.Add(Sound.Name.Invader1, "fastinvader1.wav");
            SoundManager.Add(Sound.Name.Invader2, "fastinvader2.wav");
            SoundManager.Add(Sound.Name.Invader3, "fastinvader3.wav");
            SoundManager.Add(Sound.Name.Invader4, "fastinvader4.wav");

            SoundManager.Add(Sound.Name.Shoot, "invaderkilled.wav");
            SoundManager.Add(Sound.Name.DeadAlien, "shoot.wav");
            SoundManager.Add(Sound.Name.UFO, "ufo_highpitch.wav");
            SoundManager.Add(Sound.Name.UFOExplosion, "ufo_lowpitch.wav");
            SoundManager.Add(Sound.Name.Explosion, "explosion.wav");

            //---------------------------------------------------------------------------------------------------------
            // Create Images
            //---------------------------------------------------------------------------------------------------------

            // --- aliens ---

            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.Saucer, Texture.Name.SpaceInvaders, 99, 3, 16, 8);

            ImageManager.Add(Image.Name.Missile, Texture.Name.SpaceInvaders, 3, 29, 1, 4);
            ImageManager.Add(Image.Name.Ship, Texture.Name.SpaceInvaders, 3, 14, 13, 8);

            ImageManager.Add(Image.Name.AlienExplosion, Texture.Name.SpaceInvaders, 83, 3, 13, 8);
            ImageManager.Add(Image.Name.SaucerExplosion, Texture.Name.SpaceInvaders, 118, 3, 21, 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.MissileExplosion, Texture.Name.SpaceInvaders, 7, 25, 8, 8);
            ImageManager.Add(Image.Name.BombExplosion, Texture.Name.SpaceInvaders, 86, 25, 6, 8);

            ImageManager.Add(Image.Name.BombDagger, Texture.Name.SpaceInvaders, 42, 27, 3, 6);
            ImageManager.Add(Image.Name.BombZigZag, Texture.Name.SpaceInvaders, 18, 26, 3, 7);
            ImageManager.Add(Image.Name.BombStraight, Texture.Name.SpaceInvaders, 65, 26, 3, 7);

            ImageManager.Add(Image.Name.ShieldBrick, Texture.Name.SpaceInvaders, 120, 35, 4, 2);
            ImageManager.Add(Image.Name.ShieldBrick_LeftTop0, Texture.Name.SpaceInvaders, 115, 30, 4, 2);
            ImageManager.Add(Image.Name.ShieldBrick_LeftTop1, Texture.Name.SpaceInvaders, 116, 31, 4, 2);
            ImageManager.Add(Image.Name.ShieldBrick_LeftBottom, Texture.Name.SpaceInvaders, 119, 43, 4, 2);
            ImageManager.Add(Image.Name.ShieldBrick_RightTop0, Texture.Name.SpaceInvaders, 132, 31, 4, 2);
            ImageManager.Add(Image.Name.ShieldBrick_RightTop1, Texture.Name.SpaceInvaders, 130, 31, 4, 2);
            ImageManager.Add(Image.Name.ShieldBrick_RightBottom, Texture.Name.SpaceInvaders, 126, 43, 4, 2);

            //---------------------------------------------------------------------------------------------------------
            // Create Glyphs
            //---------------------------------------------------------------------------------------------------------
            GlyphManager.Add(Glyph.Name.Space, 32, Texture.Name.SpaceInvaders, 99, 56, 5, 7);

            GlyphManager.Add(Glyph.Name.Asterisk, 42, Texture.Name.SpaceInvaders, 115, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Hyphen, 45, Texture.Name.SpaceInvaders, 131, 56, 5, 7);

            GlyphManager.Add(Glyph.Name.Zero, 48, Texture.Name.SpaceInvaders, 3, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.One, 49, Texture.Name.SpaceInvaders, 11, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Two, 50, Texture.Name.SpaceInvaders, 19, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Three, 51, Texture.Name.SpaceInvaders, 27, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Four, 52, Texture.Name.SpaceInvaders, 35, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Five, 53, Texture.Name.SpaceInvaders, 43, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Six, 54, Texture.Name.SpaceInvaders, 51, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Seven, 55, Texture.Name.SpaceInvaders, 59, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Eight, 56, Texture.Name.SpaceInvaders, 67, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Nine, 57, Texture.Name.SpaceInvaders, 75, 56, 5, 7);

            GlyphManager.Add(Glyph.Name.LessThan, 60, Texture.Name.SpaceInvaders, 83, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Equals, 61, Texture.Name.SpaceInvaders, 107, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.GreaterThan, 62, Texture.Name.SpaceInvaders, 91, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Question, 63, Texture.Name.SpaceInvaders, 123, 56, 5, 7);

            GlyphManager.Add(Glyph.Name.A, 65, Texture.Name.SpaceInvaders, 3, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.B, 66, Texture.Name.SpaceInvaders, 11, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.C, 67, Texture.Name.SpaceInvaders, 19, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.D, 68, Texture.Name.SpaceInvaders, 27, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.E, 69, Texture.Name.SpaceInvaders, 35, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.F, 70, Texture.Name.SpaceInvaders, 43, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.G, 71, Texture.Name.SpaceInvaders, 51, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.H, 72, Texture.Name.SpaceInvaders, 59, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.I, 73, Texture.Name.SpaceInvaders, 67, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.J, 74, Texture.Name.SpaceInvaders, 75, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.K, 75, Texture.Name.SpaceInvaders, 83, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.L, 76, Texture.Name.SpaceInvaders, 91, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.M, 77, Texture.Name.SpaceInvaders, 99, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.N, 78, Texture.Name.SpaceInvaders, 3, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.O, 79, Texture.Name.SpaceInvaders, 11, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.P, 80, Texture.Name.SpaceInvaders, 19, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.Q, 81, Texture.Name.SpaceInvaders, 27, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.R, 82, Texture.Name.SpaceInvaders, 35, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.S, 83, Texture.Name.SpaceInvaders, 43, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.T, 84, Texture.Name.SpaceInvaders, 51, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.U, 85, Texture.Name.SpaceInvaders, 59, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.V, 86, Texture.Name.SpaceInvaders, 67, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.W, 87, Texture.Name.SpaceInvaders, 75, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.X, 88, Texture.Name.SpaceInvaders, 83, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.Y, 89, Texture.Name.SpaceInvaders, 91, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.Z, 90, Texture.Name.SpaceInvaders, 99, 46, 5, 7);


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

            // --- aliens ---

            GameSpriteManager.Add(GameSprite.Name.PurpleOctopus, Image.Name.OctopusA, 50, 300, 49, 33);
            GameSpriteManager.Add(GameSprite.Name.BlueCrab, Image.Name.AlienB, 200, 100, 45, 33);
            GameSpriteManager.Add(GameSprite.Name.GreenSquid, Image.Name.SquidA, 200, 300, 33, 33);
            GameSpriteManager.Add(GameSprite.Name.OrangeSaucer, Image.Name.Saucer, 50, 550, 59, 33, new Azul.Color(1.0f, 0.0f, 0.0f, 1.0f));

            //-----Missile----
            GameSpriteManager.Add(GameSprite.Name.Missile, Image.Name.Missile, 50, 50, 3, 15);
            //----Player Ship----
            GameSpriteManager.Add(GameSprite.Name.Ship, Image.Name.Ship, 500, 100, 50, 30, new Azul.Color(0.0f, 1.0f, 0.0f, 1.0f));

            //---Explosions---
            GameSpriteManager.Add(GameSprite.Name.AlienExplosion, Image.Name.AlienExplosion, 50, 50, 33, 33);
            GameSpriteManager.Add(GameSprite.Name.ShipExplosion, Image.Name.ShipExplosionA, 50, 50, 55, 35);
            GameSpriteManager.Add(GameSprite.Name.SaucerExplosion, Image.Name.SaucerExplosion, 50, 50, 45, 35, new Azul.Color(1.0f, 0.0f, 0.0f, 1.0f));
            GameSpriteManager.Add(GameSprite.Name.BombExplosion, Image.Name.BombExplosion, 50, 50, 25, 25);
            GameSpriteManager.Add(GameSprite.Name.MissileExplosionRed, Image.Name.MissileExplosion, 50, 50, 20, 20, new Azul.Color(1.0f, 0.0f, 0.0f, 1.0f));
            GameSpriteManager.Add(GameSprite.Name.MissileExplosionGreen, Image.Name.MissileExplosion, 50, 50, 20, 20, new Azul.Color(0.0f, 1.0f, 0.0f, 1.0f));
            GameSpriteManager.Add(GameSprite.Name.MissileExplosionWhite, Image.Name.MissileExplosion, 50, 50, 20, 20);

            //----Bombs----
            GameSpriteManager.Add(GameSprite.Name.BombDagger, Image.Name.BombDagger, 50, 50, 10, 25);
            GameSpriteManager.Add(GameSprite.Name.BombZigZag, Image.Name.BombZigZag, 50, 50, 10, 25);
            GameSpriteManager.Add(GameSprite.Name.BombStraight, Image.Name.BombStraight, 50, 50, 10, 25);

            //----Shield----
            GameSpriteManager.Add(GameSprite.Name.ShieldBrick, Image.Name.ShieldBrick, 50, 25, 12, 7, new Azul.Color(0.0f, 1.0f, 0.0f, 1.0f));
            GameSpriteManager.Add(GameSprite.Name.ShieldBrick_LeftTop0, Image.Name.ShieldBrick_LeftTop0, 50, 25, 12, 7, new Azul.Color(0.0f, 1.0f, 0.0f, 1.0f));
            GameSpriteManager.Add(GameSprite.Name.ShieldBrick_LeftTop1, Image.Name.ShieldBrick_LeftTop1, 50, 25, 12, 7, new Azul.Color(0.0f, 1.0f, 0.0f, 1.0f));
            GameSpriteManager.Add(GameSprite.Name.ShieldBrick_LeftBottom, Image.Name.ShieldBrick_LeftBottom, 50, 25, 12, 7, new Azul.Color(0.0f, 1.0f, 0.0f, 1.0f));
            GameSpriteManager.Add(GameSprite.Name.ShieldBrick_RightTop0, Image.Name.ShieldBrick_RightTop0, 50, 25, 12, 7, new Azul.Color(0.0f, 1.0f, 0.0f, 1.0f));
            GameSpriteManager.Add(GameSprite.Name.ShieldBrick_RightTop1, Image.Name.ShieldBrick_RightTop1, 50, 25, 12, 7, new Azul.Color(0.0f, 1.0f, 0.0f, 1.0f));
            GameSpriteManager.Add(GameSprite.Name.ShieldBrick_RightBottom, Image.Name.ShieldBrick_RightBottom, 50, 25, 12, 7, new Azul.Color(0.0f, 1.0f, 0.0f, 1.0f));

            //----Ground----
            GameSpriteManager.Add(GameSprite.Name.Ground, Image.Name.ShieldBrick, 50, 50, SpaceInvaders.ScreenWidth - 10, 5, new Azul.Color(0.0f, 1.0f, 0.0f, 1.0f));

            //--------------------------------------------------------------------------
            //Create Scenes
            //--------------------------------------------------------------------------
            pHiScore      = 0;
            pPlayer1Score = 0;
            pPlayer2Score = 0;

            pSceneContext = new SceneContext();
        }
コード例 #11
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
            //---------------------------------------------------------------------------------------------------------

            ScenePlay2.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 AddP2PointsObserver());
            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 RemoveP2LifeObserver());
            pBombShipPair.Attach(new ChangeP2StateObserver());

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

            pAlienShieldPair.Attach(new RemoveBrickObserver());

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

            pAlienWallBottomPair.Attach(new DeadShipSoundObserver());
            pAlienWallBottomPair.Attach(new RemoveAllP2LivesObserver());
        }
コード例 #12
0
ファイル: ShipManager.cs プロジェクト: Smybarr/space_invaders
        private static Ship CreateShips()
        {
            ShipManager pShipMan = ShipManager.privInstance();

            Debug.Assert(pShipMan != null);

            // get the game object tree
            PCSTree rootGamObjTree = GameObjectManager.GetRootTree();

            Debug.Assert(rootGamObjTree != null);

            //create the root - coordinates are 0 since it's a root
            //ShipRoot pShipRoot = new ShipRoot(GameObject.Name.ShipRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f);
            //DeathManager.Attach(shipRoot);

            //todo find the ship object from loading instead of creating a new one
            // copy over safe copy (new or find precreated game object)

            //todo - refactor this using object pooling for ships - also will need more than these 3 ships w/ two player!
            //Create 3 ships total-----------------

            //create the starting ship;
            Ship pShip = new Ship(GameObject.Name.Ship, GameSprite.Name.Ship, 0, pShipMan.startShip_PosX, pShipMan.startShip_PosY);

            //set as the ship managers current ship
            pShipMan.pCurrentShip = pShip;

            // Attach the sprite to the correct sprite batch
            SpriteBatch pSB_GameSprites = SpriteBatchManager.Find(SpriteBatch.Name.GameSprites);
            SpriteBatch pSB_Boxes       = SpriteBatchManager.Find(SpriteBatch.Name.SpriteBoxes);

            pSB_GameSprites.Attach(pShip.pProxySprite);
            pShip.ActivateCollisionSprite(pSB_Boxes);


            // Attach the ship to the ship root
            // get the root (created before this function was called)
            GameObject pShipRoot = GameObjectManager.Find(GameObject.Name.ShipRoot);

            Debug.Assert(pShipRoot != null);

            // Add current ship tree to GameObject Tree - {update and collisions}
            rootGamObjTree.Insert(pShipMan.pCurrentShip, pShipRoot);

            //TESTING - CREATING 2 EXTRA SHIPS-------------------------------------------

            //extra ship one
            Ship pShipOne = new Ship(GameObject.Name.Ship, GameSprite.Name.Ship, 1, pShipMan.extraShipOne_X, pShipMan.extraShip_Y);

            //add to the ship tree as well as root game object tree
            rootGamObjTree.Insert(pShipOne, pShipMan.pCurrentShip);

            // Attach the sprite to the correct sprite batch

            pSB_GameSprites.Attach(pShipOne.pProxySprite);
            pShipOne.ActivateGameSprite(pSB_GameSprites);
            pShipOne.ActivateCollisionSprite(pSB_Boxes);

            //update the position of the new ship
            pShipOne.Update();

            //extra ship two
            Ship pShipTwo = new Ship(GameObject.Name.Ship, GameSprite.Name.Ship, 2, pShipMan.extraShipTwo_X, pShipMan.extraShip_Y);


            //add to the ship tree as well as root game object tree
            rootGamObjTree.Insert(pShipTwo, pShipOne);

            // Attach the sprite to the correct sprite batch
            pSB_GameSprites.Attach(pShipTwo.pProxySprite.pSprite);
            pShipTwo.ActivateGameSprite(pSB_GameSprites);
            pShipTwo.ActivateCollisionSprite(pSB_Boxes);

            //update the position of the new ship
            pShipTwo.Update();

            //END TESTING OF CREATING 2 EXTRA SHIPS-------------------------------------------


            //attach the shipRoot tree to the root game object tree
            //GameObjectManager.AttachTree(pShipRoot, rootGamObjTree);
            GameObjectManager.AttachTree(pShipRoot);

            return(pShipMan.pCurrentShip);
        }
コード例 #13
0
 public static void setInstance(GameObjectManager instance)
 {
     iGOMan = instance;
 }
コード例 #14
0
        public Bomb Create(Type type)
        {
            InvaderCategory pInvader = InvaderGridManager.GetRandomBombDropper(this.pInvaderGrid);
            Bomb            pBomb    = null;

            if (pInvader != null)
            {
                float posX = pInvader.x;
                float posY = pInvader.y;

                switch (type)
                {
                case Type.Plain:
                    pBomb = new Bomb(GameObject.Name.Bomb, Sprite.Name.BombPlain, BoxSprite.Name.BombBox, posX, posY);
                    break;

                case Type.ZigZag:
                    pBomb = new Bomb(GameObject.Name.Bomb, Sprite.Name.BombZigZag, BoxSprite.Name.BombBox, posX, posY);
                    break;

                case Type.Dagger:
                    pBomb = new Bomb(GameObject.Name.Bomb, Sprite.Name.BombDagger, BoxSprite.Name.BombBox, posX, posY);
                    break;

                case Type.Rolling:
                    pBomb = new Bomb(GameObject.Name.Bomb, Sprite.Name.BombRolling, BoxSprite.Name.BombBox, posX, posY);
                    break;

                default:
                    // something is wrong
                    Debug.Assert(false, "Bomb type not supported by this factory");
                    break;
                }

                // set pointer back to invader who dropped the bomb
                pBomb.pInvaderWhoDroppedMe = pInvader;
                pBomb.pInvaderWhoDroppedMe.canLaunchBomb = false; //block this invader from dropping another bomb until curren bomb dies

                // add it to the gameObjectManager
                Debug.Assert(pBomb != null);
                GameObjectManager.Attach(pBomb);

                // Attached to Batches
                this.pBoxSpriteBatch.Attach(pBomb.poColObj.pColSprite);
                this.pSpriteBatch.Attach(pBomb.pProxySprite);

                // Add Collision Pairs and Observers
                ColPair pMissile_BombColPair = ColPairManager.Add(ColPair.Name.Missile_Bomb, pBomb, ShipManager.GetMissile());
                Debug.Assert(pMissile_BombColPair != null);

                ColPair pBomb_FloorColPair = ColPairManager.Add(ColPair.Name.Bomb_Floor, pBomb, pWallMan.GetFloor());
                Debug.Assert(pBomb_FloorColPair != null);

                ColPair pBomb_ShipColPair = ColPairManager.Add(ColPair.Name.Bomb_Ship, pBomb, ShipManager.GetShip());
                Debug.Assert(pBomb_ShipColPair != null);

                // Observers for Bomb vs Missile
                pMissile_BombColPair.Attach(new RemoveCollisionPairObserver(pMissile_BombColPair));
                pMissile_BombColPair.Attach(new RemoveCollisionPairObserver(pBomb_FloorColPair));
                pMissile_BombColPair.Attach(new RemoveCollisionPairObserver(pBomb_ShipColPair));
                pMissile_BombColPair.Attach(new ShipMissileReadyObserver());
                pMissile_BombColPair.Attach(new ShipRemoveMissileObserver());
                pMissile_BombColPair.Attach(new RemoveBombObserver());

                //// Observers for Bomb vs Floor
                pBomb_FloorColPair.Attach(new RemoveCollisionPairObserver(pBomb_FloorColPair));
                pBomb_FloorColPair.Attach(new RemoveCollisionPairObserver(pMissile_BombColPair));
                pBomb_FloorColPair.Attach(new RemoveCollisionPairObserver(pBomb_ShipColPair));
                pBomb_FloorColPair.Attach(new RemoveBombObserver());

                // Observers for Bomb vs Ship
                pBomb_ShipColPair.Attach(new RemoveCollisionPairObserver(pBomb_ShipColPair));
                pBomb_ShipColPair.Attach(new RemoveCollisionPairObserver(pBomb_FloorColPair));
                pBomb_ShipColPair.Attach(new RemoveCollisionPairObserver(pMissile_BombColPair));
                pBomb_ShipColPair.Attach(new RemoveShipObserver());
                pBomb_ShipColPair.Attach(new RemoveBombObserver());


                GameObject pShieldZone = GameObjectManager.UnsafeFind(GameObject.Name.ShieldZone);
                if (pShieldZone != null)
                {
                    // Add Collision pair for Bomb vs Shields
                    ColPair pBomb_ShieldColPair = ColPairManager.Add(ColPair.Name.Bomb_Shield, pBomb, pShieldZone);
                    Debug.Assert(pBomb_ShieldColPair != null);

                    // Added observers to previous shield pairs to remove the bomb vs shield col pair
                    pMissile_BombColPair.Attach(new RemoveCollisionPairObserver(pBomb_ShieldColPair));
                    pBomb_FloorColPair.Attach(new RemoveCollisionPairObserver(pBomb_ShieldColPair));
                    pBomb_ShipColPair.Attach(new RemoveCollisionPairObserver(pBomb_ShieldColPair));

                    // Observers for Bomb vs Shield
                    pBomb_ShieldColPair.Attach(new RemoveCollisionPairObserver(pBomb_ShieldColPair));
                    pBomb_ShieldColPair.Attach(new RemoveCollisionPairObserver(pBomb_FloorColPair));
                    pBomb_ShieldColPair.Attach(new RemoveCollisionPairObserver(pMissile_BombColPair));
                    pBomb_ShieldColPair.Attach(new RemoveCollisionPairObserver(pBomb_ShipColPair));
                    pBomb_ShieldColPair.Attach(new RemoveBombObserver());
                    pBomb_ShieldColPair.Attach(new RemoveShieldBrickObserver());
                }
            }

            return(pBomb);
        }
コード例 #15
0
        public GameObject Recreate(ShieldCategory.Type type, GameObject.Name gameName, float posX = 0.0f, float posY = 0.0f)
        {
            GhostManager      pGhostManager      = GameStateManager.GetGame().GetStateGhostManager();
            GameObjectManager pGameObjectManager = GameStateManager.GetGame().GetStateGameObjectManager();

            GameObject pShield = null;

            switch (type)
            {
            case ShieldCategory.Type.Brick:
                pShield = pGhostManager.Find(GameObject.Name.ShieldBrick);
                break;

            case ShieldCategory.Type.LeftTop1:
                pShield = pGhostManager.Find(GameObject.Name.ShieldBrick_LeftTop1);
                break;

            case ShieldCategory.Type.LeftTop0:
                pShield = pGhostManager.Find(GameObject.Name.ShieldBrick_LeftTop0);
                break;

            case ShieldCategory.Type.LeftBottom:
                pShield = pGhostManager.Find(GameObject.Name.ShieldBrick_LeftBottom);
                break;

            case ShieldCategory.Type.RightTop1:
                pShield = pGhostManager.Find(GameObject.Name.ShieldBrick_RightTop1);
                break;

            case ShieldCategory.Type.RightTop0:
                pShield = pGhostManager.Find(GameObject.Name.ShieldBrick_RightTop0);
                break;

            case ShieldCategory.Type.RightBottom:
                pShield = pGhostManager.Find(GameObject.Name.ShieldBrick_RightBottom);
                break;

            case ShieldCategory.Type.Root:
                pShield = pGhostManager.Find(GameObject.Name.ShieldRoot);
                pShield.SetCollisionObjectLineColor(0.0f, 0.0f, 1.0f);
                break;

            case ShieldCategory.Type.Column:
                pShield = pGhostManager.Find(GameObject.Name.ShieldColumn);
                pShield.SetCollisionObjectLineColor(1.0f, 0.0f, 0.0f);
                break;

            default:
                // something is wrong
                Debug.Assert(false);
                break;
            }

            // Remove game object from ghost manager
            pGhostManager.Detach(pShield);

            // Reset position
            pShield.SetX(posX);
            pShield.SetY(posY);

            // Reset Collision Object
            Azul.Rect       pSpriteProxyScreenRect = pShield.GetSpriteProxy().GetSpriteScreenRect();
            CollisionObject pCollisionObject       = pShield.GetCollisionObject();

            pCollisionObject.GetCollisionRect().Set(pSpriteProxyScreenRect);
            pCollisionObject.GetCollisionSpriteBox().Set(SpriteBox.Name.Box, posX, posY, pSpriteProxyScreenRect.width, pSpriteProxyScreenRect.height);

            // Add to GameObjectManager
            GameStateManager.GetGame().GetStateGameObjectManager().Attach(pShield);

            // add to the tree
            this.pTree.Add(pShield);

            // Attached to Group
            pShield.ActivateSprite(this.pSpriteBatch);
            pShield.ActivateCollisionSprite(this.pCollisionSpriteBatch);

            return(pShield);
        }
コード例 #16
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);
        }
コード例 #17
0
 // Should be called during the Update part of gameloop
 public override void Update(GameManager pGameManager)
 {
     GameObjectManager.Update();
     InputManager.Update();
     DelayedObjectManager.Process();
 }
コード例 #18
0
        //-----------------------------------------------------------------------------
        // Game::LoadContent()
        //		Allows you to load all content needed for your engine,
        //	    such as objects, graphics, etc.
        //-----------------------------------------------------------------------------
        public override void LoadContent()
        {
            //---------------------------------------------------------------------------------------------------------
            // Manager initialization
            //---------------------------------------------------------------------------------------------------------
            TextureManager.Create(1, 1);
            ImageManager.Create(5, 2);
            GameSpriteManager.Create(4, 2);
            BoxSpriteManager.Create(3, 1);
            SpriteBatchManager.Create(3, 1);
            ProxySpriteManager.Create(10, 1);
            TimerManager.Create(3, 1);
            GameObjectManager.Create(3, 1);
            CollisionPairManager.Create(3, 1);
            InputManager.Create();
            SoundManager.Create();

            GlyphManager.Create(3, 1);
            FontManager.Create(3, 1);
            ScoreManager.Create();



            //---------------------------------------------------------------------------------------------------------
            // Load the Textures
            //---------------------------------------------------------------------------------------------------------
            TextureManager.Add(Texture.Name.Aliens, "aliens14x14.tga");
            TextureManager.Add(Texture.Name.Shield, "birds_N_shield.tga");
            TextureManager.Add(Texture.Name.Consolas36pt, "consolas36pt.tga");
            FontManager.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas36pt);

            //---------------------------------------------------------------------------------------------------------
            // Create Images
            //---------------------------------------------------------------------------------------------------------
            ImageManager.Add(Image.Name.Octopus0, Texture.Name.Aliens, 56, 28, 168, 112);
            ImageManager.Add(Image.Name.Octopus1, Texture.Name.Aliens, 56, 182, 168, 112);
            ImageManager.Add(Image.Name.Crab1, Texture.Name.Aliens, 322, 182, 154, 112);
            ImageManager.Add(Image.Name.Crab0, Texture.Name.Aliens, 322, 28, 154, 112);
            ImageManager.Add(Image.Name.Squid0, Texture.Name.Aliens, 616, 28, 112, 112);
            ImageManager.Add(Image.Name.Squid1, Texture.Name.Aliens, 616, 182, 112, 112);
            ImageManager.Add(Image.Name.UFO, Texture.Name.Aliens, 84, 504, 224, 98);
            ImageManager.Add(Image.Name.Missile, Texture.Name.Aliens, 378, 798, 14, 98);
            ImageManager.Add(Image.Name.Player, Texture.Name.Aliens, 57, 336, 182, 112);
            ImageManager.Add(Image.Name.BombCross, Texture.Name.Aliens, 196, 798, 42, 84);
            ImageManager.Add(Image.Name.BombStraight, Texture.Name.Aliens, 630, 798, 14, 98);
            ImageManager.Add(Image.Name.BombZigZag, Texture.Name.Aliens, 574, 644, 42, 98);

            ImageManager.Add(Image.Name.UFO_Explosion, Texture.Name.Aliens, 42, 643, 294, 112);
            ImageManager.Add(Image.Name.Player_Explosion1, Texture.Name.Aliens, 308, 336, 210, 112);
            ImageManager.Add(Image.Name.Player_Explosion2, Texture.Name.Aliens, 560, 336, 224, 112);
            ImageManager.Add(Image.Name.Missile_Explosion, Texture.Name.Aliens, 406, 490, 112, 112);
            ImageManager.Add(Image.Name.Alien_Explosion2, Texture.Name.Aliens, 574, 490, 182, 112);
            ImageManager.Add(Image.Name.Bomb_Explosion, Texture.Name.Aliens, 700, 798, 84, 112);

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



            //---------------------------------------------------------------------------------------------------------
            // Create Sprites
            //---------------------------------------------------------------------------------------------------------
            GameSpriteManager.Add(GameSprite.Name.Squid, Image.Name.Squid0, 400, 200, Constant.ALIEN_WIDTH - 10, Constant.ALIEN_HEIGHT);
            GameSpriteManager.Add(GameSprite.Name.Octopus, Image.Name.Octopus0, 50, 500, Constant.ALIEN_WIDTH, Constant.ALIEN_HEIGHT);
            GameSpriteManager.Add(GameSprite.Name.Crab, Image.Name.Crab0, 100, 300, Constant.ALIEN_WIDTH, Constant.ALIEN_HEIGHT);
            GameSpriteManager.Add(GameSprite.Name.Missile, Image.Name.Missile, Constant.WINDOW_WIDTH / 2, 0, 4, 20);
            GameSpriteManager.Add(GameSprite.Name.Player, Image.Name.Player, Constant.WINDOW_WIDTH / 2, 30, 40.0f, 25.0f);
            GameSpriteManager.Add(GameSprite.Name.BombStraight, Image.Name.BombStraight, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, 6, 25.0f);
            GameSpriteManager.Add(GameSprite.Name.BombCross, Image.Name.BombCross, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, 6, 25.0f);
            GameSpriteManager.Add(GameSprite.Name.BombZigZag, Image.Name.BombZigZag, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, 6, 25.0f);
            GameSpriteManager.Add(GameSprite.Name.UFO, Image.Name.UFO, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, 40, 20);
            GameSpriteManager.Add(GameSprite.Name.Missile_Explosion, Image.Name.Missile_Explosion, 0, 0, 10, 10);

            GameSpriteManager.Add(GameSprite.Name.UFO_Explosion, Image.Name.UFO_Explosion, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, 40, 20);
            GameSpriteManager.Add(GameSprite.Name.Player_Explosion, Image.Name.Player_Explosion1, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, 40, 25.0f);
            GameSpriteManager.Add(GameSprite.Name.Bomb_Explosion, Image.Name.Bomb_Explosion, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, 10, 10);
            GameSpriteManager.Add(GameSprite.Name.Alien_Explosion, Image.Name.Alien_Explosion2, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, Constant.ALIEN_WIDTH, Constant.ALIEN_HEIGHT);


            GameSpriteManager.Add(GameSprite.Name.Brick, Image.Name.Brick, 50, 25, Constant.SHIELD_BRICK_WIDTH, Constant.SHIELD_BRICK_HEIGHT);
            GameSpriteManager.Add(GameSprite.Name.BrickLeft_Top0, Image.Name.BrickLeft_Top0, 50, 25, Constant.SHIELD_BRICK_WIDTH, Constant.SHIELD_BRICK_HEIGHT);
            GameSpriteManager.Add(GameSprite.Name.BrickLeft_Top1, Image.Name.BrickLeft_Top1, 50, 25, Constant.SHIELD_BRICK_WIDTH, Constant.SHIELD_BRICK_HEIGHT);
            GameSpriteManager.Add(GameSprite.Name.BrickLeft_Bottom, Image.Name.BrickLeft_Bottom, 50, 25, Constant.SHIELD_BRICK_WIDTH, Constant.SHIELD_BRICK_HEIGHT);
            GameSpriteManager.Add(GameSprite.Name.BrickRight_Top0, Image.Name.BrickRight_Top0, 50, 25, Constant.SHIELD_BRICK_WIDTH, Constant.SHIELD_BRICK_HEIGHT);
            GameSpriteManager.Add(GameSprite.Name.BrickRight_Top1, Image.Name.BrickRight_Top1, 50, 25, Constant.SHIELD_BRICK_WIDTH, Constant.SHIELD_BRICK_HEIGHT);
            GameSpriteManager.Add(GameSprite.Name.BrickRight_Bottom, Image.Name.BrickRight_Bottom, 50, 25, Constant.SHIELD_BRICK_WIDTH, Constant.SHIELD_BRICK_HEIGHT);



            //---------------------------------------------------------------------------------------------------------
            // Create SpriteBatch
            //---------------------------------------------------------------------------------------------------------
            SpriteBatch pSB_Aliens  = SpriteBatchManager.Add(SpriteBatch.Name.GameSprites);
            SpriteBatch pSB_Boxes   = SpriteBatchManager.Add(SpriteBatch.Name.BoxSprites);
            SpriteBatch pSB_Shields = SpriteBatchManager.Add(SpriteBatch.Name.ShieldSprites);
            SpriteBatch pSB_Bombs   = SpriteBatchManager.Add(SpriteBatch.Name.BombSprites);
            SpriteBatch pSB_Texts   = SpriteBatchManager.Add(SpriteBatch.Name.TextSprite);
            SpriteBatch pSB_Effect  = SpriteBatchManager.Add(SpriteBatch.Name.ExplosionEffectSprite);

            pSB_Boxes.GetSBNodeManager().ToggleDraw();

            AlienGroup pAlienGroup = new AlienGroup(GameObject.Name.AlienGroup, GameSprite.Name.NullObject, -1, 0.0f, 0.0f);

            pSB_Boxes.Attach(pAlienGroup.pColObject.pBoxSprite);
            GameObjectManager.Attach(pAlienGroup);

            ShieldGroup pShieldGroup = new ShieldGroup(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, -1, 0.0f, 0.0f);

            pSB_Boxes.Attach(pShieldGroup.pColObject.pBoxSprite);
            GameObjectManager.Attach(pShieldGroup);

            AlienManager.Create();
            ShieldNodeManager.Create();

            GameSceneManager.Create();
            GameScene.Create();
            GameScene.SetGameScene(GameState.SceneName.Select);
        }