Example #1
0
        public static void DumpNodes()
        {
            GraveyardMan pGraveyard = GraveyardMan.PrivGetInstance();

            Debug.Assert(pGraveyard != null);

            GameObject pNode = pGraveyard.poHead;

            if (pNode == null)
            {
                Debug.WriteLine("-----------------------------");
                Debug.WriteLine("Graveyard Empty");
                Debug.WriteLine("-----------------------------");
            }
            else
            {
                int i = 0;
                while (pNode != null)
                {
                    Debug.WriteLine("");
                    Debug.WriteLine("{0})----------", i);
                    Debug.WriteLine("{0} ({1})", pNode.GetName(), pNode.GetHashCode());
                    Debug.WriteLine("Parent: {0} X:{1}, Y:{2}", pNode.pParent, pNode.x, pNode.y);

                    pNode = (GameObject)pNode.pNext;
                    i++;
                }
            }
        }
Example #2
0
        static public void Bury(GameObject pGameObject)
        {
            Debug.Assert(pGameObject != null);

            GraveyardMan pGraveyard = GraveyardMan.PrivGetInstance();

            //everything is added to the front of the list
            //first time
            if (pGraveyard.poHead == null)
            {
                pGraveyard.poHead = pGameObject;
                pGameObject.pNext = null;
                pGameObject.pPrev = null;
            }

            //every other time
            else
            {
                pGameObject.pNext       = pGraveyard.poHead;
                pGameObject.pPrev       = null;
                pGraveyard.poHead.pPrev = pGameObject;
                pGraveyard.poHead       = pGameObject;
            }
            pGraveyard.Total++;
        }
Example #3
0
        static public void Create()
        {
            Debug.Assert(pInstance == null);

            if (pInstance == null)
            {
                pInstance = new GraveyardMan();
            }

            Debug.Assert(pInstance != null);

            pInstance.poHead = null;
        }
Example #4
0
        public static void Destroy()
        {
            GraveyardMan pGraveyard = GraveyardMan.PrivGetInstance();

            //TO DO need this big time!!!!
#if (TRACK_DESTRUCTOR_MAN)
            Debug.WriteLine("GraveyardMan.Destroy()");
#endif
            pGraveyard.PrivFlush();

#if (TRACK_DESTRUCTOR_MAN)
            Debug.WriteLine("{0} ({1})", GraveyardMan.pInstance, GraveyardMan.pInstance.GetHashCode());
#endif
            GraveyardMan.pInstance = null;
            pGraveyard.poHead      = null;
        }
Example #5
0
        //intially had this in each of my objects(D.R.Y)
        //to remove Sprite & its collision box
        //from the sprite batches and GO node man
        public virtual void Remove()
        {
            //Debug.WriteLine("Remove: {0}", this);


            Debug.Assert(this.poProxySprite != null);
            SBNode pSBNode = this.poProxySprite.GetSBNode();

            Debug.Assert(pSBNode != null);
            SpriteBatchMan.RemoveSprite(pSBNode);

            Debug.Assert(this.poColObj != null);
            Debug.Assert(this.poColObj.pColSprite != null);
            pSBNode = this.poColObj.pColSprite.GetSBNode();

            Debug.Assert(pSBNode != null);
            SpriteBatchMan.RemoveSprite(pSBNode);


            GONodeMan.Dettach(this);

            //then add it to a graveyard to use later
            GraveyardMan.Bury(this);
        }
