예제 #1
0
        public static Missile ActivateMissile()
        {
            ShipMan pShipMan = ShipMan.PrivInstance();

            Debug.Assert(pShipMan != null);

            // copy over safe copy
            // TODO: This can be cleaned up more... no need to re-calling new()
            Missile pMissile = new Missile(GameObject.Name.Missile, GameSprite.Name.Missile, 400, 100);

            pShipMan.pMissile = pMissile;

            // Attached to SpriteBatches
            SpriteNodeBatch pSB_Player = SpriteNodeBatchManager.Find(SpriteNodeBatch.Name.Players);
            SpriteNodeBatch pSB_Boxes  = SpriteNodeBatchManager.Find(SpriteNodeBatch.Name.Boxes);

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

            // Attach the missile to the missile root
            GameObject pMissileGroup = GameObjectManager.Find(GameObject.Name.MissileGroup);

            Debug.Assert(pMissileGroup != null);

            // Add to GameObject Tree - {update and collisions}
            pMissileGroup.Add(pShipMan.pMissile);

            return(pShipMan.pMissile);
        }
예제 #2
0
        private static Ship ActivateShip()
        {
            ShipMan pShipMan = ShipMan.PrivInstance();

            Debug.Assert(pShipMan != null);

            // copy over safe copy
            Ship pShip = new Ship(GameObject.Name.Ship, GameSprite.Name.Ship, 400, 120);

            pShipMan.pShip = pShip;

            // Attach the sprite to the correct sprite batch
            SpriteNodeBatch pSB_Player = SpriteNodeBatchManager.Find(SpriteNodeBatch.Name.Players);

            pSB_Player.Attach(pShip.pProxySprite);

            // Attach the missile to the missile root
            GameObject pShipRoot = GameObjectManager.Find(GameObject.Name.ShipRoot);

            Debug.Assert(pShipRoot != null);

            // Add to GameObject Tree - {update and collisions}
            pShipRoot.Add(pShipMan.pShip);

            return(pShipMan.pShip);
        }
예제 #3
0
        public void RemoveExplosion()
        {
            SpriteNodeBatch pBatch = SpriteNodeBatchManager.Find(SpriteNodeBatch.Name.Explosions);

            pBatch.Detach(this.pProxySprite);

            // If I have the back pointer I don't need to search for it.
        }
예제 #4
0
        //----------------------------------------------------------------------------------
        // Constructor
        //----------------------------------------------------------------------------------
        public WallFactory(SpriteNodeBatch.Name spriteBatchName, SpriteNodeBatch.Name boxSpriteBatchName)
        {
            this.pSpriteBatch = SpriteNodeBatchManager.Find(spriteBatchName);
            Debug.Assert(this.pSpriteBatch != null);

            this.pCollisionSpriteBatch = SpriteNodeBatchManager.Find(boxSpriteBatchName);
            Debug.Assert(this.pCollisionSpriteBatch != null);
        }
예제 #5
0
        public void AddExplosion()
        {
            // Find the correct Batch
            SpriteNodeBatch pBatch = SpriteNodeBatchManager.Find(SpriteNodeBatch.Name.Explosions);

            //Delegate to batches attach which calls its own SpriteNodeManager's Attach
            // Inside the SpriteNodeManager's Attach is where the back pointer is set.
            pBatch.Attach(this.pProxySprite);
        }
예제 #6
0
        //----------------------------------------------------------------------------------
        // Constructor
        //----------------------------------------------------------------------------------
        public ShieldFactory(SpriteNodeBatch.Name spriteBatchName, SpriteNodeBatch.Name collisionSpriteBatch, GameObject pTree)
        {
            this.pSpriteBatch = SpriteNodeBatchManager.Find(spriteBatchName);
            Debug.Assert(this.pSpriteBatch != null);

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

            Debug.Assert(pTree != null);
            this.pTree = pTree;
        }
