Ejemplo n.º 1
0
        public virtual void Remove(SpriteBatch.Name gameObjSpriteBatch, SpriteBatch.Name collisionBoxSpriteBatch)
        {
            // Very difficult at first... if you are messy, you will pay here!
            // Given a game object....

            // Since the Root object is being drawn
            // 1st set its size to zero
            this.pCollisionObject.GetCollisionRect().Set(0, 0, 0, 0);
            this.Update();

            // Update the parent
            GameObject pParent = (GameObject)this.pParent;

            if (pParent != null)
            {
                pParent.Update();
            }

            // Remove from SpriteBatch
            GameStateManager.GetGame().GetStateSpriteBatchManager().Find(gameObjSpriteBatch).Detach(pSpriteProxy);
            GameStateManager.GetGame().GetStateSpriteBatchManager().Find(collisionBoxSpriteBatch).Detach(pCollisionObject.GetCollisionSpriteBox());

            // Remove from GameObjectManager
            GameStateManager.GetGame().GetStateGameObjectManager().Detach(this);

            // Attach to GhostManager for later use
            GameStateManager.GetGame().GetStateGhostManager().Attach(this);

            // Reset death flag
            this.markedForDeath = false;
        }
Ejemplo n.º 2
0
        //----------------------------------------------------------------------
        // Methods
        //----------------------------------------------------------------------
        public void Destroy()
        {
            this.BaseDestroy();

            this.name = SpriteBatch.Name.Uninitialized;
            this.pSpriteBaseRefCompare = null;
        }
Ejemplo n.º 3
0
        public static SpriteBatch Add(SpriteBatch.Name name, int _key, bool _bRenderEnabled, int _mNumReserved = 5, int _nGrowthSize = 2)
        {
            SpriteBatch head  = (SpriteBatch)SpriteBatchMan.pActiveSBMan.pActive;
            SpriteBatch batch = null;

            if (head == null)
            {
                batch = (SpriteBatch)SpriteBatchMan.pActiveSBMan.baseAdd();
            }
            else
            {
                while (head != null)
                {
                    if (head.key <= _key)
                    {
                        DLink dHead = head;
                        batch = (SpriteBatch)SpriteBatchMan.pActiveSBMan.AddBefore(ref dHead);
                        break;
                    }

                    if (head.pNext == null)
                    {
                        DLink dHead = head;
                        batch = (SpriteBatch)SpriteBatchMan.pActiveSBMan.AddAfter(ref dHead);
                        break;
                    }
                    head = (SpriteBatch)head.pNext;
                }
            }
            batch.Initialize(name, _key, _bRenderEnabled, _mNumReserved, _nGrowthSize);
            return(batch);
        }
Ejemplo n.º 4
0
        public static void ActivateGrid(InvaderGrid pGrid, SpriteBatch.Name spriteBatchName, SpriteBatch.Name boxSpriteBatchName)
        {
            Debug.Assert(pGrid != null);
            GameObjectManager.Attach(pGrid);

            SpriteBatch pSpriteBatch = SpriteBatchManager.Find(spriteBatchName);

            Debug.Assert(pSpriteBatch != null);

            SpriteBatch pBoxSpriteBatch = SpriteBatchManager.Find(boxSpriteBatchName);

            Debug.Assert(pBoxSpriteBatch != null);

            pBoxSpriteBatch.Attach(pGrid.poColObj.pColSprite);
            pSpriteBatch.Attach(pGrid.pProxySprite);

            ForwardIterator pFwdItor = new ForwardIterator(pGrid);

            GameObject pGameObj = (GameObject)pFwdItor.Next();

            while (!pFwdItor.IsDone())
            {
                GameObjectManager.Attach(pGameObj);

                pBoxSpriteBatch.Attach(pGameObj.poColObj.pColSprite);
                pSpriteBatch.Attach(pGameObj.pProxySprite);

                pGameObj = (GameObject)pFwdItor.Next();
            }
        }
Ejemplo n.º 5
0
        public static SpriteBatch Find(SpriteBatch.Name name)
        {
            SpriteBatchMan.pNodeCompare.SetName(name);
            SpriteBatch sprite = (SpriteBatch)SpriteBatchMan.pActiveSBMan.baseFind(SpriteBatchMan.pNodeCompare);

            return(sprite);
        }
Ejemplo n.º 6
0
 public SpriteBatch Wash()
 {
     this.name               = Name.Uninitialized;
     this.priority           = 0;
     this.poBatchNodeManager = new SpriteBatchNodeManager();
     return(this);
 }
Ejemplo n.º 7
0
 public SpriteBatch()
 {
     this.name        = SpriteBatch.Name.Uninitialized;
     this.poSBNodeMan = new SpriteBaseNodeManager();
     Debug.Assert(this.poSBNodeMan != null);
     this.enabled = true;
 }
        ///////////////////////////////////////////////////////
        //
        // Methods
        //
        ///////////////////////////////////////////////////////

        /// <summary>
        ///		Initialize a sprite batch of the given name
        /// </summary>
        /// <param name="newName"></param>
        /// <returns></returns>
        public SpriteBatch Create(SpriteBatch.Name newName)
        {
            SpriteBatch newBatch = this.BaseCreate() as SpriteBatch;

            newBatch.SetName(newName);
            return(newBatch);
        }