Example #6
0
        public override void Update()
        {
            //first time through set a time to change states
            if (this.bStateToggle == true)
            {
                //inititally used the game to get time
                //Testing timer man
                //could use Timer Man for current time
                float curTime = TimerMan.GetCurrentTime();
                this.ChangeStateTime = curTime + 10;
                this.bStateToggle    = false;
            }


            else
            {
                SpaceInvaders pGame = GameMan.GetGame();

                //time has elapsed start over
                if (this.ChangeStateTime <= pGame.GetTime())
                {
                    this.bStateToggle = true;

                    SpriteBatch pSB_Intro = SpriteBatchMan.Find(SpriteBatch.Name.IntroScreen);
                    pSB_Intro.bToggle = true;

                    SpriteBatch pGameOverScreen = SpriteBatchMan.Find(SpriteBatch.Name.GameOver);
                    pGameOverScreen.bToggle = false;

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

                    //----------------------------------------------------------------------------------------------------
                    //Things we need to reset for the Next game?
                    //----------------------------------------------------------------------------------------------------

                    // need to remove ship from its root
                    GameObject pShipRoot = GONodeMan.Find(GameObject.Name.ShipRoot);
                    GameObject pShip     = (GameObject)pShipRoot.GetFirstChild();

                    if (pShip != null)
                    {
                        pShip.Remove();
                    }

                    ShipMan.Destroy();

                    GraveyardMan.KillAll();
                    //GraveyardMan.DumpNodes();
                    GraveyardMan.Destroy();


                    TimerMan.ClearActiveList();
                    TimerMan.DumpTimeEvents();

                    AlienGroup pAlienGroup = (AlienGroup)GONodeMan.Find(GameObject.Name.AlienGrid);
                    pAlienGroup.SetDeltaMove(15.0f);

                    SpriteBatch pSB_Projectiles = SpriteBatchMan.Find(SpriteBatch.Name.Projectiles);
                    pSB_Projectiles.bToggle = false;

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

                    pGame.SetGameState(GameMan.State.Intro);
                    pGame.GetCurrentState().Update();
                }
            }
        }
Example #7
0
        public override void LoadContent()
        {
            ShipMan.Create();
            GraveyardMan.Create();

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

            pSB_Aliens.bToggle = true;

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

            pSB_Boxes.bToggle = false;

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

            pSB_Shields.bToggle = true;

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

            pSB_InGame.bToggle = true;

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

            pSB_Projectiles.bToggle = true;

            //SpriteBatch pSB_Splats = SpriteBatchMan.Find(SpriteBatch.Name.Splats);
            //pSB_Splats.bToggle = true;

            SpaceInvaders pGame = GameMan.GetGame();

            IrrKlang.ISoundEngine pSndEngine = pGame.GetSndEngine();

            //-------------------------------------------------------------------------------------------------------
            //create factory
            //--------------------------------------------------------------------------------------------------------

            Composite pAlienGroup = (Composite)GONodeMan.Find(GameObject.Name.AlienGrid);

            AlienFactory AF = new AlienFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes, pAlienGroup);

            GameObject pGameObj;

            //AF.SetParent(pAlienGroup);
            //GameObject pCol = AF.Create(GameObject.Name.Column_1, AlienCategory.Type.Column, 0.0f, 0.0f);

            //AF.SetParent(pCol);

            //pGameObj = AF.Create(GameObject.Name.Octopus, AlienCategory.Type.Octopus, 70.0f, 600);

            //Column Creation 1 - 11
            for (int i = 0; i < 11; i++)
            {
                AF.SetParent(pAlienGroup);
                GameObject pCol = AF.Create(GameObject.Name.Column_1 + i, AlienCategory.Type.Column, 0.0f, 0.0f, i);

                AF.SetParent(pCol);

                pGameObj = AF.Create(GameObject.Name.Octopus, AlienCategory.Type.Octopus, 70.0f + i * 43.0f, 600);
                pGameObj = AF.Create(GameObject.Name.Crab, AlienCategory.Type.Crab, 70.0f + i * 43.0f, 560);
                pGameObj = AF.Create(GameObject.Name.Crab, AlienCategory.Type.Crab, 70.0f + i * 43.0f, 520);
                pGameObj = AF.Create(GameObject.Name.Squid, AlienCategory.Type.Squid, 70.0f + i * 43.0f, 480);
                pGameObj = AF.Create(GameObject.Name.Squid, AlienCategory.Type.Squid, 70.0f + i * 43.0f, 440);
            }

            //Debug.WriteLine("-------------------");
            //pAlienGroup.Print();

            //---------------------------------------------------------------------------------------------------------
            // Shields
            //---------------------------------------------------------------------------------------------------------

            float posX = 80;
            float posY = 120;

            for (int i = 0; i < 4; i++)
            {
                ShieldFactory.ShieldCreator(posX, posY, GameObject.Name.ShieldGrid_1 + i);
                posX += 130;
            }

            //Debug.WriteLine("-------------------");
            //GameObject pShieldRoot = GONodeMan.Find(GameObject.Name.ShieldRoot);
            //pShieldRoot.Print();

            //--------------------------------------------------------------------------------------------------------------
            //Time Events
            //--------------------------------------------------------------------------------------------------------------

            UFORoot pUFORoot = (UFORoot)GONodeMan.Find(GameObject.Name.UFORoot);

            MoveGrid pMove = new MoveGrid(pAlienGroup, pSndEngine);

            SendUFO pSendIt = new SendUFO(pUFORoot);

            //BombDrop pBombDrop0 = new BombDrop((AlienGroup)pAlienGroup);
            BombDrop pBombDrop1 = new BombDrop((AlienGroup)pAlienGroup);
            BombDrop pBombDrop2 = new BombDrop((AlienGroup)pAlienGroup);

            SpeedUpCheck pSpeedCheck = new SpeedUpCheck((AlienGroup)pAlienGroup);

            //---------------------------------------------------------------------------------------------------------
            //Add Events
            //---------------------------------------------------------------------------------------------------------

            AnimateCrab  pAnimCrab  = (AnimateCrab)AnimMan.Find(Animation.Name.AnimateCrab);
            AnimateSquid pAnimSquid = (AnimateSquid)AnimMan.Find(Animation.Name.AnimateSquid);
            AnimateOcto  pAnimOcto  = (AnimateOcto)AnimMan.Find(Animation.Name.AnimateOcto);


            TimerMan.Add(TimeEvent.Name.AnimateOcto, pAnimOcto, 0.60f);
            TimerMan.Add(TimeEvent.Name.AnimateSquid, pAnimSquid, 0.60f);
            TimerMan.Add(TimeEvent.Name.AnimateCrab, pAnimCrab, 0.60f);
            TimerMan.Add(TimeEvent.Name.MoveGrid, pMove, 0.60f);

            //TimerMan.Add(TimeEvent.Name.ColumnShoot, pBombDrop0, 1.0f);
            TimerMan.Add(TimeEvent.Name.ColumnShoot, pBombDrop1, 2.0f);
            TimerMan.Add(TimeEvent.Name.ColumnShoot, pBombDrop2, 4.0f);

            TimerMan.Add(TimeEvent.Name.SpeedCheck, pSpeedCheck, 12.0f);
            TimerMan.Add(TimeEvent.Name.SendUFO, pSendIt, 25.0f);
        }
