Пример #1
0
        public static Missile ActivateMissile()
        {
            ShipManager shipMan = ShipManager.GetInstance();

            PCSTree pcsTree = GameObjectManager.GetRootTree();

            Debug.Assert(pcsTree != null);

            Missile pMissile = new Missile(GameObjectName.Missile, SpriteBaseName.Missile, 400.0f, 100.0f, 0);

            pMissile.pProxySprite.pSprite.SetColor(ColorFactory.Create(ColorName.Green).pAzulColor);
            shipMan.pMissile = pMissile;

            SpriteBatch sbAliens = SpriteBatchManager.Find(SpriteBatchName.Aliens);
            SpriteBatch sbBoxes  = SpriteBatchManager.Find(SpriteBatchName.Boxes);

            pMissile.ActivateCollisionSprite(sbBoxes);
            pMissile.ActivateGameSprite(sbAliens);

            GameObject pMissileRoot = GameObjectManager.Find(GameObjectName.MissileRoot);

            Debug.Assert(pMissileRoot != null);

            pcsTree.Insert(shipMan.pMissile, pMissileRoot);

            return(shipMan.pMissile);
        }
Пример #2
0
        public static Ship ActivateShip(bool isCollisionBoxActive)
        {
            ShipManager shipMan = ShipManager.GetInstance();

            PCSTree pcsTree = GameObjectManager.GetRootTree();

            Debug.Assert(pcsTree != null);

            Ship pShip = new Ship(GameObjectName.Ship, SpriteBaseName.Ship, 150.0f, 100.0f);

            shipMan.pShip = pShip;

            SpriteBatch sbAliens = SpriteBatchManager.Find(SpriteBatchName.Aliens);
            SpriteBatch sbBoxes  = SpriteBatchManager.Find(SpriteBatchName.Boxes);

            if (isCollisionBoxActive)
            {
                pShip.ActivateCollisionSprite(sbBoxes);
            }
            pShip.ActivateGameSprite(sbAliens);
            //sbAliens.Attach(pShip.pProxySprite);

            GameObject pShipRoot = GameObjectManager.Find(GameObjectName.ShipRoot);

            Debug.Assert(pShipRoot != null);
            pShip.Update();
            pcsTree.Insert(shipMan.pShip, pShipRoot);
            return(shipMan.pShip);
        }
Пример #3
0
        public static void DropBomb()
        {
            UFOManager ufoMan  = UFOManager.GetInstance();
            UFO        ufo     = ufoMan.pUFO;
            PCSTree    pcsTree = GameObjectManager.GetRootTree();

            Debug.Assert(pcsTree != null);

            Bomb pBomb = new Bomb(GameObjectName.UFOBomb, SpriteBaseName.UFOBomb, new FallStraight(), ufo.x, ufo.y, 0);

            pBomb.pProxySprite.pSprite.SetColor(ColorFactory.Create(ColorName.Red).pAzulColor);
            ufoMan.pBomb = pBomb;

            SpriteBatch sbAliens = SpriteBatchManager.Find(SpriteBatchName.Aliens);
            SpriteBatch sbBoxes  = SpriteBatchManager.Find(SpriteBatchName.Boxes);

            pBomb.ActivateCollisionSprite(sbBoxes);
            pBomb.ActivateGameSprite(sbAliens);

            GameObject pBombRoot = GameObjectManager.Find(GameObjectName.BombRoot);

            Debug.Assert(pBombRoot != null);

            pcsTree.Insert(ufoMan.pBomb, pBombRoot);
            SetUFOBombActive(true);
            Debug.WriteLine("UFO Bomb dropped!");
        }
Пример #4
0
        public static UFO ActivateUFO(bool isCollisionBoxActive)
        {
            Debug.WriteLine("UFO has been activated!");
            UFOManager ufoMan = UFOManager.GetInstance();

            PCSTree pcsTree = GameObjectManager.GetRootTree();

            Debug.Assert(pcsTree != null);

            UFOStrategy strat = new UFOMoveRight();
            float       x     = -10.0f;

            if (pRandom.Next(0, 2) == 0)
            {
                strat = new UFOMoveLeft();
                x     = 915.0f;
            }

            UFO pUFO = new UFO(GameObjectName.UFO, SpriteBaseName.UFO, strat, x, 905.0f);

            ufoMan.pUFO = pUFO;

            UFORoot     pUFORoot = (UFORoot)GameObjectManager.Find(GameObjectName.UFORoot);
            SpriteBatch sbAliens = SpriteBatchManager.Find(SpriteBatchName.Aliens);
            SpriteBatch sbBoxes  = SpriteBatchManager.Find(SpriteBatchName.Boxes);

            if (isCollisionBoxActive)
            {
                pUFO.ActivateCollisionSprite(sbBoxes);
            }
            pUFO.ActivateGameSprite(sbAliens);
            pcsTree.Insert(ufoMan.pUFO, pUFORoot);
            SetUFOActive(true);
            return(ufoMan.pUFO);
        }
Пример #5
0
        //called from column ( (GameObject)this.pParent );
        public override void DropBomb()
        {
            float bomb_startPosX = this.x;
            float bomb_startPosY = this.y;

            //Bomb pBomb = new Bomb(GameObject.Name.Bomb, GameSprite.Name.CrossAlienBomb, new FallStraight(), 0, bomb_startPosX, bomb_startPosY);
            //Debug.Assert(pBomb != null);
            Random r = new Random();
            int    randomBombType = r.Next(1, 4);

            Bomb pBomb = privCreateBomb(randomBombType, bomb_startPosX, bomb_startPosY);

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

            Debug.Assert(rootGamObjTree != null);

            //find the bomb root
            GameObject pBombRoot = GameObjectManager.Find(GameObject.Name.BombRoot);

            Debug.Assert(pBombRoot != null);

            rootGamObjTree.Insert(pBomb, pBombRoot);

            //activate the sprites
            SpriteBatch pSB_GameSprites = SpriteBatchManager.Find(SpriteBatch.Name.GameSprites);
            SpriteBatch pSB_Boxes       = SpriteBatchManager.Find(SpriteBatch.Name.SpriteBoxes);

            pBomb.ActivateGameSprite(pSB_GameSprites);
            pBomb.ActivateCollisionSprite(pSB_Boxes);
        }