예제 #7
0
        //SpriteNode pBackPointer;

        public ExplosionSprite(GameSprite.Name spriteName, float px, float py) : base()
        {
            // finds the ProxySprite and returns a reference to it.
            // the sprite base of the proxy sprite has a back pointer to its spritenode
            this.pProxySprite = ProxySpriteManager.Add(spriteName);

            this.pProxySprite.SetCoordinates(px, py);
            this.pProxySprite.Update();

            this.pExplosionBatch = SpriteNodeBatchManager.Find(SpriteNodeBatch.Name.Explosions);
        }
        //----------------------------------------------------------------------------------
        // Constructor
        //----------------------------------------------------------------------------------
        public ExplosionSpriteFactory(SpriteNodeBatch.Name spriteBatchName)
        {
            this.pSpriteBatch = SpriteNodeBatchManager.Find(spriteBatchName);
            Debug.Assert(this.pSpriteBatch != null);

            // Loading the list for recycling
            this.Create(GameSprite.Name.AlienExplosion);
            this.Create(GameSprite.Name.MissileExplosion);
            this.Create(GameSprite.Name.BombExplosion);
            this.ExplosionSpriteCreationCount = 3;
        }
예제 #9
0
        //----------------------------------------------------------------------------------
        // Constructor
        //----------------------------------------------------------------------------------
        public MissileSpawnEvent(Random pRandom)
        {
            this.pMissileRoot = GameObjectManager.Find(GameObject.Name.MissileGroup);
            Debug.Assert(this.pMissileRoot != null);

            this.pSB_Invaders = SpriteNodeBatchManager.Find(SpriteNodeBatch.Name.TheSwarm);
            Debug.Assert(this.pSB_Invaders != null);

            this.pSB_Boxes = SpriteNodeBatchManager.Find(SpriteNodeBatch.Name.Boxes);
            Debug.Assert(this.pSB_Boxes != null);

            this.pRandom = pRandom;
        }
예제 #10
0
        //----------------------------------------------------------------------------------
        // Constructor
        //----------------------------------------------------------------------------------
        public DropBomb(float px, float py)
        {
            this.x = px;
            this.y = py;

            this.pBombRoot = GameObjectManager.Find(GameObject.Name.BombRoot);
            Debug.Assert(this.pBombRoot != null);

            this.pSB_Invaders = SpriteNodeBatchManager.Find(SpriteNodeBatch.Name.TheSwarm);
            Debug.Assert(this.pSB_Invaders != null);

            this.pSB_Boxes = SpriteNodeBatchManager.Find(SpriteNodeBatch.Name.Boxes);
            Debug.Assert(this.pSB_Boxes != null);

            GameObject pGrid = GameObjectManager.Find(GameObject.Name.AlienGrid);

            hash = pGrid.GetHashCode();
        }
예제 #11
0
        //----------------------------------------------------------------------------------
        // Constructor
        //----------------------------------------------------------------------------------
        public ExplosionFactory(SpriteNodeBatch.Name spriteBatchName, SpriteNodeBatch.Name boxSpriteBatchName)
        {
            this.pSpriteBatch = SpriteNodeBatchManager.Find(spriteBatchName);
            Debug.Assert(this.pSpriteBatch != null);

            this.pCollisionSpriteBatch = SpriteNodeBatchManager.Find(boxSpriteBatchName);
            Debug.Assert(this.pCollisionSpriteBatch != null);


            // For managing / recycling the created Explosions
            this.pManager = new ExplosionManager(this, 3, 1);


            // Create at least on of each Explosion type
            // Should be in active
            this.Create(GameObject.Name.AlienExplosion, -100.0f, -100.0f);
            this.Create(GameObject.Name.MissileExplosion, -100.0f, -100.0f);
            this.Create(GameObject.Name.BombExplosion, -100.0f, -100.0f);
        }
예제 #12
0
        public static Font Add(Font.Name fontName, SpriteNodeBatch.Name SpriteBatch_Name, String pMessage, Glyph.Name glyphName, float px, float py)
        {
            FontManager pManager = FontManager.privGetInstance();

            Font pNode = (Font)pManager.baseAdd();

            Debug.Assert(pNode != null);

            pNode.Set(fontName, pMessage, glyphName, px, py);

            // Add to sprite batch
            SpriteNodeBatch pSriteBatch = SpriteNodeBatchManager.Find(SpriteBatch_Name);

            Debug.Assert(pSriteBatch != null);
            Debug.Assert(pNode.pFontSprite != null);
            pSriteBatch.Attach(pNode.pFontSprite);

            return(pNode);
        }
 //----------------------------------------------------------------------------------
 // Constructor
 //----------------------------------------------------------------------------------
 public RenderCollisionBoxesObserver()
 {
     this.pBatchHolder = SpriteNodeBatchManager.Find(SpriteNodeBatch.Name.Boxes);
 }