Ejemplo n.º 9
0
        /// <summary>
        ///		Changes the sprite reference
        /// </summary>
        /// <param name="newSprite"></param>
        public void SetSprite(SpriteBatch.Name newBatchName, SpriteEntity newSprite)
        {
            // Remove the old sprite from it's sprite batch
            SpriteBatch oldBatch = SpriteBatchManager.Active.Find(this.batchName);

            if (oldBatch != null)
            {
                bool su = oldBatch.Detach(this.sprite.SpriteName, this.sprite.Id);
                Debug.Assert(su, "The old SpriteBatch has to detach a valid (non-null) sprite.");
            }

            // Recycle old sprite
            SpriteProxyManager.Active.Recycle(this.sprite.SpriteName, this.sprite.Id);
            this.sprite = null;

            // Get new batch
            SpriteBatch newBatch = SpriteBatchManager.Active.Find(newBatchName);

            this.batchName = newBatchName;

            // If null, get null proxy and leave
            if (newBatch == null)
            {
                this.sprite = SpriteProxyManager.Active.NullSpriteProxy;
                return;                 // Leave
            }

            // Get new sprite and attach it
            this.sprite = SpriteProxyManager.Active.Create(newSprite.SpriteName, this.Id);
            newBatch.Attach(this.sprite, this.sprite.Id);

            this.collider.SetupCollisonSpriteProxy(this.sprite);
        }
Ejemplo n.º 10
0
        public static void SetPriority(SpriteBatch.Name group, int key)
        {
            SpriteBatchMan.pNodeCompare.SetName(group);
            SpriteBatch node = (SpriteBatch)SpriteBatchMan.pActiveSBMan.baseFind(SpriteBatchMan.pNodeCompare);

            node.SetPriority(key);
            SpriteBatchMan.pActiveSBMan.PrioritySort();
        }
Ejemplo n.º 11
0
        public AlienFactory(SpriteBatch.Name spriteBatchName, SpriteBatch.Name boxSpriteBatchName)
        {
            this.pSpriteBatch = SpriteBatchMan.Find(spriteBatchName);
            Debug.Assert(this.pSpriteBatch != null);

            this.pBoxSpriteBatch = SpriteBatchMan.Find(boxSpriteBatchName);
            Debug.Assert(this.pBoxSpriteBatch != null);
        }
Ejemplo n.º 12
0
        public ShieldFactory(SpriteBatch.Name spriteBatchName, SpriteBatch.Name collisionSpriteBatch)
        {
            this.pSpriteBatch = SpriteBatchMan.Find(spriteBatchName);
            Debug.Assert(this.pSpriteBatch != null);

            this.pCollisionSpriteBatch = SpriteBatchMan.Find(collisionSpriteBatch);
            Debug.Assert(this.pCollisionSpriteBatch != null);
        }
Ejemplo n.º 13
0
        public void Destroy()
        {
            this.BaseDestroy();

            this.name             = SpriteBatch.Name.Unitialized;
            this.poNodeCompare    = null;
            this.pBackSpriteBatch = null;
        }
Ejemplo n.º 14
0
        public AliensFactory(SpriteBatch.Name spriteBatchName)
        {
            this.pSpriteBatch = SpriteBatchMan.Find(spriteBatchName);
            Debug.Assert(this.pSpriteBatch != null);

            this.pBoxBatch = SpriteBatchMan.Find(SpriteBatch.Name.Batch_Boxes);
            Debug.Assert(this.pBoxBatch != null);
        }
Ejemplo n.º 15
0
 public void Initialize(SpriteBatch.Name _name, int _key, bool _bRenderEnabled, int _mNumReserved = 5, int _nGrowthSize = 2)
 {
     this.name           = _name;
     this.key            = _key;
     this.bRenderEnabled = _bRenderEnabled;
     this.pSpriteNodeMan = new SpriteNodeMan();
     this.pSpriteNodeMan.Initialize(_mNumReserved, _nGrowthSize);
 }
Ejemplo n.º 16
0
        public void Set(SpriteBatch.Name name, int reserveNum, int reserveGrow)
        {
            this.name = name;
            Debug.Assert(reserveNum > 0);
            Debug.Assert(reserveGrow > 0);

            this.BaseSetReserve(reserveNum, reserveGrow);
        }