Пример #6
0
        public static Missile ActivateMissile()
        {
            ShipManager pShipMan = ShipManager.privInstance();

            Debug.Assert(pShipMan != null);

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

            Debug.Assert(pTree != null);

            //create a new missile!!

            // copy over safe copy (create a new one or find in game object tree)
            Missile pMissile = new Missile(GameObject.Name.Missile, GameSprite.Name.Missile, 0, 400, 100);

            pShipMan.pMissile = pMissile;

            // Attach missile to SpriteBatches
            SpriteBatch pSB_Aliens = SpriteBatchManager.Find(SpriteBatch.Name.GameSprites);
            SpriteBatch pSB_Boxes  = SpriteBatchManager.Find(SpriteBatch.Name.SpriteBoxes);

            pMissile.ActivateCollisionSprite(pSB_Boxes);
            pMissile.ActivateGameSprite(pSB_Aliens);

            // Attach the missile to the missile root
            GameObject pMissileRoot = GameObjectManager.Find(GameObject.Name.MissileRoot);

            Debug.Assert(pMissileRoot != null);

            // Add to GameObject Tree - {update and collisions}
            pTree.Insert(pShipMan.pMissile, pMissileRoot);

            return(pShipMan.pMissile);
        }
Пример #7
0
 public BombFactory(SpriteBatchName sbName, PCSTree tree)
 {
     this.pSpriteBatch = SpriteBatchManager.Find(sbName);
     Debug.Assert(this.pSpriteBatch != null);
     this.pTree = tree;
     Debug.Assert(this.pTree != null);
 }
Пример #8
0
 public AlienFactory(SpriteBatchName sbName, PCSTree tree)
 {
     this.pSpriteBatch    = SpriteBatchManager.Find(sbName);
     this.pSpriteBoxBatch = SpriteBatchManager.Find(SpriteBatchName.Boxes);
     Debug.Assert(this.pSpriteBatch != null);
     this.pTree = tree;
 }
        public void associateBombs()
        {
            UFO ufo = (UFO)FactoryManager.getUfoFactry().cParent.pChild;

            if (ufo.launch)
            {
                if (ufo.x > 50)
                {
                    Random random = new Random(DateTime.UtcNow.Millisecond);
                    int    number = random.Next(1, 3);

                    if (number == 2)
                    {
                        Bomb bomb = getActivatedBomb();
                        bomb.x     = ufo.x;
                        bomb.y     = ufo.y;
                        associated = true;
                    }
                }
            }
            if (!associated)
            {
                int colCount = FactoryManager.getAlienFactry().columnCount;
                if (colCount > 0)
                {
                    Random     random        = new Random(DateTime.UtcNow.Millisecond);
                    int        number        = random.Next(1, colCount);
                    PCSTree    columnPcsTree = FactoryManager.getAlienFactry().cPCSTree;
                    GameObject column        = (GameObject)columnPcsTree.getRoot().pChild;

                    while (column != null)
                    {
                        number--;
                        if (number == 0)
                        {
                            GameObject alien = (GameObject)column.pChild;

                            if (bomb == null)
                            {
                                Bomb bomb = getActivatedBomb();
                                //bomb = (Bomb)GhostManager.find(GameObject.GameObjectName.Bomb);

                                //GhostManager.remove(bomb);
                                //BombFactory bombF = FactoryManager.getBombFactry();
                                //bombF.activate(bomb);
                                if (bomb == null)
                                {
                                    Debug.WriteLine("bomb null");
                                }
                            }
                            bomb.x = alien.x;
                            bomb.y = alien.y;
                            break;
                        }
                        column = (GameObject)column.pSibling;
                    }
                }
            }
            associated = false;
        }
Пример #10
0
        public void PopulateAlienGrid(float gridHeight)
        {
            //---------------------------------------------------------------------------------------------------------
            // Create GameObjects via AlienFactory
            //---------------------------------------------------------------------------------------------------------
            PCSTree      pAlienTree   = new PCSTree();
            AlienFactory alienFactory = new AlienFactory(SpriteBatchName.Aliens, pAlienTree, new Random());

            alienFactory.SetParent(null);
            Alien pGridRoot = alienFactory.Create(AlienType.Grid, GameObjectName.Grid);
            Grid  pGrid     = (Grid)pGridRoot;

            pGrid.marchSpeed    = 0.75f;
            pGrid.bombFrequency = 1.0f;
            for (int i = 0; i < 11; i++)
            {
                int additive = _horizontalSpace * i;
                alienFactory.SetParent(pGridRoot);
                Alien pColumn = alienFactory.Create(AlienType.Column, GameObjectName.Column, i, 0.0f, 0.0f);
                alienFactory.SetParent(pColumn);
                alienFactory.Create(AlienType.Squid, GameObjectName.Squid, i, 51.0f + additive, gridHeight);
                alienFactory.Create(AlienType.Crab, GameObjectName.Crab, i + 11, 51.5f + additive, gridHeight - 75.0f);
                alienFactory.Create(AlienType.Crab, GameObjectName.Crab, i, 51.5f + additive, gridHeight - 150.0f);
                alienFactory.Create(AlienType.Octopus, GameObjectName.Octopus, i + 11, 51.5f + additive, gridHeight - 225.0f);
                alienFactory.Create(AlienType.Octopus, GameObjectName.Octopus, i, 51.5f + additive, gridHeight - 300.0f);
                Column col = (Column)pColumn;
                col.alienCount   += 5;
                pGrid.alienCount += 5;
                pGrid.colCount++;
            }
            GameObjectManager.AttachTree(pGridRoot);
        }
Пример #11
0
        public static void Remove(GameObject pNode)
        {
            Debug.Assert(pNode != null);
            GameObjectManager pMan        = GameObjectManager.GetInstance();
            GameObject        pSafetyNode = pNode;
            GameObject        pTmp        = pNode;
            GameObject        pRoot       = null;

            while (pTmp != null)
            {
                pRoot = pTmp;
                pTmp  = (GameObject)pTmp.pParent;
            }
            GameObjectNode pTree = (GameObjectNode)pMan.pActive;

            while (pTree != null)
            {
                if (pTree.pGameObject == pRoot)
                {
                    break;
                }
                pTree = (GameObjectNode)pTree.pDNext;
            }
            Debug.Assert(pTree != null);
            Debug.Assert(pTree.pGameObject != null);
            pMan.pRoot.SetRoot(pTree.pGameObject);
            pMan.pRoot.Remove(pNode);
        }
Пример #12
0
 public WallFactory(PCSTree mPCSTree, SpriteBatch mSpriteBatch)
 {
     this.cPCSTree = mPCSTree;
     // this.cSpriteBatch = SpriteBatchManager.find(mSpriteBatch);
     this.cSpriteBatch = mSpriteBatch;
     cParent           = null;
 }
