public override void Notify()
        {
            //Double-check to verify the different visitor pattern
            this.pUFO  = (UFO)this.pSubject.pObjA;
            this.pWall = (WallCategory)this.pSubject.pObjB;
            Debug.Assert(this.pUFO != null);

            if (pUFO.bMarkForDeath == false)
            {
                pUFO.bMarkForDeath = true;

                //this is to eliminate some of the checks that the UFORoot
                //does with the wall while it generates another UFO
                UFORoot pUFORoot = (UFORoot)GONodeMan.Find(GameObject.Name.UFORoot);
                Debug.Assert(pUFORoot != null);

                pUFORoot.x = -100;
                pUFORoot.y = -100;
                pUFORoot.SetDeltaMove(-1.0f);


                MissedUFOobserver pObserver = new MissedUFOobserver(this);
                DelayedObjectMan.Attach(pObserver);
            }
        }
        public override void Notify()
        {
            GameObject pObject = this.pSubject.pObjA;

            this.pShip = (Ship)this.pSubject.pObjB;
            Debug.Assert(pShip != null);

            if (pShip.bMarkForDeath == false)
            {
                this.pShip.bMarkForDeath = true;

                //had initially tried to use the reference "this" ship
                //did not work FYI, needed to get the ship from manager
                Ship pShip = ShipMan.GetShip();

                pShip.SetShootState(ShipMan.ShootState.End);
                pShip.SetMoveState(ShipMan.MoveState.NoMove);


                HitShipObserver pObserver = new HitShipObserver(this);
                DelayedObjectMan.Attach(pObserver);
            }

            //very wierd not sure how i feel about it
            if (pObject.GetName() == GameObject.Name.Octopus || pObject.GetName() == GameObject.Name.Squid || pObject.GetName() == GameObject.Name.Crab)
            {
                //we want to reset the grids location
                AlienGroup pGrid = (AlienGroup)GONodeMan.Find(GameObject.Name.AlienGrid);
                pGrid.MoveUp();
            }
        }
示例#3
0
        //similar to Activate Missile
        public static Ship ActivateShip()
        {
            ShipMan pShipMan = ShipMan.PrivInstance();

            Debug.Assert(pShipMan != null);

            Ship pShip = new Ship(GameObject.Name.Ship, GameSprite.Name.Ship, 200, 60);

            pShipMan.poShip = pShip;

            GameObject pShipRoot = GONodeMan.Find(GameObject.Name.ShipRoot);

            Debug.Assert(pShipRoot != null);

            pShipRoot.Add(pShipMan.poShip);

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

            pShipMan.poShip.ActivateGameSprite(pSB_Aliens);
            pShipMan.poShip.ActivateCollisionSprite(pSB_Boxes);

            pShipMan.TakeLife(1);
            return(pShipMan.poShip);
        }
示例#4
0
        public static void DumpGONodes()
        {
            GONodeMan pMan = GONodeMan.PrivGetInstance();

            Debug.Assert(pMan != null);

            pMan.BaseDumpNodes();
        }
示例#5
0
        public static void Remove(GONode pNode)
        {
            GONodeMan pGOMan = GONodeMan.PrivGetInstance();

            Debug.Assert(pGOMan != null);

            Debug.Assert(pNode != null);
            pGOMan.BaseRemove(pNode);
        }
示例#6
0
        //to destroy game objects that are hit
        public static void Dettach(GameObject pGameObject)
        {
            GONodeMan pGOMan = GONodeMan.PrivGetInstance();

            Debug.Assert(pGOMan != null);

            //Remeber: a doublly linked list of trees

            //whatever game object we get, we have to travel up its tree
            // to its its tree's root/ upper most parent
            Debug.Assert(pGameObject != null);
            GameObject pTemp = pGameObject;

            GameObject pRoot = null;

            while (pTemp != null)
            {
                pRoot = pTemp;
                pTemp = (GameObject)Iterator.GetParent(pTemp);
                //keep traveling up the tree

                //exit out at the top of the tree
            }

            //Found the tree our game object is in
            // now go traverse the DLink list to that tree
            GONode pTree = (GONode)pGOMan.BaseGetActive();

            while (pTree != null)
            {
                //check if the game objects match
                if (pTree.poGameObject == pRoot)
                {
                    break;
                }

                pTree = (GONode)pTree.pNext;
            }

            //Now we are in the tree with the Game Object
            //we need to remove
            Debug.Assert(pTree != null);
            Debug.Assert(pTree.poGameObject != null);

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

            Debug.Assert(pParent != null);


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

            Debug.Assert(pChild == null);

            //finally
            //Remove Gamobject from its parent composite
            pParent.Remove(pGameObject);
        }
示例#7
0
        private void PrivStatDump()
        {
            GONodeMan pGOMan = GONodeMan.PrivGetInstance();

            Debug.Assert(pGOMan != null);

            Debug.WriteLine("");
            Debug.WriteLine("Game Object Manager Stats---------------------");
            pGOMan.BaseStatDump();
        }