Ejemplo n.º 17
0
 public SpriteBatch()
     : base()
 {
     this.name       = SpriteBatch.Name.Uninitialized;
     this.pSBNodeMan = new SBNodeMan();
     Debug.Assert(this.pSBNodeMan != null);
     this.isDraw = true;
 }
 /// <summary>
 ///		Finds a sprite batch by name and returns it
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public SpriteBatch Find(SpriteBatch.Name name)
 {
     if (name == SpriteBatch.Name.UNINITIALIZED)
     {
         return(null);
     }
     return(this.BaseFind(name, this.activeList) as SpriteBatch);
 }
        public SpriteBatch()
            : base()
        {
            this.name = SpriteBatch.Name.Uninitialized;
            this.pSpriteNodeManager = new SpriteNodeManager();
            Debug.Assert(this.pSpriteNodeManager != null);

            this.bDraw = true;
        }
Ejemplo n.º 20
0
        public SpriteBatch Find(SpriteBatch.Name name)
        {
            // Use compare node to compare to search nodes
            this.poNodeCompare.SetName(name);

            SpriteBatch pData = (SpriteBatch)BaseFind(poNodeCompare);

            return(pData);
        }
Ejemplo n.º 21
0
        public SpriteBatch Add(SpriteBatch.Name name, int reserveNum = 3, int reserveGrow = 1)
        {
            SpriteBatch pNode = (SpriteBatch)BaseAdd();

            Debug.Assert(pNode != null);

            pNode.Set(name, reserveNum, reserveGrow);
            return(pNode);
        }
Ejemplo n.º 22
0
        public void Set(SpriteBatch.Name name, int numNodes, int growthSize)
        {
            this.name = name;

            Debug.Assert(numNodes > 0);
            Debug.Assert(growthSize > 0);

            this.BaseSetReserve(numNodes, growthSize);
        }
Ejemplo n.º 23
0
 public void Set(SpriteBatch.Name name, int reserveNum = 3, int reserveGrow = 1)
 {
     this.name = name;
     this.pSBNodeMan.Set(name, reserveNum, reserveGrow);
     if (this.name == SpriteBatch.Name.Boxes)
     {
         this.isDraw = false;
     }
 }
Ejemplo n.º 24
0
        public ShieldFactory(SpriteBatch.Name spriteBatchName, SpriteBatch.Name collisionSpriteBatch, GameObject.Name shieldRootName)
        {
            this.pSpriteBatch = SpriteBatchMan.Find(spriteBatchName);
            Debug.Assert(this.pSpriteBatch != null);

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

            this.pTree = (Composite) new ShieldRoot(shieldRootName, GameSprite.Name.NullObject, 0.0f, 0.0f);
        }
Ejemplo n.º 25
0
        //----------------------------------------------------------------------
        // Methods
        //----------------------------------------------------------------------
        public void set(SpriteBatch.Name name, int reserveNum, int growNum)
        {
            this.name = name;

            // ensure reserveNum and growNum are reasonable
            Debug.Assert(reserveNum >= 0);
            Debug.Assert(growNum > 0);

            this.BaseSetReservedList(reserveNum, growNum);
        }
Ejemplo n.º 26
0
        public SpriteBatch()
            : base()
        {
            this.name = SpriteBatch.Name.Unitialized;

            // this is why SBNode manager cant be a singleton
            this.poSBNodeMan = new SBNodeMan();
            Debug.Assert(this.poSBNodeMan != null);
            this.bToggle = true;
        }
Ejemplo n.º 27
0
        public ShieldFactory(SpriteBatch.Name spriteBatchName, SpriteBatch.Name collisionSpriteBatch, Composite pRoot)
        {
            this.pSpriteBatch = SpriteBatchManager.Find(spriteBatchName);
            Debug.Assert(this.pSpriteBatch != null);

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

            this.pTree = pRoot;
        }
Ejemplo n.º 28
0
        public AlienFactory(SpriteBatch.Name spriteBatchName, SpriteBatch.Name colSpriteBatchName, Composite pTree)
        {
            this.pSpriteBatch = SpriteBatchMan.Find(spriteBatchName);
            Debug.Assert(this.pSpriteBatch != null);

            this.pColSpriteBatch = SpriteBatchMan.Find(colSpriteBatchName);
            Debug.Assert(this.pColSpriteBatch != null);

            Debug.Assert(pTree != null);
            this.pTree = pTree;
        }
        /// <summary>
        ///		Convenience method to add a sprite to a sprite batch.
        ///		The batch has to actually exist for this to work!
        /// </summary>
        /// <param name="batchName"></param>
        /// <param name="newSprite"></param>
        /// <returns></returns>
        public bool Attach(SpriteBatch.Name batchName, Sprite newSprite)
        {
            SpriteBatch batch = this.Find(batchName) as SpriteBatch;

            if (batch == null)
            {
                return(false);
            }
            batch.Attach(newSprite, newSprite.Id);
            return(true);
        }
Ejemplo n.º 30
0
        public ShieldFactory(SpriteBatch.Name spriteBatchName, SpriteBatch.Name collisionSpriteBatch, PCSTree pTree)
        {
            this.pSpriteBatch = SpriteBatchManager.Find(spriteBatchName);
            Debug.Assert(this.pSpriteBatch != null);

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

            Debug.Assert(pTree != null);
            this.pTree = pTree;
        }