public override void Execute(float deltaTime) { GhostManager pGhostManager = GameStateManager.GetGame().GetStateGhostManager(); GameObjectManager pGameObjectManager = GameStateManager.GetGame().GetStateGameObjectManager(); SpriteBatchManager pSpriteBatchManager = GameStateManager.GetGame().GetStateSpriteBatchManager(); Composite pCoreCannonGroup = GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.CoreCannonGroup); GameObject pGameObj = pGhostManager.Find(GameObject.Name.CoreCannon); // Remove game object from ghost manager pGhostManager.Detach(pGameObj); // Reset position pGameObj.SetX(200); pGameObj.SetY(100); // Reset Collision Object Azul.Rect pSpriteProxyScreenRect = pGameObj.GetSpriteProxy().GetSpriteScreenRect(); CollisionObject pCollisionObject = pGameObj.GetCollisionObject(); pCollisionObject.GetCollisionRect().Set(pSpriteProxyScreenRect); pCollisionObject.GetCollisionSpriteBox().Set(SpriteBox.Name.Box, 200, 100, pSpriteProxyScreenRect.width, pSpriteProxyScreenRect.height); // Add to GameObjectManager Debug.Assert(pGameObj != null); pGameObjectManager.Attach(pGameObj); // Add to Composite pCoreCannonGroup.Add(pGameObj); // Attach to SpriteBatch pGameObj.ActivateSprite(pSpriteBatchManager.Find(SpriteBatch.Name.CoreCannon)); pGameObj.ActivateCollisionSprite(pSpriteBatchManager.Find(SpriteBatch.Name.CollisionBox)); }
public void Recreate(Alien.Type type, float posX, float posY) { GameObject pGameObj = null; GhostManager pGhostManager = GameStateManager.GetGame().GetStateGhostManager(); GameObjectManager pGameObjectManager = GameStateManager.GetGame().GetStateGameObjectManager(); switch (type) { case Alien.Type.Crab: pGameObj = pGhostManager.Find(GameObject.Name.CrabAlien); break; case Alien.Type.FlyingSaucer: pGameObj = pGhostManager.Find(GameObject.Name.FlyingSaucer); break; case Alien.Type.JellyFish: pGameObj = pGhostManager.Find(GameObject.Name.JellyFishAlien); break; case Alien.Type.Squid: pGameObj = pGhostManager.Find(GameObject.Name.SquidAlien); break; default: // something is wrong Debug.Assert(false); break; } // Remove game object from ghost manager pGhostManager.Detach(pGameObj); // Reset position pGameObj.SetX(posX); pGameObj.SetY(posY); // Reset Collision Object Azul.Rect pSpriteProxyScreenRect = pGameObj.GetSpriteProxy().GetSpriteScreenRect(); CollisionObject pCollisionObject = pGameObj.GetCollisionObject(); pCollisionObject.GetCollisionRect().Set(pSpriteProxyScreenRect); pCollisionObject.GetCollisionSpriteBox().Set(SpriteBox.Name.Box, posX, posY, pSpriteProxyScreenRect.width, pSpriteProxyScreenRect.height); // Add to GameObjectManager Debug.Assert(pGameObj != null); pGameObjectManager.Attach(pGameObj); // Add to Composite pComposite.Add(pGameObj); // Attach to SpriteBatch pGameObj.ActivateSprite(this.pAlienSpriteBatch); pGameObj.ActivateCollisionSprite(this.pCollisionBoxSpriteBatch); }
public GameObject Recreate(ShieldCategory.Type type, GameObject.Name gameName, float posX = 0.0f, float posY = 0.0f) { GhostManager pGhostManager = GameStateManager.GetGame().GetStateGhostManager(); GameObjectManager pGameObjectManager = GameStateManager.GetGame().GetStateGameObjectManager(); GameObject pShield = null; switch (type) { case ShieldCategory.Type.Brick: pShield = pGhostManager.Find(GameObject.Name.ShieldBrick); break; case ShieldCategory.Type.LeftTop1: pShield = pGhostManager.Find(GameObject.Name.ShieldBrick_LeftTop1); break; case ShieldCategory.Type.LeftTop0: pShield = pGhostManager.Find(GameObject.Name.ShieldBrick_LeftTop0); break; case ShieldCategory.Type.LeftBottom: pShield = pGhostManager.Find(GameObject.Name.ShieldBrick_LeftBottom); break; case ShieldCategory.Type.RightTop1: pShield = pGhostManager.Find(GameObject.Name.ShieldBrick_RightTop1); break; case ShieldCategory.Type.RightTop0: pShield = pGhostManager.Find(GameObject.Name.ShieldBrick_RightTop0); break; case ShieldCategory.Type.RightBottom: pShield = pGhostManager.Find(GameObject.Name.ShieldBrick_RightBottom); break; case ShieldCategory.Type.Root: pShield = pGhostManager.Find(GameObject.Name.ShieldRoot); pShield.SetCollisionObjectLineColor(0.0f, 0.0f, 1.0f); break; case ShieldCategory.Type.Column: pShield = pGhostManager.Find(GameObject.Name.ShieldColumn); pShield.SetCollisionObjectLineColor(1.0f, 0.0f, 0.0f); break; default: // something is wrong Debug.Assert(false); break; } // Remove game object from ghost manager pGhostManager.Detach(pShield); // Reset position pShield.SetX(posX); pShield.SetY(posY); // Reset Collision Object Azul.Rect pSpriteProxyScreenRect = pShield.GetSpriteProxy().GetSpriteScreenRect(); CollisionObject pCollisionObject = pShield.GetCollisionObject(); pCollisionObject.GetCollisionRect().Set(pSpriteProxyScreenRect); pCollisionObject.GetCollisionSpriteBox().Set(SpriteBox.Name.Box, posX, posY, pSpriteProxyScreenRect.width, pSpriteProxyScreenRect.height); // Add to GameObjectManager GameStateManager.GetGame().GetStateGameObjectManager().Attach(pShield); // add to the tree this.pTree.Add(pShield); // Attached to Group pShield.ActivateSprite(this.pSpriteBatch); pShield.ActivateCollisionSprite(this.pCollisionSpriteBatch); return(pShield); }