Ejemplo n.º 1
0
        override public void Execute(float deltaTime)
        {
            float value = pRandom.Next(10, 60);
            UFO   pUFO  = new UFO(GameObject.Name.UFO, GameSprite.Name.UFO, 100, 515);

            ColPair pColPair = ColPairMan.Add(ColPair.Name.UFO_WallLeft, pUFO, this.pWallLeft);

            pColPair.Attach(new UFOWallLeftObserver());

            pColPair = ColPairMan.Add(ColPair.Name.UFO_WallRight, pUFO, this.pWallRight);
            pColPair.Attach(new UFOWallRightObserver());

            MissileGroup pMissile = (MissileGroup)GameObjectMan.Find(GameObject.Name.MissileGroup);

            pColPair = ColPairMan.Add(ColPair.Name.UFOMissile, pUFO, pMissile);
            pColPair.Attach(new RemoveUFOObserver());

            pUFO.ActivateCollisionSprite(this.pSB_Boxes);
            pUFO.ActivateGameSprite(this.pSB_Aliens);
            GameObjectMan.Attach(pUFO);

            Sound.Name pSoundName = Sound.Name.Uninitialized;
            switch (pRandom.Next(0, 1))
            {
            case (0):
                pSoundName = Sound.Name.UFOLow;
                break;

            case (1):
                pSoundName = Sound.Name.UFOHigh;
                break;
            }
            SoundMan.PlaySound(pSoundName);
            TimerMan.Add(TimeEvent.Name.UFO, this, value);
        }
        override public void Notify(float xCurs, float yCurs)
        {
            var inter = ColRect.Intersect(this.pFont.pFontSprite.pColRect, new ColRect(xCurs, yCurs, 1, 1));

            if (!this.pState && inter)
            {
                Sound.Name sound = Sound.Name.Uninitialized;
                switch (this.pRandom.Next(0, 3))
                {
                case (0):
                    sound = Sound.Name.Invader1;
                    break;

                case (1):
                    sound = Sound.Name.Invader2;
                    break;

                case (2):
                    sound = Sound.Name.Invader3;
                    break;

                case (3):
                    sound = Sound.Name.Invader4;
                    break;
                }
                SoundMan.PlaySound(sound);
                this.pFont.SetColor(1.0f, 1.0f, 1.0f);
                this.pState = true;
            }
            else if (!inter)
            {
                this.pState = false;
                this.pFont.SetColor(0.60f, 0.60f, 0.60f);
            }
        }
 override public void Notify(float xCurs, float yCurs)
 {
     if (ColRect.Intersect(this.pFont.pFontSprite.pColRect, new ColRect(xCurs, yCurs, 1, 1)))
     {
         SceneContext.SetState(SceneContext.Scene.Aliens);
         SoundMan.PlaySound(Sound.Name.Shoot);
     }
 }
        public override void Execute(float deltaTime)
        {
            SoundHolder pSoundHolder = (SoundHolder)this.pCurrSound.pSNext;

            if (pSoundHolder == null)
            {
                pSoundHolder = (SoundHolder)poFirstSound;
            }
            this.pCurrSound = pSoundHolder;

            SoundMan.PlaySound(pSoundHolder.pSound.name);
            TimerMan.Add(TimeEvent.Name.ScenePlaySound, this, deltaTime);
        }
Ejemplo n.º 5
0
        public override void Execute()
        {
            GameObject pA = (GameObject)this.pUFO;
            GameObject pB = (GameObject)Iterator.GetParent(pA);

            float x = this.pUFO.x;
            float y = this.pUFO.y;

            pA.Remove();

            // Hacks
            if (this.pGameObj is MissileGroup)
            {
                Missile pMissile = (Missile)Iterator.GetChild(this.pGameObj);

                // bug but don't crash please
                if (pMissile == null)
                {
                    return;
                }

                Player pPlayer = pMissile.pPlayer;
                pPlayer.nPoints += this.pUFO.GetPoints();
                Font.Name pFontName = Font.Name.Uninitialized;
                if (pPlayer.n == 1)
                {
                    pFontName = Font.Name.Score1Value;
                }
                if (pPlayer.n == 2)
                {
                    pFontName = Font.Name.Score2Value;
                }
                Font pScore = FontMan.Find(pFontName);
                pScore.Set(pFontName,
                           pPlayer.nPoints.ToString(),
                           Glyph.Name.Consolas20pt,
                           pScore.pFontSprite.x,
                           pScore.pFontSprite.y);
            }

            SoundMan.PlaySound(Sound.Name.InvaderKilled);

            Explosion   explosion = new Explosion(GameObject.Name.Explosion, GameSprite.Name.Explosion, x, y);
            SpriteBatch pSB_UFOs  = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);

            explosion.ActivateGameSprite(pSB_UFOs);
            GameObjectMan.Attach(explosion);
            TimerMan.Add(TimeEvent.Name.RemoveExplosion, new RemoveExplosionCommand(explosion), 0.25f);
        }
        public override void Notify()
        {
            this.pBomb = (Bomb)this.pSubject.pObjA;

            MissileGroup pMissileGroup = (MissileGroup)this.pSubject.pObjB;

            this.pMissile = (Missile)Iterator.GetChild(pMissileGroup);
            Debug.Assert(this.pMissile != null);

            if (this.pBomb.bMarkForDeath == false)
            {
                this.pBomb.bMarkForDeath = true;
            }

            if (this.pMissile.bMarkForDeath == false)
            {
                this.pBomb.bMarkForDeath = true;
            }

            //   Delay
            RemoveMissileAndBombObserver pObserver = new RemoveMissileAndBombObserver((Bomb)this.pBomb, (Missile)this.pMissile);

            DelayedObjectMan.Attach(pObserver);

            //---------------------------------------------------------------------------------------------------------
            // Sound
            //---------------------------------------------------------------------------------------------------------
            SoundMan.PlaySound(Sound.Name.InvaderKilled);
            TimeEvent pTimeEvent = TimerMan.Find(TimeEvent.Name.ScenePlaySound);

            //---------------------------------------------------------------------------------------------------------
            // Explosion
            //---------------------------------------------------------------------------------------------------------
            Explosion   explosion  = new Explosion(GameObject.Name.Explosion, GameSprite.Name.Explosion, this.pBomb.x, this.pBomb.y);
            SpriteBatch pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);

            explosion.ActivateGameSprite(pSB_Aliens);
            GameObjectMan.Attach(explosion);
            TimerMan.Add(TimeEvent.Name.RemoveExplosion, new RemoveExplosionCommand(explosion), 0.25f);
        }
