Пример #1
0
 /// <summary>
 /// Launch the game
 /// </summary>
 public void Load()
 {
     GameStateManager = new GameStateManager();
 }
        // TODO Clean this up
        public override void Notify()
        {
            //Debug.WriteLine("RemoveShieldBrickObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);

            // This cast will throw an exception if wrong
            this.pShieldBrick     = (ShieldBrick)this.pSubject.pObjA;
            this.pColComposite    = null;
            this.pShieldComposite = null;

            // Remove Shield from composite
            Composite       pShieldGrid = GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.ShieldGroup);
            ForwardIterator pFwdIter    = new ForwardIterator(pShieldGrid);

            Component pNode = pFwdIter.First();

            while (!pFwdIter.IsDone())
            {
                if (pNode.containerType == Component.Container.LEAF)
                {
                    // If Component is target shield brick
                    if (pNode.GetHashCode() == this.pShieldBrick.GetHashCode())
                    {
                        // Remove shield brick from column
                        pNode.pParent.Remove(pNode);

                        // Get references to parent composites
                        Component pShieldColComposite = pNode.pParent;
                        Component pShieldComposite    = null;

                        if (pShieldColComposite != null)
                        {
                            pShieldComposite = pShieldColComposite.pParent;
                        }

                        // If column is now empty, delete column
                        if (pShieldColComposite.GetFirstChild() == null)
                        {
                            // Delete empty column from parent composite
                            if (pShieldColComposite.pParent != null)
                            {
                                pShieldColComposite.pParent.Remove(pShieldColComposite);
                            }

                            // Mark empty column for death
                            if (!((GameObject)pShieldColComposite).IsMarkedForDeath())
                            {
                                this.pColComposite = (GameObject)pShieldColComposite;
                                this.pColComposite.MarkForDeath();
                            }
                        }

                        // If Shield is now empty, delete column
                        if (pShieldComposite.GetFirstChild() == null)
                        {
                            // Delete empty shield from parent composite
                            if (pShieldComposite.pParent != null)
                            {
                                pShieldComposite.pParent.Remove(pShieldComposite);
                            }

                            // Mark empty shield for death
                            if (!((GameObject)pShieldComposite).IsMarkedForDeath())
                            {
                                this.pShieldComposite = (GameObject)pShieldComposite;
                                this.pShieldComposite.MarkForDeath();
                            }
                        }

                        break;
                    }
                }

                pNode = pFwdIter.Next();
            }

            if (!pShieldBrick.IsMarkedForDeath())
            {
                pShieldBrick.MarkForDeath();

                // Delay - remove object later
                RemoveShieldBrickObserver pObserver = new RemoveShieldBrickObserver(this);
                GameStateManager.GetGame().GetStateDelayedObjectManager().Attach(pObserver);
            }
        }
 public override void Notify()
 {
     GameStateManager.GetGame().SetStateChangeFlag(true);
 }
Пример #4
0
        public GameObject Create(ShieldCategory.Type type, GameObject.Name gameName, float posX = 0.0f, float posY = 0.0f)
        {
            GameObject pShield = null;

            switch (type)
            {
            case ShieldCategory.Type.Brick:
                pShield = new ShieldBrick(gameName, Sprite.Name.Brick, posX, posY);
                break;

            case ShieldCategory.Type.LeftTop1:
                pShield = new ShieldBrick(gameName, Sprite.Name.Brick_LeftTop1, posX, posY);
                break;

            case ShieldCategory.Type.LeftTop0:
                pShield = new ShieldBrick(gameName, Sprite.Name.Brick_LeftTop0, posX, posY);
                break;

            case ShieldCategory.Type.LeftBottom:
                pShield = new ShieldBrick(gameName, Sprite.Name.Brick_LeftBottom, posX, posY);
                break;

            case ShieldCategory.Type.RightTop1:
                pShield = new ShieldBrick(gameName, Sprite.Name.Brick_RightTop1, posX, posY);
                break;

            case ShieldCategory.Type.RightTop0:
                pShield = new ShieldBrick(gameName, Sprite.Name.Brick_RightTop0, posX, posY);
                break;

            case ShieldCategory.Type.RightBottom:
                pShield = new ShieldBrick(gameName, Sprite.Name.Brick_RightBottom, posX, posY);
                break;

            case ShieldCategory.Type.Root:
                pShield = new ShieldRoot(gameName, Sprite.Name.NullSprite, posX, posY);
                pShield.SetCollisionObjectLineColor(0.0f, 0.0f, 1.0f);
                break;

            case ShieldCategory.Type.Column:
                pShield = new ShieldColumn(gameName, Sprite.Name.NullSprite, posX, posY);
                pShield.SetCollisionObjectLineColor(1.0f, 0.0f, 0.0f);
                break;

            default:
                // something is wrong
                Debug.Assert(false);
                break;
            }

            // 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);
        }
 public override void Notify()
 {
     GameStateManager.GetGame().SetTwoPlayerMode(twoPlayerMode);
     base.Notify();
 }