Пример #13
0
        private void SpawnBomb()
        {
            int    random  = this.pGrid.pRandom.Next(0, pGrid.colCount);
            Column pColumn = pGrid.GetColumn(random);

            //Debug.WriteLine("Firing from Column{0}", random);
            if (pColumn != null)
            {
                PCSTree        pTree  = GameObjectManager.GetRootTree();
                SpriteBaseName sName  = SpriteBaseName.Null;
                FallStrategy   pStrat = null;
                switch (pGrid.pRandom.Next(0, 3))
                {
                case 0:
                    sName  = SpriteBaseName.BombStraight;
                    pStrat = new FallStraight();
                    break;

                case 1:
                    sName  = SpriteBaseName.BombDagger;
                    pStrat = new FallDagger();
                    break;

                case 2:
                default:
                    sName  = SpriteBaseName.BombZigZag;
                    pStrat = new FallZigZag();
                    break;
                }
                Bomb pBomb = new Bomb(GameObjectName.Bomb, sName, pStrat, pColumn.x, pColumn.pCollisionObject.pCollisionRect.minY, 0);
                pBomb.ActivateCollisionSprite(this.sbBoxes);
                pBomb.ActivateGameSprite(this.sbAliens);
                pTree.Insert(pBomb, this.pBombRoot);
            }
        }
Пример #14
0
        public static GameObject Find(GameObjectName goName, int index = 0)
        {
            GameObjectManager goMan    = GameObjectManager.GetInstance();
            GameObjectNode    pRoot    = (GameObjectNode)goMan.pActive;
            GameObject        pGameObj = null;

            bool found = false;

            while (pRoot != null && found == false)
            {
                PCSTreeForwardIterator iter = new PCSTreeForwardIterator(pRoot.pGameObject);
                pGameObj = (GameObject)iter.First();

                while (!iter.IsDone())
                {
                    if ((pGameObj.gameObjectName == goName) && (pGameObj.index == index))
                    {
                        found = true;
                        break;
                    }
                    pGameObj = (GameObject)iter.Next();
                }
                pRoot = (GameObjectNode)pRoot.pDNext;
            }
            return(pGameObj);
        }
Пример #15
0
        public override void load()
        {
            Unit.level2Start();

            AlienFactory alienFactory = FactoryManager.getAlienFactry();
            AlienGrid    alienGrid    = (AlienGrid)FactoryManager.getAlienFactry().cPCSTree.getRoot();

            alienGrid.updateDelta();
            PCSTree     pcsTree      = FactoryManager.getAlienFactry().cPCSTree;
            SpriteBatch cSpriteBatch = FactoryManager.getAlienFactry().cSpriteBatch;

            for (int i = 0; i < 11; i++)
            {
                FactoryManager.getAlienFactry().setParent(alienGrid);
                Alien pColumn = (Alien)GhostManager.find(GameObject.GameObjectName.Column);
                GhostManager.remove(pColumn);

                pColumn.set(Sprite.SpriteName.NullObject, i + 1, 0, 0);
                alienFactory.activate(pColumn);
                alienFactory.setParent(pColumn);

                float x = Unit.alienPosX;
                float y = Unit.alienPosY;

                Alien alien = (Alien)GhostManager.find(GameObject.GameObjectName.Crab);
                GhostManager.remove(alien);
                alien.set(Sprite.SpriteName.Crab, i + 2, x + i * 60.0f, y);
                alienFactory.activate(alien);

                Alien alien2 = (Alien)GhostManager.find(GameObject.GameObjectName.Squid);
                GhostManager.remove(alien2);
                alien2.set(Sprite.SpriteName.Squid, i + 2, x + i * 60.0f, y - 60);
                alienFactory.activate(alien2);

                Alien alien3 = (Alien)GhostManager.find(GameObject.GameObjectName.Squid);
                GhostManager.remove(alien3);
                alien3.set(Sprite.SpriteName.Squid, i + 2, x + i * 60.0f, y - 120);
                alienFactory.activate(alien3);

                Alien alien4 = (Alien)GhostManager.find(GameObject.GameObjectName.Octopus);
                GhostManager.remove(alien4);
                alien4.set(Sprite.SpriteName.Octopus, i + 2, x + i * 60.0f, y - 180);
                alienFactory.activate(alien4);

                Alien alien5 = (Alien)GhostManager.find(GameObject.GameObjectName.Octopus);
                GhostManager.remove(alien5);
                alien5.set(Sprite.SpriteName.Octopus, i + 6, x + i * 60.0f, y - 240);
                alienFactory.activate(alien5);


                //  alienFactory.createAlien(Alien.AlienType.Squid, GameObject.GameObjectName.Squid, i + 3, x + i * 60.0f, y - 60);

                // alienFactory.createAlien(Alien.AlienType.Squid, GameObject.GameObjectName.Squid, i+4, x + i * 60.0f, y-120);

                // alienFactory.createAlien(Alien.AlienType.Octopus, GameObject.GameObjectName.Octopus, i+5, x + i * 60.0f, y-180);

                // alienFactory.createAlien(Alien.AlienType.Octopus, GameObject.GameObjectName.Octopus, i+6, x + i * 60.0f, y-240);
            }
        }
        public void set(GameObject pGameObject, PCSTree pTree)
        {
            Debug.Assert(pGameObject != null);
            this.rcGameObject = pGameObject;

            Debug.Assert(pTree != null);
            this.cTree = pTree;
        }
Пример #17
0
 public AlienFactory(SpriteBatchName sbName, PCSTree tree, Random random)
 {
     this.pSpriteBatch = SpriteBatchManager.Find(sbName);
     Debug.Assert(this.pSpriteBatch != null);
     this.pTree = tree;
     Debug.Assert(this.pTree != null);
     this.pRandom = random;
 }
Пример #18
0
 public AlienFactory(PCSTree mPCSTree, SpriteBatch mSpriteBatch)
 {
     this.cPCSTree = mPCSTree;
     //this.cSpriteBatch = SpriteBatchManager.find(mSpriteBatch);
     this.cSpriteBatch = mSpriteBatch;
     cParent           = null;
     columnCount       = 0;
     alienCount        = 0;
 }
Пример #19
0
        public ShieldFactory(SpriteBatch.Name spriteBatchName, SpriteBatch.Name collisionSpriteBatch, PCSTree pTree)
        {
            this.pSpriteBatch = SpriteBatchManager.Find(spriteBatchName);
            Debug.Assert(this.pSpriteBatch != null);

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

            Debug.Assert(pTree != null);
            this.pTree = pTree;
        }
Пример #20
0
        public AlienFactory(SpriteBatch.Name spriteBatchName, PCSTree pTree)
        {
            this.pSpriteBatch = SpriteBatchManager.Find(spriteBatchName);
            Debug.Assert(this.pSpriteBatch != null);

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

            //parent is null by default;
            this.pParent = null;
        }
Пример #21
0
        public override void execute(float currentTime)
        {
            PCSTree pTree = GameObjectManager.GetRootTree();

            float value = pRandom.Next(100, 760);
            Bomb  pBomb = new Bomb(GameObjectName.Bomb, SpriteBaseName.BombStraight, new FallStraight(), value, 850.0f, 0);

            pBomb.ActivateCollisionSprite(this.sbBoxes);
            pBomb.ActivateGameSprite(this.sbAliens);
            pTree.Insert(pBomb, pBombRoot);
        }
