Beispiel #1
0
 public virtual void VisitShieldBrick(ShieldBrick s)
 {
     //shouldn't call this
     //need to implement in concrete class
     Debug.WriteLine("Visit by ShieldBrick not implemented");
     Debug.Assert(false);
 }
        public override void VisitShieldBrick(ShieldBrick m)
        {
            CollisionPair pColPair = CollisionPairManager.GetActiveColPair();

            pColPair.SetCollision(this, m);
            pColPair.NotifyListeners();
        }
Beispiel #3
0
        public override void VisitShieldBrick(ShieldBrick sb)
        {
            // ShieldBrick vs Missile
            GameObject pGameObj = Iterator.GetChildGameObject(this);

            CollisionPair.Collide(sb, pGameObj);
        }
Beispiel #4
0
        public override void VisitShieldBrick(ShieldBrick pShieldBrick)
        {
            //Debug.WriteLine("in Grid, visit from ShieldBrick");
            GameObject pGameObj = (GameObject)this.GetFirstChild();

            ColPair.FwdCollide(pGameObj, pShieldBrick);
        }
Beispiel #5
0
        public GameObject Create(ShieldCategory.Type type, GameObject.Name gameName, GameObject pContainer = null, float posX = 0.0f, float posY = 0.0f)
        {
            GameObject pShield = null;

            switch (type)
            {
            case ShieldCategory.Type.Brick:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick, posX, posY);
                break;

            case ShieldCategory.Type.LeftTop1:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_LeftTop1, posX, posY);
                break;

            case ShieldCategory.Type.LeftTop0:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_LeftTop0, posX, posY);
                break;

            case ShieldCategory.Type.LeftBottom:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_LeftBottom, posX, posY);
                break;

            case ShieldCategory.Type.RightTop1:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_RightTop1, posX, posY);
                break;

            case ShieldCategory.Type.RightTop0:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_RightTop0, posX, posY);
                break;

            case ShieldCategory.Type.RightBottom:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_RightBottom, posX, posY);
                break;

            case ShieldCategory.Type.Root:
                pShield = new ShieldRoot(gameName, GameSprite.Name.NullObject, posX, posY);
                pShield.SetCollisionColor(0.0f, 0.0f, 1.0f);
                //Debug.Assert(false);
                break;

            case ShieldCategory.Type.Grid:
                pShield = new ShieldGrid(gameName, GameSprite.Name.NullObject, posX, posY);
                pShield.SetCollisionColor(0.0f, 1.0f, 0.0f);
                break;

            case ShieldCategory.Type.Column:
                pShield = new ShieldColumn(gameName, GameSprite.Name.NullObject, posX, posY);
                pShield.SetCollisionColor(1.0f, 0.0f, 0.0f);
                break;

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

            this.AttachTo(pShield, pContainer);
            return(pShield);
        }
Beispiel #6
0
        public GameObject Create(ShieldCategory.Type type, GameObject.Name gameName, float posX = 0.0f, float posY = 0.0f)
        {
            GameObject pShield = null;

            switch (type)
            {
            case ShieldCategory.Type.Brick:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick, posX, posY);
                break;

            case ShieldCategory.Type.LeftTop1:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_LeftTop1, posX, posY);
                break;

            case ShieldCategory.Type.LeftTop0:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_LeftTop0, posX, posY);
                break;

            case ShieldCategory.Type.LeftBottom:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_LeftBottom, posX, posY);
                break;

            case ShieldCategory.Type.RightTop1:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_RightTop1, posX, posY);
                break;

            case ShieldCategory.Type.RightTop0:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_RightTop0, posX, posY);
                break;

            case ShieldCategory.Type.RightBottom:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_RightBottom, posX, posY);
                break;

            case ShieldCategory.Type.Root:
                pShield = new ShieldRoot(gameName, GameSprite.Name.NullObject, posX, posY);
                pShield.SetCollisionColor(0.0f, 0.0f, 1.0f);
                break;

            case ShieldCategory.Type.Column:
                pShield = new ShieldColumn(gameName, GameSprite.Name.NullObject, posX, posY);
                pShield.SetCollisionColor(1.0f, 0.0f, 0.0f);
                break;

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

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

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

            return(pShield);
        }