Ejemplo n.º 7
0
        public override void Execute()
        {
            GameObject pA = (GameObject)this.pBrick;
            GameObject pB = (GameObject)Iterator.GetParent(pA);

            pA.Remove();

            if (!(this.pObjA is AlienGrid))
            {
                SoundMan.PlaySound(Sound.Name.Explode);
            }

            if (privCheckParent(pB) == true)
            {
                GameObject pC = (GameObject)Iterator.GetParent(pB);
                pB.Remove();

                if (privCheckParent(pC) == true)
                {
                    //pC.Remove();
                }
            }
        }
Ejemplo n.º 8
0
 public override void Notify()
 {
     SoundMan.PlaySound(Sound.Name.Shoot);
     pShip.ShootMissile();
 }
Ejemplo n.º 9
0
        public override void Execute()
        {
            GameObject pA = (GameObject)this.pAlien;
            GameObject pB = (GameObject)Iterator.GetParent(pA);

            float x = this.pAlien.x;
            float y = this.pAlien.y;

            AlienGrid pGrid = (AlienGrid)this.pAlien.pParent.pParent;

            pGrid.nNumActive--;

            pA.Remove();

            // TODO: Need a better way...
            if (privCheckParent(pB) == true)
            {
                GameObject pC = (GameObject)Iterator.GetParent(pB);
                pB.Remove();

                if (privCheckParent(pC) == true)
                {
                    pC.Remove();
                }
            }

            Missile pMissile = (Missile)this.pGameObj;
            Player  pPlayer  = pMissile.pPlayer;

            //
            Font.Name pFontName = Font.Name.Uninitialized;
            if (this.pGameObj is MissileCategory)
            {
                pPlayer.nPoints += this.pAlien.GetPoints();
                Font pScore = null;
                if (pPlayer.n == 1)
                {
                    pScore    = FontMan.Find(Font.Name.Score1Value);
                    pFontName = Font.Name.Score1Value;
                }
                if (pPlayer.n == 2)
                {
                    pScore    = FontMan.Find(Font.Name.Score2Value);
                    pFontName = Font.Name.Score2Value;
                }
                pScore.Set(pFontName,
                           pPlayer.nPoints.ToString(),
                           Glyph.Name.Consolas20pt,
                           pScore.pFontSprite.x,
                           pScore.pFontSprite.y);
            }

            //---------------------------------------------------------------------------------------------------------
            // Sound
            //---------------------------------------------------------------------------------------------------------
            SoundMan.PlaySound(Sound.Name.InvaderKilled);
            TimeEvent pTimeEvent = TimerMan.Find(TimeEvent.Name.ScenePlaySound);

            pTimeEvent.deltaTime -= 0.01f;

            //---------------------------------------------------------------------------------------------------------
            // Explosion
            //---------------------------------------------------------------------------------------------------------
            Explosion   explosion  = new Explosion(GameObject.Name.Explosion, GameSprite.Name.Explosion, x, y);
            SpriteBatch pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);

            explosion.ActivateGameSprite(pSB_Aliens);
            GameObjectMan.Attach(explosion);
            TimerMan.Add(TimeEvent.Name.RemoveExplosion, new RemoveExplosionCommand(explosion), 0.25f);

            //---------------------------------------------------------------------------------------------------------
            // Scene Transition
            //---------------------------------------------------------------------------------------------------------
            if (pGrid.nNumActive == 0 && pPlayer.nCurrLevel == 1)
            {
                PlayerMan.WriteHighScores();
                pPlayer.nCurrLevel++;
                SceneContext.GetState().Initialize();
                if (SceneContext.bMultiplayer)
                {
                    SceneContext.SetState(SceneContext.Scene.MultiPlay);
                }
                else
                {
                    SceneContext.SetState(SceneContext.Scene.SinglePlay);
                }
            }
            else if (pGrid.nNumActive == 0 && pPlayer.nCurrLevel == 2)
            {
                PlayerMan.WriteHighScores();
                SceneContext.SetState(SceneContext.Scene.Credits);
            }
        }