Пример #6
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);
        }
Пример #7
0
        public static GameObject RecreateShield(float start_x = 0.0f, float start_y = 0.0f)
        {
            GhostManager      pGhostManager      = GameStateManager.GetGame().GetStateGhostManager();
            GameObjectManager pGameObjectManager = GameStateManager.GetGame().GetStateGameObjectManager();

            Composite pShieldRoot = (Composite)pGhostManager.Find(GameObject.Name.ShieldRoot);

            pGhostManager.Detach(pShieldRoot);

            GameStateManager.GetGame().GetStateGameObjectManager().Attach(pShieldRoot);
            pShieldRoot.ActivateSprite(GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.Shield));
            pShieldRoot.ActivateCollisionSprite(GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.CollisionBox));

            ShieldFactory SF = new ShieldFactory(SpriteBatch.Name.Shield, SpriteBatch.Name.CollisionBox, pShieldRoot);

            // load by column

            GameObject pColumn;

            SF.SetParent(pShieldRoot);
            pColumn = SF.Recreate(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn);

            SF.SetParent(pColumn);

            float off_x       = 0;
            float brickWidth  = 12.0f;
            float brickHeight = 6.0f;

            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 2 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 3 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 4 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 5 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 6 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 7 * brickHeight);
            SF.Recreate(ShieldCategory.Type.LeftTop1, GameObject.Name.ShieldBrick, start_x, start_y + 8 * brickHeight);
            SF.Recreate(ShieldCategory.Type.LeftTop0, GameObject.Name.ShieldBrick, start_x, start_y + 9 * brickHeight);

            SF.SetParent(pShieldRoot);
            pColumn = SF.Recreate(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn);

            SF.SetParent(pColumn);

            off_x += brickWidth;
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

            SF.SetParent(pShieldRoot);
            pColumn = SF.Recreate(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn);

            SF.SetParent(pColumn);

            off_x += brickWidth;
            SF.Recreate(ShieldCategory.Type.LeftBottom, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

            SF.SetParent(pShieldRoot);
            pColumn = SF.Recreate(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn);

            SF.SetParent(pColumn);

            off_x += brickWidth;
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

            SF.SetParent(pShieldRoot);
            pColumn = SF.Recreate(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn);

            SF.SetParent(pColumn);

            off_x += brickWidth;
            SF.Recreate(ShieldCategory.Type.RightBottom, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

            SF.SetParent(pShieldRoot);
            pColumn = SF.Recreate(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn);

            SF.SetParent(pColumn);

            off_x += brickWidth;
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

            SF.SetParent(pShieldRoot);
            pColumn = SF.Recreate(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn);

            SF.SetParent(pColumn);

            off_x += brickWidth;
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
            SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
            SF.Recreate(ShieldCategory.Type.RightTop1, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
            SF.Recreate(ShieldCategory.Type.RightTop0, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

            return(pShieldRoot);
        }
Пример #8
0
        public static GameObject CreateAlienGrid(float start_x = 0.0f, float start_y = 0.0f)
        {
            // Create Composite objects
            Composite pAlienGrid = new AlienGrid(Composite.CompositeName.AlienGrid, 20.0f, 0.0f);

            pAlienGrid.SetCollisionObjectLineColor(1.0f, 1.0f, 0.0f);
            pAlienGrid.ActivateSprite(GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.Alien));
            pAlienGrid.ActivateCollisionSprite(GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.CollisionBox));
            GameStateManager.GetGame().GetStateCompositeManager().Attach(pAlienGrid);
            GameStateManager.GetGame().GetStateGameObjectManager().Attach(pAlienGrid);

            Composite pCol;

            for (int i = 0; i < 11; i++)
            {
                pCol = new AlienGridColumn(Composite.CompositeName.AlienCol1 + i);
                GameStateManager.GetGame().GetStateGameObjectManager().Attach(pCol);

                // Generate Aliens & Attach to Column
                GenerateNewAlienGridColumn(pCol, (start_x + (60.0f * i)), start_y);

                // Append Columns to AlienGrid
                pAlienGrid.Add(pCol);
            }

            // Add Initial AlienGridMovement Event
            AlienGridMovement pAlienGridMovement = new AlienGridMovement(pAlienGrid);

            GameStateManager.GetGame().GetStateQueuedTimeEventManager().Enqueue(TimeEvent.Name.AlienGridMovement, pAlienGridMovement, GameStateManager.GetGame().GetStateLevelInitialAlienGridSpeed());

            return(pAlienGrid);
        }
Пример #9
0
        public override void Execute(float deltaTime)
        {
            SpaceInvaders pGame = GameStateManager.GetGame();

            pGame.SetResetLevelFlag(false);

            // Ghost any remaining Shields
            ShieldGroup pShieldGroup = (ShieldGroup)GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.ShieldGroup);

            ShieldFactory.DestroyShields(pShieldGroup);

            // Ghost any remaining Aliens (Only necessary for Game reset)
            AlienGrid pAlienGrid = (AlienGrid)GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.AlienGrid);

            AlienFactory.DestroyAlienGrid(pAlienGrid);

            // Clear TimeEvents
            TimeEvent tEvent = TimerManager.Pop();

            while (tEvent != null)
            {
                // Kill any remaining TimerEvents
                tEvent = TimerManager.Pop();
            }

            // Recreate shields
            GameObject pShield;

            pShield = ShieldFactory.RecreateShield(110, 150);
            pShieldGroup.Add(pShield);
            pShield = ShieldFactory.RecreateShield(310, 150);
            pShieldGroup.Add(pShield);
            pShield = ShieldFactory.RecreateShield(510, 150);
            pShieldGroup.Add(pShield);
            pShield = ShieldFactory.RecreateShield(710, 150);
            pShieldGroup.Add(pShield);

            // Adjust Starting Speed
            float newStartingSpeed = pGame.GetStateLevelInitialAlienGridSpeed() - 0.05f;

            pGame.SetStateLevelInitialAlienGridSpeed(newStartingSpeed);
            pGame.SetStateAlienGridSpeed(newStartingSpeed);

            // Adjust Starting Position
            float newStartingYPosition = pGame.GetStateLevelInitialAlienGridYPosition() - 40.0f;

            pGame.SetStateLevelInitialAlienGridYPosition(newStartingYPosition);

            // Recreate AlienGrid
            AlienFactory.RecreateAlienGrid(pAlienGrid, newStartingSpeed, GameStateManager.GetGame().GetGameInitialGridXPosition(), newStartingYPosition);

            pGame.GetStateGameObjectManager().Print();
            pGame.GetStateSpriteBatchManager().Print();

            // Queue up Time Events
            QueuedTimeEventManager qtem = pGame.GetStateQueuedTimeEventManager();

            qtem.Enqueue(TimeEvent.Name.AlienGridMovementSound, new AlienGridMovementSound(), newStartingSpeed);
            qtem.Enqueue(TimeEvent.Name.SpriteAnimation, SpriteAnimationManager.Find(SpriteAnimation.Name.SquidAlien), newStartingSpeed);
            qtem.Enqueue(TimeEvent.Name.SpriteAnimation, SpriteAnimationManager.Find(SpriteAnimation.Name.CrabAlien), newStartingSpeed);
            qtem.Enqueue(TimeEvent.Name.SpriteAnimation, SpriteAnimationManager.Find(SpriteAnimation.Name.JellyfishAlien), newStartingSpeed);
            qtem.Enqueue(TimeEvent.Name.DropBomb, new DropBombCommand(), 1.0f);
            qtem.Enqueue(TimeEvent.Name.DropBomb, new DropBombCommand(), 3.0f);
        }