示例#8
0
        public static void Create(int reserveNum = 3, int growth = 1)
        {
            Debug.Assert(reserveNum > 0);
            Debug.Assert(growth > 0);

            Debug.Assert(pInstance == null);

            if (pInstance == null)
            {
                pInstance = new GONodeMan(reserveNum, growth);
            }
        }
示例#9
0
        public static GONode Attach(GameObject pGObject)
        {
            GONodeMan pGOMan = GONodeMan.PrivGetInstance();

            Debug.Assert(pGOMan != null);

            GONode pNode = (GONode)pGOMan.BaseAdd();

            Debug.Assert(pNode != null);

            pNode.Set(pGObject);
            return(pNode);
        }
示例#10
0
        public static GameObject Find(GameObject.Name name)
        {
            GONodeMan pGOMan = GONodeMan.PrivGetInstance();

            Debug.Assert(pGOMan != null);

            pGOMan.poNodeCompare.poGameObject.SetName(name);

            GONode pNode = (GONode)pGOMan.BaseFind(pGOMan.poNodeCompare);

            Debug.Assert(pNode != null);

            return(pNode.poGameObject);
        }
示例#11
0
        public override void Update()
        {
            SpaceInvaders pGame = GameMan.GetGame();

            pGame.sndEngine.Update();

            InputManager.Update();

            Simulation.Update(pGame.GetTime());

            if (Simulation.GetTimeStep() > 0.0f)
            {
                //start timer
                TimerMan.Update(Simulation.GetTotalTime());

                //Update all the game objects(nodes)
                GONodeMan.Update();

                //check for collisions
                ColPairMan.Process();

                //process observers
                DelayedObjectMan.Process();
            }


            //---------------------------------------------------------------------------------------------------------
            // Font Practice
            //---------------------------------------------------------------------------------------------------------

            Font pScoreMessage = FontMan.Find(Font.Name.P1Points);

            Debug.Assert(pScoreMessage != null);
            pScoreMessage.UpdateMessage("" + (PlayerMan.GetP1Score()));

            Font pHiScore = FontMan.Find(Font.Name.HiPoints);

            Debug.Assert(pHiScore != null);
            pHiScore.UpdateMessage("" + PlayerMan.GetHiScore());

            Font pP1LivesLeft = FontMan.Find(Font.Name.LivesP1);

            Debug.Assert(pP1LivesLeft != null);
            pP1LivesLeft.UpdateMessage("P1 Lives: " + (PlayerMan.GetP1Lives()));
        }
示例#12
0
        public virtual void Reset()
        {
            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);
        }
示例#13
0
        //-----------------------------------------------------------------------------
        // Game::UnLoadContent()
        //       unload content (resources loaded above)
        //       unload all content that was loaded before the Engine Loop started
        //-----------------------------------------------------------------------------
        public override void UnLoadContent()
        {
            TextureMan.Destroy();
            ImageMan.Destroy();
            GameSpriteMan.Destroy();
            BoxSpriteMan.Destroy();
            ProxySpriteMan.Destroy();
            SpriteBatchMan.Destroy();
            GONodeMan.Destroy();
            TimerMan.Destroy();
            ColPairMan.Destroy();
            FontMan.Destroy();

            Simulation.Destroy();
            AnimMan.Destroy();
            InputManager.Destroy();
            GlyphMan.Destroy();
            //ShipMan.Destroy();
            //GraveyardMan.Destroy();
        }
示例#14
0
        public static void Update()
        {
            // go through active list and update everything in it
            // while loop

            GONodeMan pMan = GONodeMan.PrivGetInstance();

            Debug.Assert(pMan != null);

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

            GONode pGONode = (GONode)pMan.BaseGetActive();


            while (pGONode != null)
            {
                //Debug.WriteLine("update: GameObjectTree {0} ({1})", pGONode.poGameObject, pGONode.poGameObject.GetHashCode());
                //Debug.WriteLine("   +++++");
                if (pGONode.poGameObject.GetPlayerOption() == true)
                {
                    ReverseIterator pRev = new ReverseIterator(pGONode.poGameObject);

                    //need to update the children 1st then work our way back up the tree
                    // So depth first(ReverseIterator)
                    // maintaines integrity of the bounding collision rectangles
                    Component pNode = pRev.First();
                    while (!pRev.IsDone())
                    {
                        GameObject pGameObj = (GameObject)pNode;

                        //Debug.WriteLine("update: {0} ({1})", pGameObj, pGameObj.GetHashCode());
                        pGameObj.Update();

                        pNode = pRev.Next();
                    }
                    //Debug.WriteLine("   ------");
                    pGONode = (GONode)pGONode.pNext;
                }
            }
        }
