Esempio n. 1
0
        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);
        }