Example #8
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;
            }
        }
Example #9
0
        public static void KillAll()
        {
            GraveyardMan pGraveyard = GraveyardMan.PrivGetInstance();

            Debug.Assert(pGraveyard != null);

            // trying to gather leftover Aliens
            GameObject pAlienGroup = GONodeMan.Find(GameObject.Name.AlienGrid);

            //Start with the columns
            GameObject pColumn = (GameObject)pAlienGroup.GetFirstChild();

            while (pColumn != null)
            {
                //store the next column
                GameObject pNextColumn = (GameObject)pColumn.pNext;

                //remove aliens from the column
                GameObject pAlien = (GameObject)pColumn.GetFirstChild();
                while (pAlien != null)
                {
                    GameObject pNextAlien = (GameObject)pAlien.pNext;

                    pAlien.Remove();

                    pAlien = pNextAlien;
                }

                //once your out do a check to see if its null
                Debug.Assert(pColumn.GetFirstChild() == null);

                //remove the column
                pColumn.Remove();

                pColumn = pNextColumn;
            }

            // trying to gather leftover Shieldbricks
            GameObject pShieldRoot = GONodeMan.Find(GameObject.Name.ShieldRoot);

            //start with shields (4 of them if all there)
            GameObject pShield = (GameObject)pShieldRoot.GetFirstChild();

            while (pShield != null)
            {
                //store the next shield
                GameObject pNextShield = (GameObject)pShield.pNext;

                //go to the shield columns
                GameObject pShieldColumn = (GameObject)pShield.GetFirstChild();
                while (pShieldColumn != null)
                {
                    GameObject pNextColumn = (GameObject)pShieldColumn.pNext;

                    //finally at the bricks
                    GameObject pBrick = (GameObject)pShieldColumn.GetFirstChild();
                    while (pBrick != null)
                    {
                        GameObject pNextBrick = (GameObject)pBrick.pNext;

                        pBrick.Remove();

                        pBrick = pNextBrick;
                    }

                    //once your out do a check to see if its null
                    Debug.Assert(pShieldColumn.GetFirstChild() == null);

                    //remove the column from shield
                    pShieldColumn.Remove();

                    pShieldColumn = pNextColumn;
                }

                //once your out do a check to see if its null
                Debug.Assert(pShield.GetFirstChild() == null);

                //remove the shield from root
                pShield.Remove();

                pShield = pNextShield;
            }
        }
