public override void ExecuteDelayed()
        {
            // Let the gameObjects deal with this...

            if (this.pShieldBrick != null)
            {
                this.pShieldBrick.Remove(SpriteBatch.Name.Shield, SpriteBatch.Name.CollisionBox);
            }

            if (this.pColComposite != null)
            {
                this.pColComposite.Remove(SpriteBatch.Name.Shield, SpriteBatch.Name.CollisionBox);
            }

            if (this.pShieldComposite != null)
            {
                this.pShieldComposite.Remove(SpriteBatch.Name.Shield, SpriteBatch.Name.CollisionBox);
            }

            // Remove root if all deleted
            Composite pShieldGroup = GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.ShieldGroup);

            if (pShieldGroup.GetFirstChild() == null && !pShieldGroup.IsMarkedForDeath())
            {
                pShieldGroup.MarkForDeath();
                pShieldGroup.Remove(SpriteBatch.Name.Shield, SpriteBatch.Name.CollisionBox);
            }
        }
        public override void Execute(float deltaTime)
        {

            Composite pFlyingSaucerRoot = GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.FlyingSaucerRoot);

            // If there is not already a flying saucer on screen
            if (pFlyingSaucerRoot.GetFirstChild() == null)
            {
                // Identify random starting location (left or right)
                // 0 == Left, 1 == Right
                int randomStart = r.Next(0, 2);

                float xPos = 65 + (randomStart * 770.0f);
                float xDelta = (randomStart == 0) ? 10.0f : -10.0f;
                float yPos = 735.0f;

                FlyingSaucer pFlyingSaucer = new FlyingSaucer(GameObject.Name.FlyingSaucer, Sprite.Name.FlyingSaucer, xPos, yPos);
                GameStateManager.GetGame().GetStateGameObjectManager().Attach(pFlyingSaucer);
                GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.FlyingSaucerRoot).Add(pFlyingSaucer);
                pFlyingSaucer.ActivateSprite(GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.FlyingSaucer));
                pFlyingSaucer.ActivateCollisionSprite(GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.CollisionBox));

                FlyingSaucerMovement pFlyingSaucerMovement = new FlyingSaucerMovement(GameObject.Name.FlyingSaucer, xDelta, 0.0f);
                TimerManager.Add(TimeEvent.Name.SpriteMovement, pFlyingSaucerMovement, 0.1f);
                TimerManager.Add(TimeEvent.Name.DropBomb, new DropFlyingSaucerBombCommand(), (float)r.NextDouble());
            }

        }
Exemple #3
0
        public override void Execute(float deltaTime)
        {
            Composite pFlyingSaucerRoot = GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.FlyingSaucerRoot);

            // If Flying Saucer is on screen
            if (pFlyingSaucerRoot.GetFirstChild() != null)
            {
                Composite pBombRoot = GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.BombRoot);

                // Identify random Column + starting location
                int          randomColIndex = r.Next(0, pFlyingSaucerRoot.GetNumOfChildren());
                FlyingSaucer pFlyingSaucer  = (FlyingSaucer)pFlyingSaucerRoot.GetFirstChild();
                Azul.Rect    pFlyingSaucerColCollisionRect = pFlyingSaucer.GetCollisionObject().GetCollisionRect();

                float xPos = (pFlyingSaucerColCollisionRect.x + (pFlyingSaucerColCollisionRect.width / 2.0f));
                float yPos = (pFlyingSaucerColCollisionRect.y - (pFlyingSaucerColCollisionRect.height / 2.0f));

                // Identify random Bomb Type and create bomb
                FallStrategy bombStrategy = null;
                int          bombType     = r.Next(0, 3);

                if (bombType == 0)
                {
                    bombType     = (int)Sprite.Name.BombStraight;
                    bombStrategy = new FallStraight();
                }
                else if (bombType == 1)
                {
                    bombType     = (int)Sprite.Name.BombZigZag;
                    bombStrategy = new FallZigZag();
                }
                else
                {
                    bombType     = (int)Sprite.Name.BombCross;
                    bombStrategy = new FallDagger();
                }

                // TODO refactor to use Object Pool
                FlyingSaucerBomb pBomb = new FlyingSaucerBomb(GameObject.Name.FlyingSaucerBomb, (Sprite.Name)bombType, bombStrategy, xPos, yPos);

                // Attach to BombRoot, SpriteBatches, and any related managers
                GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.BombRoot).Add(pBomb);
                GameStateManager.GetGame().GetStateGameObjectManager().Attach(pBomb);
                pBomb.ActivateCollisionSprite(GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.CollisionBox));
                pBomb.ActivateSprite(GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.Bomb));
            }
        }
Exemple #4
0
 public Movement(Composite root, SpriteBatch pSpriteBatch, SpriteBatch pCollisionSpriteBatch, Composite pTree)
 {
     // initialized the sprite animation is attached to
     this.grid                  = (Composite)root.GetFirstChild();
     this.pSpriteBatch          = pSpriteBatch;
     this.pCollisionSpriteBatch = pCollisionSpriteBatch;
     this.pTree                 = pTree;
 }
Exemple #5
0
        public override void Execute(float deltaTime)
        {
            Composite pFlyingSaucerRoot = GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.FlyingSaucerRoot);

            IrrKlang.ISoundEngine pSoundEngine = SoundEngineManager.GetSoundEngine();

            // If flying saucer is active
            if (pFlyingSaucerRoot.GetFirstChild() != null)
            {
                // Check to see if sound is currently playing
                if (!pSoundEngine.IsCurrentlyPlaying("ufo_lowpitch.wav"))
                {
                    IrrKlang.ISound pSnd = pSoundEngine.Play2D("ufo_lowpitch.wav");
                }

                base.Execute(deltaTime);
            }
        }
Exemple #6
0
        public override void ExecuteDelayed()
        {
            // Let the gameObjects deal with this...

            if (this.pAlien != null)
            {
                this.pAlien.Remove(SpriteBatch.Name.Alien, SpriteBatch.Name.CollisionBox);
            }

            if (this.pComposite != null)
            {
                this.pComposite.Remove(SpriteBatch.Name.Alien, SpriteBatch.Name.CollisionBox);
            }

            // Reset level if all deleted
            Composite pAlienGrid = GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.AlienGrid);

            if (pAlienGrid.GetFirstChild() == null)
            {
                GameStateManager.GetGame().SetResetLevelFlag(true);
            }
        }