Пример #22
0
        //changed
        public static GameObjectNode add(GameObject mGameObj, PCSTree mTree)
        {
            Debug.Assert(mGameObj != null);
            Debug.Assert(mTree != null);

            GameObjectNodeManager goNInstance = GameObjectNodeManager.getSingletonInstance();

            Debug.Assert(gamMInstance != null);

            GameObjectNode goNode = (GameObjectNode)gamMInstance.genericAdd();

            Debug.Assert(goNode != null);

            goNode.set(mGameObj, mTree);
            return(goNode);
        }
Пример #23
0
        private GameObjectManager(int startReserveSize = 3, int refillSize = 1)
            : base(startReserveSize, refillSize)
        {
            //default null game object as ref node to avoid breaking find;
            GameObject pGameObj = new NullGameObject();

            Debug.Assert(pGameObj != null);
            GameObjectManager.pRefNode.pGameObj = pGameObj;


            //Todo - GameObjectManager Constructor - used in remove: HACK HACK, need a better way
            this.pRootTree = new PCSTree();
            //make sure tree and its root were created
            Debug.Assert(this.pRootTree != null);
            Debug.Assert(this.pRootTree.GetRoot() != null);
        }
Пример #24
0
        public override void Update()
        {
            int lives = ScoreManager.UpdateLives();

            if (lives == 0)
            {
                Debug.WriteLine("Game Over!");
            }
            else
            {
                PCSTree     pRootTree = GameObjectManager.GetRootTree();
                SpriteBatch sbBoxes   = SpriteBatchManager.Find(SpriteBatchName.Boxes);
                SpriteBatch sbAliens  = SpriteBatchManager.Find(SpriteBatchName.Aliens);
                //MissileRoot pMissileRoot = new MissileRoot(GameObjectName.MissileRoot, SpriteBaseName.Null, 0.0f, 0.0f, 0);
                //pMissileRoot.ActivateCollisionSprite(sbBoxes);
                ShipRoot pShipRoot = (ShipRoot)GameObjectManager.Find(GameObjectName.ShipRoot);
                pShipRoot.ActivateCollisionSprite(sbBoxes);
                pShipRoot.ActivateGameSprite(sbAliens);
                ShipManager.Create();
                AnimationSprite animSpriteSquids = new AnimationSprite(SpriteBaseName.Squid);
                animSpriteSquids.Attach(ImageName.SquidA);
                animSpriteSquids.Attach(ImageName.SquidB);
                AnimationSprite animSpriteCrabs = new AnimationSprite(SpriteBaseName.Crab);
                animSpriteCrabs.Attach(ImageName.CrabA);
                animSpriteCrabs.Attach(ImageName.CrabB);
                AnimationSprite animSpriteOctopi = new AnimationSprite(SpriteBaseName.Octopus);
                animSpriteOctopi.Attach(ImageName.OctopusA);
                animSpriteOctopi.Attach(ImageName.OctopusB);
                SoundCommand playFastInvader1 = new SoundCommand(SoundName.fastInvader1);
                SoundCommand playFastInvader2 = new SoundCommand(SoundName.fastInvader2);
                SoundCommand playFastInvader3 = new SoundCommand(SoundName.fastInvader3);
                SoundCommand playFastInvader4 = new SoundCommand(SoundName.fastInvader4);
                Grid         pGrid            = (Grid)GameObjectManager.Find(GameObjectName.Grid);
                float        marchSpeed       = pGrid.marchSpeed;
                TimerManager.Add(TimerEventName.MoveGrid, marchSpeed, marchSpeed, new MoveGridEvent());
                TimerManager.Add(TimerEventName.AnimateSquids, marchSpeed, marchSpeed, animSpriteSquids);
                TimerManager.Add(TimerEventName.AnimateCrabs, marchSpeed, marchSpeed, animSpriteCrabs);
                TimerManager.Add(TimerEventName.AnimateOctopi, marchSpeed, marchSpeed, animSpriteOctopi);
                TimerManager.Add(TimerEventName.PlayFastInvaders4, marchSpeed, 4 * marchSpeed, playFastInvader4);
                TimerManager.Add(TimerEventName.PlayFastInvaders1, 2 * marchSpeed, 4 * marchSpeed, playFastInvader1);
                TimerManager.Add(TimerEventName.PlayFastInvaders2, 3 * marchSpeed, 4 * marchSpeed, playFastInvader2);
                TimerManager.Add(TimerEventName.PlayFastInvaders3, 4 * marchSpeed, 4 * marchSpeed, playFastInvader3);
                TimerManager.Add(TimerEventName.BombSpawn, 1.0f, 1.0f, new BombSpawnEvent(pGrid));
            }
        }
Пример #25
0
        public static StraightMissile activateMissile()
        {
            ShipManager shipMan = ShipManager.getSingleton();

            Debug.Assert(shipMan != null);

            GameObjectNode gon     = GameObjectNodeManager.findGameObjectNode(GameObject.GameObjectName.MissileRoot);
            PCSTree        pcsTree = gon.getPCSTree();
            GameObject     gameObj = gon.getGameObject();

            Debug.Assert(pcsTree != null);
            Debug.Assert(gameObj != null);

            // StraightMissile missile = new StraightMissile(GameObject.GameObjectName.StraightMissile, Sprite.SpriteName.Straight, 1, 400, 100f,Missile.MissileType.Straight);

            ///to do
            StraightMissile missile = (StraightMissile)FactoryManager.getMissileFactry().createMissile(Missile.MissileType.StraightMissile, GameObject.GameObjectName.StraightMissile, 1, 300, 200);

            //StraightMissile missile = (StraightMissile)GhostManager.find(GameObject.GameObjectName.StraightMissile);
            //if(missile==null)
            //{
            //   missile = (StraightMissile)FactoryManager.getMissileFactry().createMissile(Missile.MissileType.StraightMissile, GameObject.GameObjectName.StraightMissile, 1, 300, 200);
            //}
            //StraightMissile missile = (StraightMissile)GhostManager.find(GameObject.GameObjectName.StraightMissile);

            shipMan.missile = missile;

            //  SpriteBatch missileBatch = SpriteBatchManager.find(SpriteBatch.SpriteBatchName.Missiles);
            //  SpriteBatch boxBatch = SpriteBatchManager.find(SpriteBatch.SpriteBatchName.Boxes);

            //  Debug.Assert(missileBatch != null);
            //  Debug.Assert(boxBatch != null);

            // missile.addSpriteToBatch(missileBatch);
            //  missile.addCollisionToBatch(boxBatch);
            GameObject pMissileRoot = GameObjectNodeManager.find(GameObject.GameObjectName.MissileRoot);

            Debug.Assert(pMissileRoot != null);
            ///////////////////////////Not sure
            // pcsTree.Insert(missile, pMissileRoot);
            // pcsTree.GetRoot.
            pMissileRoot.update();

            return(missile);
        }