Beispiel #7
0
        public override void VisitShieldBrick(ShieldBrick sb)
        {
            Debug.Assert(sb != null);
            CollisionPair pColPair = CollisionPairManager.GetCurrentCollisionPair();

            pColPair.SetObserverSubject(sb, this);
            pColPair.NotifyListeners();
        }
Beispiel #8
0
        public override void VisitShieldBrick(ShieldBrick sb)
        {
            CollisionPair pColPair = CollisionPairManager.GetCurrentCollisionPair();

            pColPair.SetObserverSubject(sb, this);
            pColPair.NotifyListeners();

            // Shield will be deactivated by removeObserver
        }
Beispiel #9
0
        public override void VisitShieldBrick(ShieldBrick sb)
        {
            Debug.Assert(sb != null);
            CollisionPair pColPair = CollisionPairManager.GetCurrentCollisionPair();
            pColPair.SetObserverSubject(sb, this);
            pColPair.NotifyListeners();

            // The bomb and shield will be dealt with by RemoveObserver...
        }
        public override void VisitShieldBrick(ShieldBrick pShieldBrick)
        {
            //Debug.WriteLine("in InvaderCategory   --->DONE<----");
            ColPair pColPair = ColPairManager.GetActiveColPair();

            Debug.Assert(pColPair != null);

            pColPair.SetCollision(this, pShieldBrick);
            pColPair.NotifyListeners();
        }
Beispiel #11
0
        public override void VisitShieldBrick(ShieldBrick sb)
        {
            // AlienGridColumn vs ShieldBrick
            Debug.WriteLine("         collide:  {0} <-> {1}", sb.GetName(), this.name);

            // Alien vs ShieldBrick
            GameObject pGameObj = Iterator.GetChildGameObject(this);

            CollisionPair.Collide(this, pGameObj);
        }
Beispiel #12
0
        public override void VisitShieldBrick(ShieldBrick pShieldBrick)
        {
            //Debug.WriteLine("in Missile   --->DONE<----");
            ColPair pColPair = ColPairManager.GetActiveColPair();

            Debug.Assert(pColPair != null);
            // Always set missile as ObjA
            pColPair.SetCollision(this, pShieldBrick);
            pColPair.NotifyListeners();
        }
        public override void visitShieldBrick(ShieldBrick s)
        {
            Debug.WriteLine("FlippingBomb ShieldBrick");
            Debug.WriteLine("Both tress finished to roots");

            CollisionPair currColPair = CollisionPairManager.getCurrentColPair();

            Debug.Assert(currColPair != null);
            currColPair.setSubject(this, s);
            currColPair.notifyObserver();
        }
Beispiel #14
0
        public override void VisitShieldBrick(ShieldBrick sb)
        {
            //ShieldBrick vs Bomb
            //Debug.WriteLine("         collide:  {0} <-> {1}", sb.GetName(), this.name);

            // Notify Observers
            CollisionPair pColPair = CollisionPairManager.GetActiveColPair();

            Debug.Assert(pColPair != null);
            pColPair.SetCollision(sb, this);
            pColPair.NotifyListeners();
        }
Beispiel #15
0
        internal static void DestroyShields(ShieldGroup pShieldGroup)
        {
            // Iterate through shields
            ShieldRoot pShieldRoot = (ShieldRoot)pShieldGroup.GetFirstChild();

            while (pShieldRoot != null)
            {
                // Iterate through shield columns
                ShieldColumn pShieldCol = (ShieldColumn)pShieldRoot.GetFirstChild();
                while (pShieldCol != null)
                {
                    // Iterate through shield bricks
                    ShieldBrick pShieldBrick = (ShieldBrick)pShieldCol.GetFirstChild();
                    while (pShieldBrick != null)
                    {
                        // Remove ShieldBrick from composite
                        pShieldCol.Remove(pShieldBrick);

                        // Kill ShieldRoot
                        pShieldBrick.Remove(SpriteBatch.Name.Shield, SpriteBatch.Name.CollisionBox);

                        // Get next ShieldColumn
                        pShieldBrick = (ShieldBrick)pShieldCol.GetFirstChild();
                    }

                    // Remove ShieldColumn from composite
                    pShieldRoot.Remove(pShieldCol);

                    // Kill ShieldRoot
                    pShieldCol.Remove(SpriteBatch.Name.Shield, SpriteBatch.Name.CollisionBox);

                    // Get next ShieldColumn
                    pShieldCol = (ShieldColumn)pShieldRoot.GetFirstChild();
                }


                // Remove ShieldRoot from composite
                pShieldGroup.Remove(pShieldRoot);

                // Kill ShieldRoot
                pShieldRoot.Remove(SpriteBatch.Name.Shield, SpriteBatch.Name.CollisionBox);

                // Get next ShieldRoot
                pShieldRoot = (ShieldRoot)pShieldGroup.GetFirstChild();
            }
        }
