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; }
//---------------------------------------------------------------------- // Methods //---------------------------------------------------------------------- public void Destroy() { this.BaseDestroy(); this.name = SpriteBatch.Name.Uninitialized; this.pSpriteBaseRefCompare = null; }
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); }
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(); } }
public static SpriteBatch Find(SpriteBatch.Name name) { SpriteBatchMan.pNodeCompare.SetName(name); SpriteBatch sprite = (SpriteBatch)SpriteBatchMan.pActiveSBMan.baseFind(SpriteBatchMan.pNodeCompare); return(sprite); }
public SpriteBatch Wash() { this.name = Name.Uninitialized; this.priority = 0; this.poBatchNodeManager = new SpriteBatchNodeManager(); return(this); }
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); }
/// <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); }
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(); }
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); }
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); }
public void Destroy() { this.BaseDestroy(); this.name = SpriteBatch.Name.Unitialized; this.poNodeCompare = null; this.pBackSpriteBatch = null; }
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); }
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); }
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); }
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; }
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); }
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); }
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); }
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; } }
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); }
//---------------------------------------------------------------------- // 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); }
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; }
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; }
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); }
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; }