Пример #10
0
        public override void Notify()
        {
            // Delete missile
            //Debug.WriteLine("RemoveAlienObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);

            // This cast will throw an exception if wrong
            this.pAlien     = (Alien)this.pSubject.pObjA;
            this.pComposite = null;

            // Remove Alien from composite
            Composite       pAlienGrid = GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.AlienGrid);
            ForwardIterator pFwdIter   = new ForwardIterator(pAlienGrid);

            Component pNode = pFwdIter.First();

            while (!pFwdIter.IsDone())
            {
                if (pNode.containerType == Component.Container.LEAF)
                {
                    // If Component is target alien
                    if (pNode.GetHashCode() == this.pAlien.GetHashCode())
                    {
                        // Remove Alien from column
                        pNode.pParent.Remove(pNode);

                        Component parentComposite = pNode.pParent;
                        // If column is now empty, delete column
                        if (parentComposite.GetFirstChild() == null)
                        {
                            // Delete empty column from parent composite
                            if (parentComposite.pParent != null)
                            {
                                parentComposite.pParent.Remove(parentComposite);
                            }

                            if (!((GameObject)parentComposite).IsMarkedForDeath())
                            {
                                // Delay - remove object later
                                this.pComposite = (GameObject)parentComposite;
                                this.pComposite.MarkForDeath();
                            }
                        }

                        break;
                    }
                }

                pNode = pFwdIter.Next();
            }

            if (!pAlien.IsMarkedForDeath())
            {
                pAlien.MarkForDeath();

                // Delay - remove object later
                RemoveAlienObserver pObserver = new RemoveAlienObserver(this);
                GameStateManager.GetGame().GetStateDelayedObjectManager().Attach(pObserver);
            }

            // Faster grid speed (shorter delta)
            float newSpeed = GameStateManager.GetGame().GetStateAlienGridSpeed() - 0.013f;

            if (newSpeed > 0.0f)
            {
                // Increase Alien Grid Speed
                GameStateManager.GetGame().SetStateAlienGridSpeed(newSpeed);
            }
        }