示例#15
0
        public static void Destroy()
        {
            GONodeMan pGOMan = GONodeMan.PrivGetInstance();

            Debug.Assert(pGOMan != null);

            pGOMan.PrivStatDump();

#if (TRACK_DESTRUCTOR_MAN)
            Debug.WriteLine("GONodeMan.Destroy()");
#endif
            pGOMan.BaseDestroy();

#if (TRACK_DESTRUCTOR_MAN)
            Debug.WriteLine("     {0} ({1})", pGOMan.poNullGO, pGOMan.poNullGO.GetHashCode());
            Debug.WriteLine("     {0} ({1})", pGOMan.poNodeCompare, pGOMan.poNodeCompare.GetHashCode());
            Debug.WriteLine("     {0} ({1})", GONodeMan.pInstance, GONodeMan.pInstance.GetHashCode());
#endif
            pGOMan.poNullGO      = null;
            pGOMan.poNodeCompare = null;
            GONodeMan.pInstance  = null;
        }
示例#16
0
        public void ActivateBomb(float minX, float minY)
        {
            GameObject pBombRoot = GONodeMan.Find(GameObject.Name.BombRoot);

            Debug.Assert(pBombRoot != null);

            Random rNum   = new Random();
            int    choice = rNum.Next(1, 4);

            switch (choice)
            {
            case 1:
                this.pBomb = new  Bomb(GameObject.Name.Bomb, GameSprite.Name.BombStraight, new FallStraight(), this, minX, minY);
                break;

            case 2:
                this.pBomb = new Bomb(GameObject.Name.Bomb, GameSprite.Name.BombDagger, new FallDagger(), this, minX, minY);
                break;

            case 3:
                this.pBomb = new Bomb(GameObject.Name.Bomb, GameSprite.Name.BombZigZag, new FallZigZag(), this, minX, minY);
                break;

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



            pBombRoot.Add(this.pBomb);

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

            this.pBomb.ActivateGameSprite(pSB_Projectiles);
            this.pBomb.ActivateCollisionSprite(pSB_Boxes);
        }
        public override void Notify()
        {
            this.pUFO = (UFO)this.pSubject.pObjB;
            Debug.Assert(this.pUFO != null);

            if (pUFO.bMarkForDeath == false)
            {
                pUFO.bMarkForDeath = true;

                //this is to eliminate some of the checks that the UFORoot
                //does with the wall while it generates another UFO
                UFORoot pUFORoot = (UFORoot)GONodeMan.Find(GameObject.Name.UFORoot);
                Debug.Assert(pUFORoot != null);

                pUFORoot.x = -100;
                pUFORoot.y = -100;
                pUFORoot.SetDeltaMove(-1.0f);


                RemoveUFOobserver pObserver = new RemoveUFOobserver(this);
                DelayedObjectMan.Attach(pObserver);
            }
        }
示例#18
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);
        }
示例#19
0
        public static Missile ActivateMissile()
        {
            ShipMan pShipMan = ShipMan.PrivInstance();

            Debug.Assert(pShipMan != null);

            pShipMan.pMissile = new Missile(GameObject.Name.Missile, GameSprite.Name.Missile, 10, 10);

            //attach missile to missile group(should be missileRoot)
            GameObject pMissileGroup = GONodeMan.Find(GameObject.Name.MissileGroup);

            Debug.Assert(pMissileGroup != null);

            pMissileGroup.Add(pShipMan.pMissile);

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

            pShipMan.pMissile.ActivateGameSprite(pSB_Projectiles);
            pShipMan.pMissile.ActivateCollisionSprite(pSB_Boxes);


            return(pShipMan.pMissile);
        }
示例#20
0
        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);
        }
示例#21
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;
            }
        }
示例#22
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;
            }
        }
示例#23
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);
        }
示例#24
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();
                }
            }
        }