Beispiel #16
0
        public GameObject Create(Type type, float posX, float posY)
        {
            GameObject pGameObj = null;

            switch (type)
            {
            case Type.Brick:
                pGameObj = new ShieldBrick(GameObject.Name.ShieldBrick, Sprite.Name.ShieldBrick, BoxSprite.Name.ShieldBrickBox, posX, posY);
                break;

            case Type.Column:
                pGameObj = new ShieldColumn(GameObject.Name.ShieldColumn, BoxSprite.Name.ShieldColumnBox);
                break;

            case Type.Shield:
                pGameObj = new Shield(GameObject.Name.Shield, BoxSprite.Name.ShieldBox);
                break;

            case Type.Zone:
                pGameObj = new ShieldZone(GameObject.Name.ShieldZone, BoxSprite.Name.ShieldZoneBox);
                break;

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

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

            if (pGOComposite != null)
            {
                // add to grouping
                pGOComposite.Add(pGameObj);
            }

            // Attached to Batches
            this.pBoxSpriteBatch.Attach(pGameObj.poColObj.pColSprite);
            this.pSpriteBatch.Attach(pGameObj.pProxySprite);
            return(pGameObj);
        }
Beispiel #17
0
        public Shield createShield(Shield.ShieldType mShieldType, GameObject.GameObjectName gameName, int index = 0, float mX = 0.0f, float mY = 0.0f)
        {
            Shield shield = null;

            switch (mShieldType)
            {
            case Shield.ShieldType.ShieldBrick:
                shield = new ShieldBrick(gameName, Sprite.SpriteName.ShieldBrick, index, mX, mY);
                break;

            case Shield.ShieldType.ShieldColumn:
                shield = new ShieldColumn(gameName, Sprite.SpriteName.NullObject, index, mX, mY);
                break;

            case Shield.ShieldType.ShieldUnit:
                shield = new ShieldUnit(gameName, Sprite.SpriteName.NullObject, index, mX, mY);
                break;

            case Shield.ShieldType.ShieldGrid:
                shield = new ShieldGrid(gameName, index, Sprite.SpriteName.NullObject);
                GameObjectNodeManager.add(shield, cPCSTree);
                break;

            case Shield.ShieldType.Uninitilized:
                Debug.WriteLine("Shield Type is Uninitilized");
                break;
            }

            this.cPCSTree.Insert(shield, this.cParent);
            // cSpriteBatch.addToBatch(shield.getProxySprite());
            // cSpriteBatch.addToBatch(shield.getCollisionObj().cSpriteBox);

            shield.addSpriteToBatch(this.cSpriteBatch);
            shield.addCollisionToBatch(SpriteBatchManager.find(SpriteBatch.SpriteBatchName.Boxes));
            return(shield);
        }
Beispiel #18
0
 //-------------------------------------
 public virtual void VisitShieldBrick(ShieldBrick s)
 {
     Debug.WriteLine("Visit by ShieldBrick not implemented");
     Debug.Assert(false);
 }
Beispiel #19
0
        public static GameObject Create(ShieldCategory.Type type, int _Index, float posX = 0.0f, float posY = 0.0f)
        {
            ShieldFactory pFactory = ShieldFactory.PrivGetInstance();

            Debug.Assert(pFactory != null);

            GameObject pGameObj = null;

            switch (type)
            {
            case ShieldCategory.Type.Brick:
                pGameObj = new ShieldBrick(GameObject.Name.ShieldBrick, GameSprite.Name.Brick, _Index, posX, posY);
                break;

            case ShieldCategory.Type.LeftBottom:
                pGameObj = new ShieldBrick(GameObject.Name.ShieldBrick, GameSprite.Name.BrickLeft_Bottom, _Index, posX, posY);
                break;

            case ShieldCategory.Type.LeftTop0:
                pGameObj = new ShieldBrick(GameObject.Name.ShieldBrick, GameSprite.Name.BrickLeft_Top0, _Index, posX, posY);
                break;

            case ShieldCategory.Type.LeftTop1:
                pGameObj = new ShieldBrick(GameObject.Name.ShieldBrick, GameSprite.Name.BrickLeft_Top1, _Index, posX, posY);
                break;

            case ShieldCategory.Type.RightBottom:
                pGameObj = new ShieldBrick(GameObject.Name.ShieldBrick, GameSprite.Name.BrickRight_Bottom, _Index, posX, posY);
                break;

            case ShieldCategory.Type.RightTop0:
                pGameObj = new ShieldBrick(GameObject.Name.ShieldBrick, GameSprite.Name.BrickRight_Top0, _Index, posX, posY);
                break;

            case ShieldCategory.Type.RightTop1:
                pGameObj = new ShieldBrick(GameObject.Name.ShieldBrick, GameSprite.Name.BrickRight_Top1, _Index, posX, posY);
                break;

            case ShieldCategory.Type.Column:
                pGameObj = new ShieldColumn(GameObject.Name.ShieldColumn, GameSprite.Name.NullObject, _Index, posX, posY);
                break;

            case ShieldCategory.Type.Group:
                pGameObj = new ShieldGroup(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, _Index, posX, posY);
                break;

            default:
                Debug.Assert(false);
                break;
            }
            Debug.Assert(pGameObj != null);


            // Attach to SpriteBatch
            if (pGameObj.type == Component.Container.LEAF)
            {
                pFactory.pParent.Add(pGameObj);
                pGameObj.ActivateGameSprite(pFactory.pShieldSpriteBatch);
            }
            pGameObj.ActivateCollisionSprite(pFactory.pBoxSpriteBatch);
            return(pGameObj);
        }
Beispiel #20
0
 public virtual void VisitShieldBrick(ShieldBrick pShieldBrick)
 {
     // no differed to subcass
     Debug.WriteLine("Visit by ShieldBrick not implemented");
     Debug.Assert(false);
 }
Beispiel #21
0
        public ShieldCategory Create(ShieldCategory.Type type, GameObject.Name gameObjName, int index = 0, float posX = 0.0f, float posY = 0.0f)
        {
            ShieldCategory pShield = null;

            switch (type)
            {
            case ShieldCategory.Type.Root:
                pShield = new ShieldRoot(gameObjName, GameSprite.Name.NullObject, index, posX, posY);
                //pShield.SetCollisionColor(0.0f, 0.0f, 1.0f);
                //GameObjectManager.AttachTree(pShield, this.pTree);
                //pShield.ActivateCollisionSprite(this.pCollisionSpriteBatch);
                break;

            case ShieldCategory.Type.ShieldGrid:
                pShield = new ShieldGrid(gameObjName, GameSprite.Name.NullObject, index, posX, posY);
                //pShield.SetCollisionColor(1.0f, 0.0f, 0.0f);
                pShield.ActivateCollisionSprite(this.pCollisionSpriteBatch);
                break;

            case ShieldCategory.Type.ShieldColumn:
                pShield = new ShieldColumn(gameObjName, GameSprite.Name.NullObject, index, posX, posY);
                //pShield.SetCollisionColor(1.0f, 0.0f, 0.0f);
                pShield.ActivateCollisionSprite(this.pCollisionSpriteBatch);
                break;


            case ShieldCategory.Type.ShieldBrick:
                pShield = new ShieldBrick(gameObjName, GameSprite.Name.ShieldBrick, index, posX, posY);
                break;

            case ShieldCategory.Type.ShieldBrickLeft_Top:
                pShield = new ShieldBrick(gameObjName, GameSprite.Name.ShieldBrickLeft_Top, index, posX, posY);
                break;


            case ShieldCategory.Type.ShieldBrickRight_Top:
                pShield = new ShieldBrick(gameObjName, GameSprite.Name.ShieldBrickRight_Top, index, posX, posY);
                break;


            case ShieldCategory.Type.ShieldBrickMidLeft_Bottom:
                pShield = new ShieldBrick(gameObjName, GameSprite.Name.ShieldBrickMidLeft_Bottom, index, posX, posY);
                break;

            case ShieldCategory.Type.ShieldBrickMid_Bottom:
                pShield = new ShieldBrick(gameObjName, GameSprite.Name.ShieldBrickMid_Bottom, index, posX, posY);
                break;

            case ShieldCategory.Type.ShieldBrickMidRight_Bottom:
                pShield = new ShieldBrick(gameObjName, GameSprite.Name.ShieldBrickMidRight_Bottom, index, posX, posY);
                break;

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

            // add to the tree
            this.pTree.Insert(pShield, this.pParent);

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

            return(pShield);
        }
Beispiel #22
0
 public virtual void VisitShieldBrick(ShieldBrick sb)
 {
     Debug.Assert(false);
 }
Beispiel #23
0
        public static Shield CreateShield(float xOrigin, float yOrigin, GameObjectComposite pGOComposite = null)
        {
            // 21 x 18
            ShieldFactory pShieldSF = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pGOComposite);
            Shield        pShield   = (Shield)pShieldSF.Create(ShieldFactory.Type.Shield, 0, 0);

            ShieldFactory pColumnSF = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShield);

            ShieldColumn pShieldColumn0 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0);
            ShieldColumn pShieldColumn1 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0);
            ShieldColumn pShieldColumn2 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0);
            ShieldColumn pShieldColumn3 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0);
            ShieldColumn pShieldColumn4 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0);
            ShieldColumn pShieldColumn5 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0);
            ShieldColumn pShieldColumn6 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0);
            // Columns 7 through 13 are produced in a loop below.
            ShieldColumn pShieldColumn14 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0);
            ShieldColumn pShieldColumn15 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0);
            ShieldColumn pShieldColumn16 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0);
            ShieldColumn pShieldColumn17 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0);
            ShieldColumn pShieldColumn18 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0);
            ShieldColumn pShieldColumn19 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0);
            ShieldColumn pShieldColumn20 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0);

            // make shield columns 0 and 20
            for (int i = 0; i < 12; i++)
            {
                ShieldFactory pShieldBrickFactory = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn0);
                ShieldBrick   shieldBrick         = (ShieldBrick)pShieldBrickFactory.Create(ShieldFactory.Type.Brick, xOrigin, yOrigin + i * Constants.shieldBrickHeight);

                ShieldFactory pShieldBrickFactory20 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn20);
                pShieldBrickFactory20.Create(ShieldFactory.Type.Brick, xOrigin + 20 * Constants.shieldBrickHeight, yOrigin + i * Constants.shieldBrickHeight);
            }

            // make shield columns 1 and 19
            for (int i = 0; i < 13; i++)
            {
                ShieldFactory pShieldBrickFactory = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn1);
                ShieldBrick   shieldBrick         = (ShieldBrick)pShieldBrickFactory.Create(ShieldFactory.Type.Brick, xOrigin + 1 * Constants.shieldBrickHeight, yOrigin + i * Constants.shieldBrickHeight);

                ShieldFactory pShieldBrickFactory19 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn19);
                pShieldBrickFactory19.Create(ShieldFactory.Type.Brick, xOrigin + 19 * Constants.shieldBrickHeight, yOrigin + i * Constants.shieldBrickHeight);
            }

            // make shield columns 2 and 18
            for (int i = 0; i < 14; i++)
            {
                ShieldFactory pShieldBrickFactory = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn2);
                ShieldBrick   shieldBrick         = (ShieldBrick)pShieldBrickFactory.Create(ShieldFactory.Type.Brick, xOrigin + 2 * Constants.shieldBrickHeight, yOrigin + i * Constants.shieldBrickHeight);

                ShieldFactory pShieldBrickFactory18 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn18);
                pShieldBrickFactory18.Create(ShieldFactory.Type.Brick, xOrigin + 18 * Constants.shieldBrickHeight, yOrigin + i * Constants.shieldBrickHeight);
            }

            // make shield columns 3 and 17
            for (int i = 0; i < 15; i++)
            {
                ShieldFactory pShieldBrickFactory3 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn3);
                pShieldBrickFactory3.Create(ShieldFactory.Type.Brick, xOrigin + 3 * Constants.shieldBrickHeight, yOrigin + i * Constants.shieldBrickHeight);

                ShieldFactory pShieldBrickFactory17 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn17);
                pShieldBrickFactory17.Create(ShieldFactory.Type.Brick, xOrigin + 17 * Constants.shieldBrickHeight, yOrigin + i * Constants.shieldBrickHeight);
            }

            // make shield columns 4 and 16
            for (int i = 0; i < 16; i++)
            {
                ShieldFactory pShieldBrickFactory4 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn4);
                pShieldBrickFactory4.Create(ShieldFactory.Type.Brick, xOrigin + 4 * Constants.shieldBrickHeight, yOrigin + i * Constants.shieldBrickHeight);

                ShieldFactory pShieldBrickFactory16 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn16);
                pShieldBrickFactory16.Create(ShieldFactory.Type.Brick, xOrigin + 16 * Constants.shieldBrickHeight, yOrigin + i * Constants.shieldBrickHeight);
            }

            // make shield columns 5 and 15
            for (int i = 0; i < 14; i++)
            {
                ShieldFactory pShieldBrickFactor5 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn5);
                pShieldBrickFactor5.Create(ShieldFactory.Type.Brick, xOrigin + 5 * Constants.shieldBrickHeight, yOrigin + 2 * Constants.shieldBrickHeight + i * Constants.shieldBrickHeight);

                ShieldFactory pShieldBrickFactor15 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn15);
                pShieldBrickFactor15.Create(ShieldFactory.Type.Brick, xOrigin + 15 * Constants.shieldBrickHeight, yOrigin + 2 * Constants.shieldBrickHeight + i * Constants.shieldBrickHeight);
            }

            // make shield  columns 6 and 14
            for (int i = 0; i < 13; i++)
            {
                ShieldFactory pShieldBrickFactory6 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn6);
                pShieldBrickFactory6.Create(ShieldFactory.Type.Brick, xOrigin + 6 * Constants.shieldBrickHeight, yOrigin + 3 * Constants.shieldBrickHeight + i * Constants.shieldBrickHeight);

                ShieldFactory pShieldBrickFactory14 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn14);
                pShieldBrickFactory14.Create(ShieldFactory.Type.Brick, xOrigin + 14 * Constants.shieldBrickHeight, yOrigin + 3 * Constants.shieldBrickHeight + i * Constants.shieldBrickHeight);
            }

            // make shield  columns 7 thru 13
            for (int i = 0; i < 7; i++)
            {
                float         x                   = xOrigin + 7 * Constants.shieldBrickHeight + i * Constants.shieldBrickHeight;
                ShieldColumn  pShieldColumn       = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0);
                ShieldFactory pShieldBrickFactory = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn);
                for (int j = 0; j < 12; j++)
                {
                    float y = yOrigin + 4 * Constants.shieldBrickHeight + j * Constants.shieldBrickHeight;
                    pShieldBrickFactory.Create(ShieldFactory.Type.Brick, x, y);
                }
            }

            return(pShield);
        }
        public GameObject Create(ShieldCategory.Type type, GameObject.Name gameName, float posX = 0.0f, float posY = 0.0f)
        {
            GameObject pShield = null;

            switch (type)
            {
            case ShieldCategory.Type.Brick:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick, posX, posY);
                break;

            case ShieldCategory.Type.LeftTop1:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_LeftTop1, posX, posY);
                break;

            case ShieldCategory.Type.LeftTop2:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_LeftTop2, posX, posY);
                break;

            case ShieldCategory.Type.LeftBottom:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_LeftBottom, posX, posY);
                break;

            case ShieldCategory.Type.RightTop1:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_RightTop1, posX, posY);
                break;

            case ShieldCategory.Type.RightTop2:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_RightTop2, posX, posY);
                break;

            case ShieldCategory.Type.RightBottom:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_RightBottom, posX, posY);
                break;


            case ShieldCategory.Type.Root:
                pShield = new ShieldRoot(gameName, GameSprite.Name.NullObject, posX, posY);
                pShield.SetCollisionColor(0.0f, 0.0f, 1.0f);
                Debug.Assert(false);
                break;

            case ShieldCategory.Type.Grid:
                pShield = new ShieldGrid(gameName, GameSprite.Name.NullObject, posX, posY);
                pShield.SetCollisionColor(0.0f, 0.0f, 1.0f);
                break;

            case ShieldCategory.Type.Column:
                pShield = new ShieldColumn(gameName, GameSprite.Name.NullObject, posX, posY);
                pShield.SetCollisionColor(1.0f, 0.0f, 0.0f);
                break;

            default:
                Debug.Assert(false);
                break;
            }

            this.pTree.Add(pShield);

            pShield.ActivateGameSprite(this.pSpriteBatch);
            pShield.ActivateCollisionSprite(this.pColSpriteBatch);

            return(pShield);
        }
 public virtual void visitShieldBrick(ShieldBrick s)
 {
 }