Пример #26
0
        private FactoryManager()
        {
            SpriteBatch alienBatch   = SpriteBatchManager.add(SpriteBatch.SpriteBatchName.Aliens);
            PCSTree     alienPcsTree = new PCSTree();

            this.alienFactory = new AlienFactory(alienPcsTree, alienBatch);

            SpriteBatch bombBatch   = SpriteBatchManager.add(SpriteBatch.SpriteBatchName.Bombs);
            PCSTree     bombPcsTree = new PCSTree();

            this.bombFactory = new BombFactory(bombPcsTree, bombBatch);

            SpriteBatch missileBatch   = SpriteBatchManager.add(SpriteBatch.SpriteBatchName.Missiles);
            PCSTree     missilePcsTree = new PCSTree();

            this.missileFactory = new MissileFactory(missilePcsTree, missileBatch);


            SpriteBatch shieldBatch   = SpriteBatchManager.add(SpriteBatch.SpriteBatchName.Shields);
            PCSTree     shieldPcsTree = new PCSTree();

            this.shieldFactory = new ShieldFactory(shieldPcsTree, shieldBatch);

            SpriteBatch shipBatch   = SpriteBatchManager.add(SpriteBatch.SpriteBatchName.Ships);
            PCSTree     shipPcsTree = new PCSTree();

            this.shipFactory = new ShipFactory(shipPcsTree, shipBatch);

            SpriteBatch wallBatch   = SpriteBatchManager.add(SpriteBatch.SpriteBatchName.Walls);
            PCSTree     wallPcsTree = new PCSTree();

            this.wallFactory = new WallFactory(wallPcsTree, wallBatch);


            SpriteBatch ufoBatch   = SpriteBatchManager.add(SpriteBatch.SpriteBatchName.UFOs);
            PCSTree     ufoPcsTree = new PCSTree();

            this.ufoFactory = new UFOFactory(ufoPcsTree, ufoBatch);

            sndEngine = new IrrKlang.ISoundEngine();
        }
Пример #27
0
        public override void Update()
        {
            //Debug.WriteLine("RemoveShipObserver: {0} {1}", this.pSubject.goA, this.pSubject.goB);
            GameObject ship = ShipManager.GetShip();

            if (ship != null)
            {
                ship.Remove();
                GameObject pShipRoot = GameObjectManager.Find(GameObjectName.ShipRoot);
                pShipRoot.Remove();
            }
            Alien       pExplosion = new Explosion(GameObjectName.Explosion, SpriteBaseName.Explosion, AlienType.Explosion, ship, ColorName.Green, 0);
            SpriteBatch sbAliens   = SpriteBatchManager.Find(SpriteBatchName.Aliens);
            SpriteBatch sbBoxes    = SpriteBatchManager.Find(SpriteBatchName.Boxes);

            pExplosion.ActivateGameSprite(sbAliens);
            pExplosion.ActivateCollisionSprite(sbBoxes);
            GameObjectManager.AttachTree(pExplosion);

            Game pGame = GameManager.GetGame();
            //pGame.Pause();
            int lives = ScoreManager.UpdateLives();

            if (lives == 0)
            {
                pGame.roundNum = 1;
                TimerManager.ClearTimerManager();
                pExplosion.Remove();
                pGame.Die();
                TimerManager.Add(TimerEventName.GameStart, TimerManager.GetCurrentTime() + 10.0f, 10.0f, new GameStartEvent(pGame));
            }
            else
            {
                TimerManager.Add(TimerEventName.RemoveGameObject, TimerManager.GetCurrentTime(), TimerManager.GetCurrentTime(), new RemoveGameObjectCommand(pExplosion));
                PCSTree pRootTree = GameObjectManager.GetRootTree();
                //ShipRoot pShipRoot = (ShipRoot)GameObjectManager.Find(GameObjectName.ShipRoot);
                //pShipRoot.ActivateCollisionSprite(sbBoxes);
                //pShipRoot.ActivateGameSprite(sbAliens);
                ShipManager.Create(GameManager.GetCollisionBoxes());
            }
        }