示例#25
0
        //This loadContent is called in the actual Game.cs
        //So its done before the player even presses input
        // and only called once
        public override void LoadContent()
        {
            //---------------------------------------------------------------------------------------------------------
            // Create Managers
            //---------------------------------------------------------------------------------------------------------

            TextureMan.Create(6, 1);
            ImageMan.Create(25, 2);
            GameSpriteMan.Create(20, 1);

            //i'm grossly inefficient at this point
            //------------------------------------------------
            BoxSpriteMan.Create(200, 100);
            ProxySpriteMan.Create(200, 100);
            //-------------------------------------------------
            SpriteBatchMan.Create(8, 1);
            GlyphMan.Create();
            FontMan.Create(12, 1);

            GONodeMan.Create(10, 3);
            TimerMan.Create(7, 3);
            ColPairMan.Create(16, 1);

            //Experimental managers
            AnimMan.Create(3, 1);
            Simulation.Create();
            PlayerMan.Create();

            SpaceInvaders pGame = GameMan.GetGame();

            IrrKlang.ISoundEngine pSndEngine = pGame.GetSndEngine();


            //---------------------------------------------------------------------------------------------------------
            // Load the Textures and Font {Consolas20pt}
            //---------------------------------------------------------------------------------------------------------

            TextureMan.Add(Texture.Name.Aliens14x14, "aliens14x14.tga");
            TextureMan.Add(Texture.Name.Aliens, "SpaceInvadersSprites.tga");

            TextureMan.Add(Texture.Name.Consolas36pt, "Consolas36pt.tga");
            TextureMan.Add(Texture.Name.Consolas20pt, "Consolas20pt.tga");

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



            //---------------------------------------------------------------------------------------------------------
            // Load Images
            //---------------------------------------------------------------------------------------------------------

            ImageMan.Add(Image.Name.CrabU, Texture.Name.Aliens14x14, 318, 180, 160, 116);
            ImageMan.Add(Image.Name.CrabD, Texture.Name.Aliens14x14, 318, 24, 160, 116);
            ImageMan.Add(Image.Name.OctopusU, Texture.Name.Aliens14x14, 610, 25, 122, 115);
            ImageMan.Add(Image.Name.OctopusD, Texture.Name.Aliens14x14, 610, 180, 119, 112);
            ImageMan.Add(Image.Name.SquidU, Texture.Name.Aliens14x14, 51, 24, 175, 116);
            ImageMan.Add(Image.Name.SquidD, Texture.Name.Aliens14x14, 51, 180, 175, 110);

            ImageMan.Add(Image.Name.Ship, Texture.Name.Aliens14x14, 52, 336, 194, 114);
            ImageMan.Add(Image.Name.UFO, Texture.Name.Aliens14x14, 81, 502, 229, 98);
            ImageMan.Add(Image.Name.Missile, Texture.Name.Aliens14x14, 378, 798, 14, 98);

            ImageMan.Add(Image.Name.AlienSplat, Texture.Name.Aliens14x14, 573, 490, 183, 110);
            ImageMan.Add(Image.Name.ShipSplat, Texture.Name.Aliens, 651, 942, 117, 72);
            ImageMan.Add(Image.Name.BombSplat, Texture.Name.Aliens, 350, 90, 49, 72);
            ImageMan.Add(Image.Name.UFOSplat, Texture.Name.Aliens, 224, 230, 187, 77);

            ImageMan.Add(Image.Name.BombStraight, Texture.Name.Aliens, 216, 94, 16, 56);
            ImageMan.Add(Image.Name.BombZigZag, Texture.Name.Aliens, 349, 161, 23, 59);
            ImageMan.Add(Image.Name.BombCross, Texture.Name.Aliens, 210, 163, 30, 48);

            ImageMan.Add(Image.Name.Brick, Texture.Name.Aliens, 50, 120, 20, 10);
            ImageMan.Add(Image.Name.BrickLeft_Top1, Texture.Name.Aliens, 40, 100, 20, 10);
            ImageMan.Add(Image.Name.BrickLeft_Top2, Texture.Name.Aliens, 40, 110, 20, 10);
            ImageMan.Add(Image.Name.BrickLeft_Bottom, Texture.Name.Aliens, 75, 190, 15, 10);
            ImageMan.Add(Image.Name.BrickRight_Top1, Texture.Name.Aliens, 189, 125, 20, 10);
            ImageMan.Add(Image.Name.BrickRight_Top2, Texture.Name.Aliens, 186, 126, 20, 10);
            ImageMan.Add(Image.Name.BrickRight_Bottom, Texture.Name.Aliens, 130, 190, 20, 10);


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

            GameSpriteMan.Add(GameSprite.Name.UFO, Image.Name.UFO, 400, 550, 50.0f, 25.0f);
            GameSpriteMan.Add(GameSprite.Name.Ship, Image.Name.Ship, 400, 25, 40.0f, 25.0f);

            GameSpriteMan.Add(GameSprite.Name.Crab, Image.Name.CrabU, 700, 480, 35, 20);
            GameSpriteMan.Add(GameSprite.Name.Squid, Image.Name.SquidU, 325, 350, 35, 20);
            GameSpriteMan.Add(GameSprite.Name.Octopus, Image.Name.OctopusU, 260, 350, 25, 20);

            GameSpriteMan.Add(GameSprite.Name.AlienSplat, Image.Name.AlienSplat, 50, 50, 30, 20);
            GameSpriteMan.Add(GameSprite.Name.ShipSplat, Image.Name.ShipSplat, 50, 50, 40, 25);
            GameSpriteMan.Add(GameSprite.Name.UFOsplat, Image.Name.UFOSplat, 50, 50, 50, 25);
            GameSpriteMan.Add(GameSprite.Name.BombSplat, Image.Name.BombSplat, 50, 50, 10, 15);

            GameSpriteMan.Add(GameSprite.Name.Missile, Image.Name.Missile, 100, 100, 5.0f, 15.0f);
            GameSpriteMan.Add(GameSprite.Name.BombZigZag, Image.Name.BombZigZag, 200, 200, 10, 20);
            GameSpriteMan.Add(GameSprite.Name.BombStraight, Image.Name.BombStraight, 100, 100, 5, 20);
            GameSpriteMan.Add(GameSprite.Name.BombDagger, Image.Name.BombCross, 100, 100, 10, 20);

            GameSpriteMan.Add(GameSprite.Name.Brick, Image.Name.Brick, 50, 25, 10, 5);
            GameSpriteMan.Add(GameSprite.Name.Brick_LeftTop1, Image.Name.BrickLeft_Top1, 50, 25, 10, 5);
            GameSpriteMan.Add(GameSprite.Name.Brick_LeftTop2, Image.Name.BrickLeft_Top2, 50, 25, 10, 5);
            GameSpriteMan.Add(GameSprite.Name.Brick_LeftBottom, Image.Name.BrickLeft_Bottom, 50, 25, 10, 5);
            GameSpriteMan.Add(GameSprite.Name.Brick_RightTop1, Image.Name.BrickRight_Top1, 50, 25, 10, 5);
            GameSpriteMan.Add(GameSprite.Name.Brick_RightTop2, Image.Name.BrickRight_Top2, 50, 25, 10, 5);
            GameSpriteMan.Add(GameSprite.Name.Brick_RightBottom, Image.Name.BrickRight_Bottom, 50, 25, 10, 5);


            //------------------------------------------------------------------------------------------
            //Attaching the sprites/batches
            //------------------------------------------------------------------------------------------

            SpriteBatch pSB_Intro = SpriteBatchMan.Add(SpriteBatch.Name.IntroScreen);


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

            pSB_Aliens.bToggle = false;

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

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

            pSB_Shields.bToggle = false;

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

            pSB_InGame.bToggle = false;

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

            pSB_Projectiles.bToggle = false;

            SpriteBatch pSB_GameOver = SpriteBatchMan.Add(SpriteBatch.Name.GameOver);

            pSB_GameOver.bToggle = false;

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

            //---------------------------------------------------------------------------------------------------------
            // Font
            //---------------------------------------------------------------------------------------------------------

            FontMan.Add(Font.Name.Title, SpriteBatch.Name.IntroScreen, "Space Invaders", Glyph.Name.Consolas36pt, 200, 700);
            FontMan.Add(Font.Name.NumOfPlayers, SpriteBatch.Name.IntroScreen, "Press 1 for Single Player", Glyph.Name.Consolas36pt, 120, 650);
            FontMan.Add(Font.Name.ShootButton, SpriteBatch.Name.IntroScreen, "Space <Bar> To Shoot", Glyph.Name.Consolas36pt, 140, 580);
            FontMan.Add(Font.Name.MoveButtons, SpriteBatch.Name.IntroScreen, "Left and Right Arrows To Move", Glyph.Name.Consolas36pt, 60, 540);
            FontMan.Add(Font.Name.SquidScore, SpriteBatch.Name.IntroScreen, "Squid = 30 points", Glyph.Name.Consolas36pt, 200, 480);
            FontMan.Add(Font.Name.CrabScore, SpriteBatch.Name.IntroScreen, "Crab = 40 points", Glyph.Name.Consolas36pt, 200, 440);
            FontMan.Add(Font.Name.OctoScore, SpriteBatch.Name.IntroScreen, "Octo = 50 points", Glyph.Name.Consolas36pt, 200, 400);
            FontMan.Add(Font.Name.UFOScore, SpriteBatch.Name.IntroScreen, "UFO = 100 points", Glyph.Name.Consolas36pt, 200, 360);
            FontMan.Add(Font.Name.TBD, SpriteBatch.Name.IntroScreen, "2 Player Coming Soon!", Glyph.Name.Consolas36pt, 160, 300);


            FontMan.Add(Font.Name.ScoreP1, SpriteBatch.Name.InGameScreen, "<P1 Score>", Glyph.Name.Consolas36pt, 20, 720);
            FontMan.Add(Font.Name.LivesP1, SpriteBatch.Name.InGameScreen, "P1 Lives:", Glyph.Name.Consolas36pt, 20, 20);
            FontMan.Add(Font.Name.P1Points, SpriteBatch.Name.InGameScreen, "0", Glyph.Name.Consolas36pt, 20, 680);

            FontMan.Add(Font.Name.HiScore, SpriteBatch.Name.InGameScreen, "<HiScore>", Glyph.Name.Consolas36pt, 230, 720);
            FontMan.Add(Font.Name.HiPoints, SpriteBatch.Name.InGameScreen, "0", Glyph.Name.Consolas36pt, 250, 680);

            FontMan.Add(Font.Name.ScoreP2, SpriteBatch.Name.InGameScreen, "<P2 Score>", Glyph.Name.Consolas36pt, 425, 720);
            FontMan.Add(Font.Name.LivesP2, SpriteBatch.Name.InGameScreen, "P2 Lives:", Glyph.Name.Consolas36pt, 400, 20);
            FontMan.Add(Font.Name.P2Points, SpriteBatch.Name.InGameScreen, "0", Glyph.Name.Consolas36pt, 400, 680);

            FontMan.Add(Font.Name.GameOver, SpriteBatch.Name.GameOver, "Game, Set and Match", Glyph.Name.Consolas36pt, 100, 450);
            FontMan.Add(Font.Name.Credits, SpriteBatch.Name.GameOver, "Created By: James Corcoran", Glyph.Name.Consolas36pt, 100, 350);
            FontMan.Add(Font.Name.Thankyou, SpriteBatch.Name.GameOver, "Thanks for Playing!!!", Glyph.Name.Consolas36pt, 100, 250);

            //----------------------------------------------------------------------
            //Missile
            //----------------------------------------------------------------------

            MissileGroup pMissileGroup = new MissileGroup(GameObject.Name.MissileGroup, GameSprite.Name.NullObject, 0, 0.0f, 0.0f);

            pMissileGroup.ActivateGameSprite(pSB_Projectiles);
            pMissileGroup.ActivateCollisionSprite(pSB_Boxes);

            GONodeMan.Attach(pMissileGroup);


            Debug.WriteLine("-------------------");
            pMissileGroup.Print();

            //----------------------------------------------------------------------
            //Ship
            //----------------------------------------------------------------------

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

            GONodeMan.Attach(pShipRoot);

            Debug.WriteLine("-------------------");
            pShipRoot.Print();

            //----------------------------------------------------------------------
            //UFO
            //----------------------------------------------------------------------

            UFORoot pUFORoot = new UFORoot(GameObject.Name.UFORoot, GameSprite.Name.NullObject, 0.0f, 0.0f);

            GONodeMan.Attach(pUFORoot);

            Debug.WriteLine("-------------------");
            pUFORoot.Print();

            //---------------------------------------------------------------------------------------------------------
            // Bomb
            //---------------------------------------------------------------------------------------------------------

            BombRoot pBombRoot = new BombRoot(GameObject.Name.BombRoot, GameSprite.Name.NullObject, -100.0f, -100.0f);

            GONodeMan.Attach(pBombRoot);

            Debug.WriteLine("-------------------");
            pBombRoot.Print();

            //---------------------------------------------------------------------
            //Wall Creation
            //---------------------------------------------------------------------

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

            GONodeMan.Attach(pTWallRoot);

            TopWall pTWall = new TopWall(GameObject.Name.TopWall, GameSprite.Name.NullObject, 336, 748, 600, 40);

            pTWall.ActivateCollisionSprite(pSB_Boxes);
            pTWallRoot.Add(pTWall);

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

            GONodeMan.Attach(pLWallRoot);

            LeftWall pLWall = new LeftWall(GameObject.Name.LeftWall, GameSprite.Name.NullObject, 20, 384, 40, 700);

            pLWall.ActivateCollisionSprite(pSB_Boxes);
            pLWallRoot.Add(pLWall);

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

            GONodeMan.Attach(pRWallRoot);

            RightWall pRWall = new RightWall(GameObject.Name.RightWall, GameSprite.Name.NullObject, 653, 384, 40, 700);

            pRWall.ActivateCollisionSprite(pSB_Boxes);
            pRWallRoot.Add(pRWall);

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

            GONodeMan.Attach(pBWallRoot);

            BottomWall pBWall = new BottomWall(GameObject.Name.BottomWall, GameSprite.Name.NullObject, 336, 20, 700, 40);

            pBWall.ActivateCollisionSprite(pSB_Boxes);
            pBWallRoot.Add(pBWall);

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

            //---------------------------------------------------------------------
            //AlienRoot(Group) and ShieldRoot
            //---------------------------------------------------------------------

            Composite pAlienGroup = new AlienGroup(GameObject.Name.AlienGrid, GameSprite.Name.NullObject, 0.0f, 0.0f);

            pAlienGroup.ActivateCollisionSprite(pSB_Boxes);
            GONodeMan.Attach(pAlienGroup);


            Composite pShieldRoot = new ShieldRoot(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, 0.0f, 0.0f);

            GONodeMan.Attach(pShieldRoot);


            //Composite pSplatRoot = new SplatRoot(GameObject.Name.SplatRoot, GameSprite.Name.NullObject, 0.0f, 0.0f);
            //GONodeMan.Attach(pSplatRoot);

            //--------------------------------------------------------------------------
            // Collision Pair
            //--------------------------------------------------------------------------

            ColPair pGrid_V_LWall = ColPairMan.Add(ColPair.Name.Aliens_V_LWall, pAlienGroup, pLWallRoot);

            Debug.Assert(pGrid_V_LWall != null);
            pGrid_V_LWall.Attach(new GridObserver());

            ColPair pGrid_V_RWall = ColPairMan.Add(ColPair.Name.Aliens_V_RWall, pAlienGroup, pRWallRoot);

            Debug.Assert(pGrid_V_RWall != null);
            pGrid_V_RWall.Attach(new GridObserver());

            ColPair pGrid_V_BWall = ColPairMan.Add(ColPair.Name.Aliens_V_BWall, pAlienGroup, pBWallRoot);

            Debug.Assert(pGrid_V_BWall != null);
            pGrid_V_BWall.Attach(new GridObserver());

            ColPair pMissile_V_Alien = ColPairMan.Add(ColPair.Name.Missile_V_Alien, pMissileGroup, pAlienGroup);

            Debug.Assert(pMissile_V_Alien != null);
            pMissile_V_Alien.Attach(new SplatObserver());
            pMissile_V_Alien.Attach(new RemoveAlienObserver());
            pMissile_V_Alien.Attach(new RemoveMissileObserver());
            pMissile_V_Alien.Attach(new ShipReadyObserver());
            pMissile_V_Alien.Attach(new SndObserver(pSndEngine, "invaderkilled.wav"));


            ColPair pAlien_V_Shield = ColPairMan.Add(ColPair.Name.Aliens_V_Shield, pAlienGroup, pShieldRoot);

            Debug.Assert(pAlien_V_Shield != null);
            pAlien_V_Shield.Attach(new RemoveBrickObserver());
            //pAlien_V_Shield.Attach(new SndObserver(pSndEngine, "explosion.wav"));

            ColPair pAlien_V_Ship = ColPairMan.Add(ColPair.Name.Aliens_V_Ship, pAlienGroup, pShipRoot);

            Debug.Assert(pAlien_V_Ship != null);
            pAlien_V_Ship.Attach(new SplatShipObserver());
            pAlien_V_Ship.Attach(new HitShipObserver());
            pAlien_V_Ship.Attach(new SndObserver(pSndEngine, "explosion.wav"));
            pAlien_V_Ship.Attach(new P1GameOverObs());

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

            ColPair pCollide_UFO_RWall = ColPairMan.Add(ColPair.Name.UFO_V_RWall, pUFORoot, pRWallRoot);

            Debug.Assert(pCollide_UFO_RWall != null);
            pCollide_UFO_RWall.Attach(new MissedUFOobserver());
            pCollide_UFO_RWall.Attach(new RemoveSndUFO());

            ColPair pCollide_UFO_LWall = ColPairMan.Add(ColPair.Name.UFO_V_LWall, pUFORoot, pLWallRoot);

            Debug.Assert(pCollide_UFO_LWall != null);
            pCollide_UFO_LWall.Attach(new MissedUFOobserver());
            pCollide_UFO_LWall.Attach(new RemoveSndUFO());

            ColPair pCollide_Missile_V_UFO = ColPairMan.Add(ColPair.Name.Missile_V_UFO, pMissileGroup, pUFORoot);

            Debug.Assert(pCollide_Missile_V_UFO != null);
            pCollide_Missile_V_UFO.Attach(new RemoveMissileObserver());
            pCollide_Missile_V_UFO.Attach(new RemoveUFOobserver());
            pCollide_Missile_V_UFO.Attach(new ShipReadyObserver());
            pCollide_Missile_V_UFO.Attach(new UFOSplatObs());
            pCollide_Missile_V_UFO.Attach(new SndObserver(pSndEngine, "invaderkilled.wav"));
            pCollide_Missile_V_UFO.Attach(new RemoveSndUFO());

            //-----------------------------------------------------------------------------------------------------------------
            ColPair pMissile_V_TWall = ColPairMan.Add(ColPair.Name.Missile_V_TWall, pMissileGroup, pTWallRoot);

            Debug.Assert(pMissile_V_TWall != null);
            pMissile_V_TWall.Attach(new ShipReadyObserver());
            pMissile_V_TWall.Attach(new RemoveMissileObserver());

            ColPair pBomb_V_Wall = ColPairMan.Add(ColPair.Name.Bomb_V_Wall, pBombRoot, pBWallRoot);

            Debug.Assert(pBomb_V_Wall != null);
            pBomb_V_Wall.Attach(new BombObserver());

            ColPair pMissile_V_Shield = ColPairMan.Add(ColPair.Name.Missile_V_Shield, pMissileGroup, pShieldRoot);

            Debug.Assert(pMissile_V_Shield != null);
            pMissile_V_Shield.Attach(new RemoveBrickObserver());
            pMissile_V_Shield.Attach(new RemoveMissileObserver());
            pMissile_V_Shield.Attach(new ShipReadyObserver());
            pMissile_V_Shield.Attach(new SndObserver(pSndEngine, "explosion.wav"));

            ColPair pBomb_V_Shield = ColPairMan.Add(ColPair.Name.Bomb_V_Shield, pBombRoot, pShieldRoot);

            Debug.Assert(pBomb_V_Shield != null);
            pBomb_V_Shield.Attach(new RemoveBrickObserver());
            pBomb_V_Shield.Attach(new BombObserver());
            pBomb_V_Shield.Attach(new SndObserver(pSndEngine, "explosion.wav"));

            ColPair pBomb_V_Ship = ColPairMan.Add(ColPair.Name.Ship_V_Bomb, pBombRoot, pShipRoot);

            Debug.Assert(pBomb_V_Ship != null);
            pBomb_V_Ship.Attach(new SplatShipObserver());
            pBomb_V_Ship.Attach(new BombObserver());
            pBomb_V_Ship.Attach(new HitShipObserver());
            pBomb_V_Ship.Attach(new SndObserver(pSndEngine, "explosion.wav"));
            pBomb_V_Ship.Attach(new P1GameOverObs());


            ColPair pBomb_V_Missile = ColPairMan.Add(ColPair.Name.Bomb_V_Missile, pBombRoot, pMissileGroup);

            Debug.Assert(pBomb_V_Missile != null);
            pBomb_V_Missile.Attach(new BombSplatObs());
            pBomb_V_Missile.Attach(new BombMissileObserver());
            pBomb_V_Missile.Attach(new SndObserver(pSndEngine, "explosion.wav"));
            pBomb_V_Missile.Attach(new ShipReadyObserver());
            //------------------------------------------------------------------------------------------------------------------

            ColPair pShip_V_LWall = ColPairMan.Add(ColPair.Name.Ship_V_LWall, pShipRoot, pLWallRoot);

            Debug.Assert(pShip_V_LWall != null);
            pShip_V_LWall.Attach(new ShipMovementObserver());

            ColPair pShip_V_RWall = ColPairMan.Add(ColPair.Name.Ship_V_RWall, pShipRoot, pRWallRoot);

            Debug.Assert(pShip_V_RWall != null);
            pShip_V_RWall.Attach(new ShipMovementObserver());

            //----------------------------------------------------------------------------------------------------------
            //Animate Sprites and Movement Commands
            //----------------------------------------------------------------------------------------------------------

            //Tests on my Animation Manager
            AnimateCrab pAnimS1 = new AnimateCrab(Animation.Name.AnimateCrab, GameSprite.Name.Crab);

            pAnimS1.Attach(Image.Name.CrabD);
            pAnimS1.Attach(Image.Name.CrabU);

            AnimateSquid pAnimS2 = new AnimateSquid(Animation.Name.AnimateSquid, GameSprite.Name.Squid);

            pAnimS2.Attach(Image.Name.SquidD);
            pAnimS2.Attach(Image.Name.SquidU);

            AnimateOcto pAnimS3 = new AnimateOcto(Animation.Name.AnimateOcto, GameSprite.Name.Octopus);

            pAnimS3.Attach(Image.Name.OctopusD);
            pAnimS3.Attach(Image.Name.OctopusU);

            AnimMan.Attach(pAnimS1);
            AnimMan.Attach(pAnimS2);
            AnimMan.Attach(pAnimS3);

            //---------------------------------------------------------------------------------------------------------
            //Add Input
            //---------------------------------------------------------------------------------------------------------
            InputSubject pInputSubject;

            pInputSubject = InputManager.GetArrowRightSubject();
            pInputSubject.Attach(new MoveRightObserver());

            pInputSubject = InputManager.GetArrowLeftSubject();
            pInputSubject.Attach(new MoveLeftObserver());

            pInputSubject = InputManager.GetSpaceBarSubject();
            pInputSubject.Attach(new ShootObserver());

            //first player
            pInputSubject = InputManager.Get1keySubject();
            pInputSubject.Attach(new Player1Observer());

            //add second player observer
            pInputSubject = InputManager.Get2keySubject();
            pInputSubject.Attach(new Player2Observer());


            pInputSubject = InputManager.GetCkeySubject();
            pInputSubject.Attach(new ToggleColObserver());


            //Simulator
            //I am testing because i think we will need to pause the game
            //for the timer manager and the lives for the ship
            Simulation.SetState(Simulation.State.RealTime);
        }