Example #10
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;
            }
        }
        public override void LoadContent()
        {
            //make the next wave more difficult
            //change grid movement speed and add more bombs
            GraveyardMan.RaiseDead();

            //can be finicky might need to replace
            //GraveyardMan.RebuildShields();

            //-------------------------------------------------------------------------------------------------------
            //create factory
            //--------------------------------------------------------------------------------------------------------

            Composite pAlienGroup = (Composite)GONodeMan.Find(GameObject.Name.AlienGrid);

            //AlienFactory AF = new AlienFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes, pAlienGroup);

            //GameObject pGameObj;

            //AF.SetParent(pAlienGroup);
            //GameObject pCol = AF.Create(GameObject.Name.Column_1, AlienCategory.Type.Column, 0.0f, 0.0f);

            //AF.SetParent(pCol);

            //pGameObj = AF.Create(GameObject.Name.Octopus, AlienCategory.Type.Octopus, 70.0f, 600);

            //Column Creation 1 - 11
            //for (int i = 0; i < 1; i++)
            //{
            //    AF.SetParent(pAlienGroup);
            //    GameObject pCol = AF.Create(GameObject.Name.Column_1 + i, AlienCategory.Type.Column, 0.0f, 0.0f, i);

            //    AF.SetParent(pCol);

            //    pGameObj = AF.Create(GameObject.Name.Octopus, AlienCategory.Type.Octopus, 70.0f + i * 43.0f, 660);
            //    pGameObj = AF.Create(GameObject.Name.Crab, AlienCategory.Type.Crab, 70.0f + i * 43.0f, 620);
            //    pGameObj = AF.Create(GameObject.Name.Crab, AlienCategory.Type.Crab, 70.0f + i * 43.0f, 580);
            //    pGameObj = AF.Create(GameObject.Name.Squid, AlienCategory.Type.Squid, 70.0f + i * 43.0f, 540);
            //    pGameObj = AF.Create(GameObject.Name.Squid, AlienCategory.Type.Squid, 70.0f + i * 43.0f, 500);
            //}

            //Debug.WriteLine("-------------------");
            //pAlienGroup.Print();

            //---------------------------------------------------------------------------------------------------------
            // Shields
            //---------------------------------------------------------------------------------------------------------

            //float posX = 80;
            //float posY = 120;

            //for (int i = 0; i < 1; i++)
            //{
            //    ShieldFactory.ShieldCreator(posX, posY, GameObject.Name.ShieldGrid_1 + i);
            //    posX += 130;
            //}

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

            //GameObject pShieldRoot = GONodeMan.Find(GameObject.Name.ShieldRoot);
            //pShieldRoot.Print();


            //---------------------------------------------------------------------------------
            //Event/Difficulty Modifiers
            //----------------------------------------------------------------------------------
            TimeEvent pE1 = TimerMan.Find(TimeEvent.Name.AnimateSquid);
            TimeEvent pE2 = TimerMan.Find(TimeEvent.Name.AnimateOcto);
            TimeEvent pE3 = TimerMan.Find(TimeEvent.Name.AnimateCrab);

            TimeEvent pE4 = TimerMan.Find(TimeEvent.Name.MoveGrid);

            pE1.SetTriggerTime(0.50f);
            pE2.SetTriggerTime(0.50f);
            pE3.SetTriggerTime(0.50f);
            pE4.SetTriggerTime(0.50f);

            //pAlienGroup.SetDeltaMove(18.0f);
            BombDrop pBombDrop1 = new BombDrop((AlienGroup)pAlienGroup);
            BombDrop pBombDrop2 = new BombDrop((AlienGroup)pAlienGroup);
            BombDrop pBombDrop3 = new BombDrop((AlienGroup)pAlienGroup);

            TimerMan.Add(TimeEvent.Name.ColumnShoot, pBombDrop1, 1.0f);
            TimerMan.Add(TimeEvent.Name.ColumnShoot, pBombDrop2, 3.0f);
            TimerMan.Add(TimeEvent.Name.ColumnShoot, pBombDrop3, 5.0f);
        }