Beispiel #26
0
        public ShieldCategory Create(ShieldType type, GameObjectName goName, float x = 0.0f, float y = 0.0f, int idx = 0)
        {
            ShieldCategory pShield = null;

            switch (type)
            {
            case ShieldType.Brick:
                pShield = new ShieldBrick(goName, SpriteBaseName.Brick, x, y, idx);
                break;

            case ShieldType.LeftTop0:
                pShield = new ShieldBrick(goName, SpriteBaseName.BrickLeftTop0, x, y, idx);
                break;

            case ShieldType.LeftTop1:
                pShield = new ShieldBrick(goName, SpriteBaseName.BrickLeftTop1, x, y, idx);
                break;

            case ShieldType.LeftBottom:
                pShield = new ShieldBrick(goName, SpriteBaseName.BrickLeftBottom, x, y, idx);
                break;

            case ShieldType.RightTop0:
                pShield = new ShieldBrick(goName, SpriteBaseName.BrickRightTop0, x, y, idx);
                break;

            case ShieldType.RightTop1:
                pShield = new ShieldBrick(goName, SpriteBaseName.BrickRightTop1, x, y, idx);
                break;

            case ShieldType.RightBottom:
                pShield = new ShieldBrick(goName, SpriteBaseName.BrickRightBottom, x, y, idx);
                break;

            case ShieldType.Root:
                pShield = new ShieldRoot(goName, SpriteBaseName.Null, x, y, idx);
                pShield.pCollisionObject.pCollisionSpriteBox.pLineColor = ColorFactory.Create(ColorName.Blue).pAzulColor;
                Debug.Assert(false);
                break;

            case ShieldType.Grid:
                pShield = new ShieldGrid(goName, SpriteBaseName.Null, x, y, idx);
                pShield.pCollisionObject.pCollisionSpriteBox.pLineColor = ColorFactory.Create(ColorName.Blue).pAzulColor;
                break;

            case ShieldType.Column:
                pShield = new ShieldColumn(goName, SpriteBaseName.Null, x, y, idx);
                pShield.pCollisionObject.pCollisionSpriteBox.pLineColor = ColorFactory.Create(ColorName.Red).pAzulColor;
                break;

            default:
                Debug.Assert(false);
                break;
            }
            this.pTree.Insert(pShield, this.pParent);
            pShield.ActivateGameSprite(this.pSpriteBatch);
            if (GameManager.GetCollisionBoxes())
            {
                pShield.ActivateCollisionSprite(this.pCollisionSpriteBatch);
            }
            return(pShield);
        }
        //make it rebuild the Shields now
        public static void RebuildShields()
        {
            SpriteBatch pSB_Shields = SpriteBatchMan.Find(SpriteBatch.Name.Shields);
            SpriteBatch pSB_Boxes   = SpriteBatchMan.Find(SpriteBatch.Name.Boxes);
            GameObject  pShieldRoot = GONodeMan.Find(GameObject.Name.ShieldRoot);

            GraveyardMan pGraveyard = GraveyardMan.PrivGetInstance();

            GameObject pSafety = pGraveyard.poHead;

            GameObject pNode = pSafety;

            GameObject pNextNode = null;

            //-------------------------------------------------------------------------------------------------
            //add the Shields to the Shield Root
            //-------------------------------------------------------------------------------------------------

            //search for the shields
            while (pNode != null)
            {
                //save this to iterate, because we will possibly remove the next pointer it
                pNextNode = (GameObject)pNode.pNext;

                //we still have the parent reference on the objects
                if (pShieldRoot == pNode.pParent)
                {
                    //dettach from list then add it to tree
                    pGraveyard.PrivDetach(pNode, ref pGraveyard.poHead);

                    pNode.Clear();

                    pShieldRoot.Add(pNode);
                    pNode.ActivateGameSprite(pSB_Shields);
                    pNode.ActivateCollisionSprite(pSB_Boxes);
                }

                pNode = pNextNode;
            }

            //-------------------------------------------------------------------------------------------------
            //add the Columns to the Shields
            //-------------------------------------------------------------------------------------------------

            //random check
            //check to see if ShieldRoot has a shield
            Debug.Assert(pShieldRoot.GetFirstChild() != null);

            GameObject pShield = (GameObject)pShieldRoot.GetFirstChild();

            //iterate through the shield siblings
            while (pShield != null)
            {
                //iterate through the graveyard
                pNode = pGraveyard.poHead;
                while (pNode != null)
                {
                    //save this to iterate, because we will possibly remove the next pointer it
                    pNextNode = (GameObject)pNode.pNext;

                    //check the parent reference to the shield
                    if (pShield == pNode.pParent)
                    {
                        //dettach from list then add it to tree
                        pGraveyard.PrivDetach(pNode, ref pGraveyard.poHead);

                        pNode.Clear();

                        pShield.Add(pNode);
                        pNode.ActivateGameSprite(pSB_Shields);
                        pNode.ActivateCollisionSprite(pSB_Boxes);
                    }

                    pNode = pNextNode;
                }


                pShield = (GameObject)pShield.pNext;
            }

            //-------------------------------------------------------------------------------------------------
            //lastly add the bricks to the Shield columns in each shield
            //-------------------------------------------------------------------------------------------------

            pShield = (GameObject)pShieldRoot.GetFirstChild();
            Debug.Assert(pShield != null);

            while (pShield != null)
            {
                GameObject pShieldColumn = (GameObject)pShield.GetFirstChild();
                Debug.Assert(pShieldColumn != null);

                //iterate through the shield columns
                while (pShieldColumn != null)
                {
                    //iterate through the graveyard
                    pNode = pGraveyard.poHead;
                    while (pNode != null)
                    {
                        //save this to iterate, because we will possibly remove the next pointer it
                        pNextNode = (GameObject)pNode.pNext;

                        //check the parent reference to the column
                        if (pShieldColumn == pNode.pParent)
                        {
                            //dettach from list then add it to tree
                            pGraveyard.PrivDetach(pNode, ref pGraveyard.poHead);

                            ShieldBrick pAlien = (ShieldBrick)pNode;
                            pAlien.x             = pAlien.OrigX();
                            pAlien.y             = pAlien.OrigY();
                            pAlien.bMarkForDeath = false;

                            pNode.Clear();

                            pShieldColumn.Add(pNode);
                            pNode.ActivateGameSprite(pSB_Shields);
                            pNode.ActivateCollisionSprite(pSB_Boxes);
                        }

                        pNode = pNextNode;
                    }


                    pShieldColumn = (GameObject)pShieldColumn.pNext;
                }

                pShield = (GameObject)pShield.pNext;
            }
        }