示例#26
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;
            }
        }
示例#27
0
        //need to create the root node first before using
        public static void ShieldCreator(float startX, float startY, GameObject.Name shieldName)
        {
            Composite pShieldRoot = (Composite)GONodeMan.Find(GameObject.Name.ShieldRoot);

            Debug.Assert(pShieldRoot != null);

            ShieldFactory SF = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.Boxes, pShieldRoot);

            GameObject pShieldGrid;

            SF.SetParent(pShieldRoot);
            pShieldGrid = SF.Create(ShieldCategory.Type.Grid, shieldName);

            //j represents the columns
            int j = 0;

            GameObject pShieldColumn;

            SF.SetParent(pShieldGrid);
            pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_1 + j++);

            SF.SetParent(pShieldColumn);

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


            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 2 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 3 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 4 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 5 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 6 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 7 * brickHeight);
            SF.Create(ShieldCategory.Type.LeftTop2, GameObject.Name.ShieldBrick, start_x, start_y + 8 * brickHeight);
            SF.Create(ShieldCategory.Type.LeftTop1, GameObject.Name.ShieldBrick, start_x, start_y + 9 * brickHeight);

            SF.SetParent(pShieldGrid);
            pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_1 + j++);

            SF.SetParent(pShieldColumn);

            off_x += brickWidth;
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

            SF.SetParent(pShieldGrid);
            pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_1 + j++);

            SF.SetParent(pShieldColumn);

            off_x += brickWidth;
            SF.Create(ShieldCategory.Type.LeftBottom, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

            SF.SetParent(pShieldGrid);
            pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_1 + j++);

            SF.SetParent(pShieldColumn);

            off_x += brickWidth;
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

            SF.SetParent(pShieldGrid);
            pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_1 + j++);

            SF.SetParent(pShieldColumn);

            off_x += brickWidth;
            SF.Create(ShieldCategory.Type.RightBottom, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

            SF.SetParent(pShieldGrid);
            pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_1 + j++);

            SF.SetParent(pShieldColumn);

            off_x += brickWidth;
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

            SF.SetParent(pShieldGrid);
            pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_1 + j++);

            SF.SetParent(pShieldColumn);

            off_x += brickWidth;
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
            SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
            SF.Create(ShieldCategory.Type.RightTop2, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
            SF.Create(ShieldCategory.Type.RightTop1, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);
        }