示例#1
0
        //rebuilds the Alien Group Tree
        public static void RaiseDead()
        {
            SpriteBatch pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);
            SpriteBatch pSB_Boxes  = SpriteBatchMan.Find(SpriteBatch.Name.Boxes);
            GameObject  pRoot      = GONodeMan.Find(GameObject.Name.AlienGrid);

            GraveyardMan pGraveyard = GraveyardMan.PrivGetInstance();

            GameObject pSafety = pGraveyard.poHead;

            GameObject pNode = pSafety;

            GameObject pNextNode = null;

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

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

                    pNode.Clear();

                    pRoot.Add(pNode);
                    pNode.ActivateGameSprite(pSB_Aliens);
                    pNode.ActivateCollisionSprite(pSB_Boxes);
                }

                pNode = pNextNode;
            }

            //random check
            //check to see if AlienGroup has a column
            Debug.Assert(pRoot.GetFirstChild() != null);

            GameObject pColumn = (GameObject)pRoot.GetFirstChild();

            //iterate through the column siblings
            while (pColumn != 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 (pColumn == pNode.pParent)
                    {
                        //dettach from list then add it to tree
                        pGraveyard.PrivDetach(pNode, ref pGraveyard.poHead);

                        AlienCategory pAlien = (AlienCategory)pNode;
                        pAlien.x             = pAlien.OrigX();
                        pAlien.y             = pAlien.OrigY() - 100.0f;
                        pAlien.bMarkForDeath = false;

                        pNode.Clear();

                        pColumn.Add(pNode);
                        pNode.ActivateGameSprite(pSB_Aliens);
                        pNode.ActivateCollisionSprite(pSB_Boxes);
                    }

                    pNode = pNextNode;
                }


                pColumn = (GameObject)pColumn.pNext;
            }
        }
示例#2
0
        //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;
            }
        }