Пример #28
0
        //-----------------------------------------------------------------------------
        // Game::LoadContent()
        //		Allows you to load all content needed for your engine,
        //	    such as objects, graphics, etc.
        //-----------------------------------------------------------------------------

        public override void LoadContent()
        {
            Debug.WriteLine("----------------------------------");
            Debug.WriteLine("Load Content");
            Debug.WriteLine("----------------------------------\n");


            //-----------------------------------------------
            //Create Game Simulation instance
            Simulation.Create();

            //-----------------------------------------------
            //Manager Load
            //------------------------------
            //Texture Manager Create
            TextureManager.Create();
            //------------------------------
            //Image Manager Create
            ImageManager.Create();
            //------------------------------
            //Game/Box Sprite Manager Create
            GameSpriteManager.Create(5, 2);
            BoxSpriteManager.Create();
            //------------------------------
            //SpriteBatch Manager Create
            SpriteBatchManager.Create();
            //------------------------------
            //ProxySprite Manager Create
            ProxySpriteManager.Create(10, 1);
            //------------------------------
            //GameObject Manager Create
            GameObjectManager.Create();
            //------------------------------
            //CollisionPair Manager Create
            ColPairManager.Create();
            //------------------------------
            //TimerEvent Manager Create
            TimerEventManager.Create();
            //------------------------------
            //Glyph/Font Manager Create/Load
            GlyphManager.Create();
            FontManager.Create();

            //------------------------------
            //Death/Ghost Manager Create
            DeathManager.Create(1, 1);
            GhostManager.Create(1, 1);
            //-----------------------------------------------
            // Input Manager - Key Observer Load
            InputManager.LoadKeyInputObservers();

            //-----------------------------------------------
            //Print some initial stats
            TextureManager.DumpStats();
            ImageManager.DumpStats();
            GameSpriteManager.DumpStats();
            BoxSpriteManager.DumpStats();
            SpriteBatchManager.DumpStats();
            ProxySpriteManager.DumpStats();
            TimerEventManager.DumpStats();
            GameObjectManager.DumpStats();
            DeathManager.DumpStats();
            GhostManager.DumpStats();
            ColPairManager.DumpStats();
            GlyphManager.DumpStats();

            //------------------------------
            //Asset Loading

            //Texture/Image/Font Load
            TextureManager.LoadTextures();
            ImageManager.LoadImages();
            FontManager.LoadFonts();

            //-----------------------------------------------
            //Sprite Batch /Sprite Load
            SpriteBatch pSB_GameSprites = SpriteBatchManager.Add(SpriteBatch.Name.GameSprites);
            SpriteBatch pShields        = SpriteBatchManager.Add(SpriteBatch.Name.Shields);
            SpriteBatch pSB_Boxes       = SpriteBatchManager.Add(SpriteBatch.Name.SpriteBoxes);
            SpriteBatch pSB_Texts       = SpriteBatchManager.Add(SpriteBatch.Name.TextLetters);


            //-----------------------------------------------
            //Sprites/BoxSprites Load
            //NOTE that the following coordinates will not matter
            //once proxy sprites are used!

            //35w x 35h for all sprites;
            float const_AlienSpriteSize = 30.0f;


            //render dimensions/coordinates
            float squid_sX = 400.0f;
            float squid_sY = 400.0f;

            float crab_sX = 400.0f;
            float crab_sY = 350.0f;

            float octo_sX = 400.0f;
            float octo_sY = 300.0f;

            float missileSpriteWidth  = 4.0f;
            float missileSpriteHeight = 8.0f;

            float alienBombSpriteWidth  = 6.0f;
            float alienBombSpriteHeight = 12.0f;

            float shipSpriteWidth  = 55.0f;
            float shipSpriteHeight = 25.0f;

            float verticalWallWidth  = 678.0f;
            float verticalWallHeight = 10.0f;

            float horizontalWallWidth  = 678.0f;
            float horizontalWallHeight = 10.0f;

            //----------------------
            //aliens (initial sprites only)

            //note that the alien grid and alien column are game sprites for box sprite rendering,
            //but will pass a null image since they don't have anything to render
            GameSpriteManager.Add(GameSprite.Name.AlienGrid, Image.Name.NullObject, 0, 0, 0, 0);
            GameSpriteManager.Add(GameSprite.Name.AlienColumn, Image.Name.NullObject, 0, 0, 0, 0);

            //squid game sprite
            GameSpriteManager.Add(GameSprite.Name.Squid, Image.Name.SquidOpen, squid_sX, squid_sY, const_AlienSpriteSize, const_AlienSpriteSize);
            //crab game sprite
            GameSpriteManager.Add(GameSprite.Name.Crab, Image.Name.CrabOpen, crab_sX, crab_sY, const_AlienSpriteSize, const_AlienSpriteSize);
            //octopus game sprite
            GameSpriteManager.Add(GameSprite.Name.Octopus, Image.Name.OctopusOpen, octo_sX, octo_sY, const_AlienSpriteSize, const_AlienSpriteSize);

            //alien explosion (for explosion animation after alien is destroyed)
            GameSpriteManager.Add(GameSprite.Name.AlienExplosion, Image.Name.AlienExplosionPop, 0, 0, const_AlienSpriteSize, const_AlienSpriteSize);



            //----------------------
            //alien bombs (initial sprites only)

            //zigzag bomb
            GameSpriteManager.Add(GameSprite.Name.ZigZagAlienBomb, Image.Name.AlienBombZigZag_One, 0, 0, alienBombSpriteWidth, alienBombSpriteHeight);
            //cross bomb
            GameSpriteManager.Add(GameSprite.Name.CrossAlienBomb, Image.Name.AlienBombCross_One, 0, 0, alienBombSpriteWidth, alienBombSpriteHeight);
            //rolling bomb
            GameSpriteManager.Add(GameSprite.Name.RollingAlienBomb, Image.Name.AlienBombRolling_Two, 0, 0, alienBombSpriteWidth, alienBombSpriteHeight);

            //----------------------
            //hero ship
            GameSpriteManager.Add(GameSprite.Name.Ship, Image.Name.Ship, 640.0f, 440.0f, shipSpriteWidth, shipSpriteHeight);
            //hero missile
            GameSpriteManager.Add(GameSprite.Name.Missile, Image.Name.Missile, 0, 0, missileSpriteWidth, missileSpriteHeight);

            //----------------------
            //walls (2: top/bottom, left/right)
            //note screen w = 672px wide by 768px
            GameSpriteManager.Add(GameSprite.Name.VerticalWall, Image.Name.NullObject, 0, 0, verticalWallWidth, verticalWallHeight);
            GameSpriteManager.Add(GameSprite.Name.HorizontalWall, Image.Name.NullObject, 0, 0, horizontalWallWidth, horizontalWallHeight);


            //----------------------
            //shield bricks (6)

            float brickSpriteWidth  = 15.0f;
            float brickSpriteHeight = 10.0f;

            GameSpriteManager.Add(GameSprite.Name.ShieldBrick, Image.Name.ShieldBrick, 0.0f, 0.0f, brickSpriteWidth, brickSpriteHeight);
            GameSpriteManager.Add(GameSprite.Name.ShieldBrickLeft_Top, Image.Name.ShieldBrickLeft_Top, 0.0f, 0.0f, brickSpriteWidth, brickSpriteHeight);
            GameSpriteManager.Add(GameSprite.Name.ShieldBrickRight_Top, Image.Name.ShieldBrickRight_Top, 0, 0, brickSpriteWidth, brickSpriteHeight);
            GameSpriteManager.Add(GameSprite.Name.ShieldBrickMidLeft_Bottom, Image.Name.ShieldBrickMidLeft_Bottom, 0, 0, brickSpriteWidth, brickSpriteHeight);
            GameSpriteManager.Add(GameSprite.Name.ShieldBrickMid_Bottom, Image.Name.ShieldBrickMid_Bottom, 0, 0, brickSpriteWidth, brickSpriteHeight);
            GameSpriteManager.Add(GameSprite.Name.ShieldBrickMidRight_Bottom, Image.Name.ShieldBrickMidRight_Bottom, 0, 0, brickSpriteWidth, brickSpriteHeight);


            //----------------------
            //alien UFO ship
            float ufoSpriteWidth  = 30.0f;
            float ufoSpriteHeight = 10.0f;

            GameSpriteManager.Add(GameSprite.Name.AlienUFO, Image.Name.AlienUFO, 0, 0, ufoSpriteWidth, ufoSpriteHeight);

            //----------------------
            //BoxSprites are added in the CollisionObject constructor depending on the sprite!



            //-----------------------------------------------
            //Load the Animations (TimerEvents)

            TimerEventManager.LoadAlienAnimations();
            TimerEventManager.LoadBombAnimations();



            //-----------------------------------------------
            //Set the Game Simulation State;

            Simulation.SetState(Simulation.State.Realtime);



            //-----------------------------------------------
            //GameObject Load (Factory)

            //get the PCSRootTree that was created by GameObjectManager
            PCSTree rootGamObjTree = GameObjectManager.GetRootTree();

            //make sure root tree and root have been created;
            Debug.Assert(rootGamObjTree != null);
            Debug.Assert(rootGamObjTree.GetRoot() != null);

            //check the tree
            rootGamObjTree.DumpTree();

            //------------------------------------------------
            // Create Missile Tree

            MissileRoot pMissileRoot = new MissileRoot(GameObject.Name.MissileRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f);

            rootGamObjTree.Insert(pMissileRoot, null);
            //pMissileRoot.ActivateCollisionSprite(pSB_Boxes);

            //GameObjectManager.AttachTree(pMissileRoot, rootGamObjTree);
            GameObjectManager.AttachTree(pMissileRoot);

            //TEST------------------
            //PCSTree missileTree = new PCSTree();

            //MissileRoot pMissileRoot = new MissileRoot(GameObject.Name.MissileRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f);

            //missileTree.Insert(pMissileRoot, null);
            //pMissileRoot.ActivateCollisionSprite(pSB_Boxes);

            //GameObjectManager.AttachTree(pMissileRoot, rootGamObjTree);
            //rootGamObjTree.Insert(pMissileRoot, rootGamObjTree.GetRoot());

            //------------------------------------------------
            // Create Ship Tree

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

            DeathManager.Attach(shipRoot);


            //check the tree
            rootGamObjTree.DumpTree();

            //attach the shipRoot to the rootGameObjTree, with the gamObjRoot as parent
            rootGamObjTree.Insert(shipRoot, null);

            //check the tree
            rootGamObjTree.DumpTree();

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

            //create the ship manager that handles all the ship's states
            ShipManager.CreateShipManager();

            //check the tree
            rootGamObjTree.DumpTree();



            //------------------------------------------------
            // Create an Alien Tree

            //AlienRoot alienRoot = new AlienRoot(GameObject.Name.AlienRoot, GameSprite.SpriteName.Null_Object, 0, 0.0f, 0.0f);

            //create the PCS tree that will hold all alien game objects
            PCSTree pAlienTree = new PCSTree();

            DeathManager.Attach(pAlienTree);

            //create the alien game object factory with pAlienTree as the factory's tree
            //factory will attach all alien game objects to pAlienTree
            AlienFactory pAlienFactory = new AlienFactory(SpriteBatch.Name.GameSprites, pAlienTree);

            DeathManager.Attach(pAlienFactory);

            //attach grid as a child of game object root; grid will be parent of all alien game objects
            Grid pGrid = (Grid)pAlienFactory.Create(AlienType.Type.AlienGrid, GameObject.Name.Grid);

            // set the grid as the root parent to attach all aliens to;
            pAlienFactory.SetParent(pGrid);

            //Build the grid (builder pattern)
            int numberOfColumns = 11;

            //numberOfColumns = 1;
            AlienFactory.BuildAlienGrid(pAlienFactory, pGrid, numberOfColumns);

            //check the tree
            rootGamObjTree.DumpTree();

            //GameObjectManager.AttachTree(pGrid, rootGamObjTree);
            GameObjectManager.AttachTree(pGrid);

            //------------------------------------------------
            // Create Alien Bomb tree

            //create the root
            BombRoot pBombRoot = new BombRoot(GameObject.Name.BombRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f);

            //insert root into the bomb tree
            rootGamObjTree.Insert(pBombRoot, null);
            //pBombRoot.ActivateCollisionSprite(pSB_Boxes);

            //add the bombtree to the root tree
            //GameObjectManager.AttachTree(pBombRoot, rootGamObjTree);
            GameObjectManager.AttachTree(pBombRoot);

            //check the tree
            rootGamObjTree.DumpTree();



            //------------------------------------------------
            // Associate and Create Walls
            //note screen = 672px wide by 768px

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

            rootGamObjTree.Insert(pWallRoot, null);

            WallTop pWallTop = new WallTop(GameObject.Name.WallTop, GameSprite.Name.HorizontalWall, 0, 336.0f, 728.0f, 612.0f, 10.0f);

            rootGamObjTree.Insert(pWallTop, pWallRoot);
            pWallTop.ActivateCollisionSprite(pSB_Boxes);

            WallBottom pWallBottom = new WallBottom(GameObject.Name.WallBottom, GameSprite.Name.HorizontalWall, 0, 336.0f, 40.0f, 612.0f, 10.0f);

            rootGamObjTree.Insert(pWallBottom, pWallRoot);
            pWallBottom.ActivateCollisionSprite(pSB_Boxes);

            WallRight pWallRight = new WallRight(GameObject.Name.WallRight, GameSprite.Name.HorizontalWall, 0, 652.0f, 384.0f, 10.0f, 693.0f);

            rootGamObjTree.Insert(pWallRight, pWallRoot);
            pWallRight.ActivateCollisionSprite(pSB_Boxes);

            WallLeft pWallLeft = new WallLeft(GameObject.Name.WallLeft, GameSprite.Name.HorizontalWall, 0, 20.0f, 384.0f, 10.0f, 693.0f);

            rootGamObjTree.Insert(pWallLeft, pWallRoot);
            pWallLeft.ActivateCollisionSprite(pSB_Boxes);

            //now that it's fully created, attach the newly created wall tree to the main game object tree
            //GameObjectManager.AttachTree(pWallRoot, rootGamObjTree);
            GameObjectManager.AttachTree(pWallRoot);

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

            //create the root
            ShieldRoot pShieldRoot = new ShieldRoot(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f);

            rootGamObjTree.Insert(pShieldRoot, null);

            //attach to game object tree
            GameObjectManager.AttachTree(pShieldRoot);

            // create the factory
            ShieldFactory shieldFactory = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.Shields, rootGamObjTree);

            // set the parent for hierarchy inside the factory, grid is root, so parent is null
            //shieldFactory.setParent(pShieldRoot);

            // create and attach grid to Root
            //ShieldGrid pShieldGrid = (ShieldGrid)shieldFactory.Create(ShieldCategory.Type.ShieldGrid, GameObject.Name.ShieldGrid);


            float startPos_X = 50.0f;
            float startPos_y = 100.0f;

            //shield 1 - far left
            shieldFactory.BuildShield(pShieldRoot, startPos_X, startPos_y, brickSpriteWidth, brickSpriteHeight);

            //move to the right
            startPos_X = 210.0f;
            shieldFactory.BuildShield(pShieldRoot, startPos_X, startPos_y, brickSpriteWidth, brickSpriteHeight);

            //move to the right
            startPos_X = 370.0f;
            shieldFactory.BuildShield(pShieldRoot, startPos_X, startPos_y, brickSpriteWidth, brickSpriteHeight);


            //move to the right
            startPos_X = 520.0f;
            shieldFactory.BuildShield(pShieldRoot, startPos_X, startPos_y, brickSpriteWidth, brickSpriteHeight);


            //check the tree
            rootGamObjTree.DumpTree();



            //------------------------------------------------
            // Associate and Create Collision Pairs
            ColPair pColPair = null;

            // IMPORTANT: At LEAST two steps when establishing the collision pairs
            // 1) associate object roots in a collision pair,
            // 2) then attach all relevent Observer objects that will execute their specified response to collision
            //todo create an observerObject manager that pools all of these observer objects!

            //---------------------------------------------------------------------------------------------
            //Missile CollisionPairs

            //Missile vs Wall (Top) Collision

            // associate object roots in a collision pair
            pColPair = ColPairManager.Add(ColPair.Name.Missile_Wall, pMissileRoot, pWallRoot);
            //attach all observers that will react to collision
            pColPair.Attach(new ShipReadyObserver());
            pColPair.Attach(new ShipRemoveMissileObserver());

            //--------------------
            // Missile vs Shield collision

            // associate object roots in a collision pair
            pColPair = ColPairManager.Add(ColPair.Name.Misslie_Shield, pMissileRoot, pShieldRoot);
            //attach all observers that will react to this collision
            pColPair.Attach(new RemoveMissileObserver());
            //pColPair.Attach(new DegradeBrickSpriteObserver());
            pColPair.Attach(new RemoveBrickObserver());
            pColPair.Attach(new ShipReadyObserver());


            //--------------------
            //Missile vs AlienGrid collision

            // associate object roots in a collision pair
            pColPair = ColPairManager.Add(ColPair.Name.Alien_Missile, pMissileRoot, pGrid);
            //attach all observers that will react to collision
            pColPair.Attach(new RemoveMissileObserver());
            //todo alien explosion animation isn't working
            pColPair.Attach(new AnimateAlienExplosionObserver());
            pColPair.Attach(new RemoveAlienObserver());
            //pColPair.Attach(new AlienDeathSoundObserver());
            //pColPair.Attach(new AlienScoreUpdateObserver());
            pColPair.Attach(new ShipReadyObserver());

            //---------------------------------------------------------------------------------------------
            //Bomb CollisionPairs


            //Bomb vs Wall (Bottom) Collision

            // associate object roots in a collision pair
            pColPair = ColPairManager.Add(ColPair.Name.Bomb_Wall, pBombRoot, pWallRoot);
            //attach all observers that will react to collision
            //pColPair.Attach(new BombObserver());
            pColPair.Attach(new RemoveBombObserver());


            //todo broken collision - fix
            //--------------------
            //Bomb vs Shield Collision

            // associate object roots in a collision pair
            pColPair = ColPairManager.Add(ColPair.Name.Bomb_Shield, pBombRoot, pShieldRoot);
            //attach all observers that will react to collision
            pColPair.Attach(new RemoveBombObserver());
            pColPair.Attach(new RemoveBrickObserver());

            //todo need to implement collision reaction for bomb v ship
            ////--------------------
            ////Bomb vs Ship Collision

            //// associate object roots in a collision pair
            //pColPair = ColPairManager.Add(ColPair.Name.Bomb_Ship, pBombRoot, shipRoot);
            ////attach all observers that will react to collision
            //pColPair.Attach(new RemoveBombObserver());
            ////pColPair.Attach(new ShipExplosionSoundObserver());
            ////pColPair.Attach(new TriggerGameOverStateObserver());


            //todo need to implement collision reaction for grid v wall, grid vs shield;
            //---------------------------------------------------------------------------------------------
            //AlienGrid/Column CollisionPairs

            ////AlienGrid vs Walls

            //// associate object roots in a collision pair
            //pColPair = ColPairManager.Add(ColPair.Name.Alien_Wall, pGrid, pWallRoot);
            ////attach all observers that will react to collision
            //pColPair.Attach(new AlienGridPivotObserver());

            //--------------------
            //AlienColumn vs Shield Collision

            //// associate object roots in a collision pair
            //pColPair = ColPairManager.Add(ColPair.Name.Alien_Shield, pGrid, pShieldRoot);
            ////attach all observers that will react to collision
            //pColPair.Attach(new RemoveShieldBrickObserver());


            //---------------------------------------------------------------------------------------------
            //Ship CollisionPairs



            Debug.WriteLine("\n\n\n\n\n");
            GameObjectManager.DumpAll();



            Debug.WriteLine("\n\nLoad Content Complete\n----------------------------------\n");

            //-----------------------------------------------
            //Data Dump;

            TextureManager.DumpStats();
            ImageManager.DumpStats();
            GameSpriteManager.DumpStats();
            BoxSpriteManager.DumpStats();
            SpriteBatchManager.DumpStats();
            ProxySpriteManager.DumpStats();
            TimerEventManager.DumpStats();
            GameObjectManager.DumpStats();
            DeathManager.DumpStats();
            GhostManager.DumpStats();
            ColPairManager.DumpStats();
            GlyphManager.DumpStats();

            //TextureManager.DumpLists();
            //ImageManager.DumpLists();
            //GameSpriteManager.DumpLists();
            BoxSpriteManager.DumpLists();
            //SpriteBatchManager.DumpLists();
            //ProxySpriteManager.DumpLists();
            //TimerEventManager.DumpLists();
            //GameObjectManager.DumpLists();
            //DeathManager.DumpLists();
            //GhostManager.DumpLists();
            //ColPairManager.DumpLists();
            //GlyphManager.DumpLists();

            //TextureManager.DumpAll();
            //ImageManager.DumpAll();
            //GameSpriteManager.DumpAll();
            //BoxSpriteManager.DumpAll();
            //SpriteBatchManager.DumpAll();
            //ProxySpriteManager.DumpAll();
            //TimerEventManager.DumpAll();
            //GameObjectManager.DumpAll();
            //DeathManager.DumpAll();
            //GhostManager.DumpAll();
            //ColPairManager.DumpAll();
            //GlyphManager.DumpAll();
        }
Пример #29
0
 public ShieldFactory(PCSTree mPCSTree, SpriteBatch mSpriteBatch)
 {
     this.cPCSTree = mPCSTree;
     //this.cSpriteBatch = SpriteBatchManager.find(mSpriteBatch);
     this.cSpriteBatch = mSpriteBatch;
 }
Пример #30
0
        private ShieldRoot GenerateShield(PCSTree pRootTree, float startX, float startY, int idx)
        {
            ShieldRoot pShieldRoot = new ShieldRoot(GameObjectName.ShieldRoot, SpriteBaseName.Null, 0.0f, 0.0f, idx);

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

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

            int            j = 0;
            ShieldCategory pCol;

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

            int i = 0;

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

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

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

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

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

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

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

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

            return(pShieldRoot);
        }