Exemple #1
0
        public override void Notify()
        {
            this.pBomb = (Bomb)this.pSubject.pObjA;
            Debug.Assert(this.pBomb != null);

            if (pBomb.bMarkForDeath == false)
            {
                pBomb.bMarkForDeath = true;
                //   Delay
                RemoveBombObserver pObserver = new RemoveBombObserver(this);
                DelayedObjectMan.Attach(pObserver);
            }

            if (this.pSubject.pObjB is WallBottom)
            {
                //---------------------------------------------------------------------------------------------------------
                // Explosion
                //---------------------------------------------------------------------------------------------------------
                Explosion   explosion  = new Explosion(GameObject.Name.Explosion_Ground, GameSprite.Name.Explosion_Ground, 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);
            }
        }
        public override void Execute()
        {
            if (scenePlay.numLives > 1)
            {
                GameObject pA = (GameObject)this.pShip;
                GameObject pB = (GameObject)Iterator.GetParent(pA);

                pA.Remove();

                this.pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);
                Debug.Assert(this.pSB_Aliens != null);

                this.pSB_Boxes = SpriteBatchMan.Find(SpriteBatch.Name.Boxes);
                Debug.Assert(this.pSB_Boxes != null);

                // TODO: Splat Alien - needs a better way
                this.pSplat = new Splat(GameObject.Name.Splat, GameSprite.Name.SplatShip, pShip.x, pShip.y);
                pSplat.ActivateCollisionSprite(this.pSB_Boxes);
                pSplat.ActivateGameSprite(this.pSB_Aliens);

                GameObject pSplatbRoot = GameObjectMan.Find(GameObject.Name.SplatRoot);
                Debug.Assert(pSplatbRoot != null);
                pSplatbRoot.Add(pSplat);

                TimerMan.Add(TimeEvent.Name.SplatRemoveShip, new SplatRemoveEvent(this.pSplat), 0.6f);

                this.scenePlay.RemoveLife();
            }
        }
        override public void Update(float systemTime)
        {
            // Snd update - keeps everything moving and updating smoothly
            sndEngine.Update();

            // Single Step, Free running...
            Simulation.Update(systemTime);

            // Input
            InputMan.Update();

            // Run based on simulation stepping
            if (Simulation.GetTimeStep() > 0.0f)
            {
                // Fire off the timer events
                TimerMan.Update(Simulation.GetTotalTime());

                // walk through all objects and push to flyweight
                GameObjectMan.Update();

                // Do the collision checks
                ColPairMan.Process();

                // Delete any objects here...
                DelayedObjectMan.Process();
            }
        }
Exemple #4
0
        public static void Update(float totalTime)
        {
            // ensure call Create() first
            TimerMan pMan = TimerMan.GetInstance();

            Debug.Assert(pMan != null);

            pMan.mCurrTime = totalTime;

            // get the active list
            TimeEvent pEvent     = (TimeEvent)pMan.baseGetActiveList();
            TimeEvent pNextEvent = null;

            // walk the list until there is no more list or currtime is greater than timeEvent
            while (pEvent != null && (pMan.mCurrTime >= pEvent.getTriggerTime()))
            {
                // get next event
                pNextEvent = (TimeEvent)pEvent.pNext;

                if (pMan.mCurrTime > pEvent.getTriggerTime())
                {
                    // call it
                    pEvent.process();
                    // remove from active list
                    pMan.baseRemove(pEvent);
                }

                // go to next event
                pEvent = pNextEvent;
            }
        }
        public override void Execute(float deltaTime, TimeEvent.Name name)
        {
            GameObject pUFO = null;

            switch (this.flag)
            {
            case false:
                pUFO      = new LeftUFO(gameObjectName, spriteName, 800, 600);
                this.flag = true;
                break;

            case true:
                pUFO      = new RightUFO(gameObjectName, spriteName, 100, 600);
                this.flag = false;
                break;

            default:
                // something is wrong
                Debug.Assert(false);
                break;
            }
            this.pTree.Add(pUFO);

            // Attached to Group
            pUFO.ActivateGameSprite(this.pSpriteBatch);
            pUFO.ActivateCollisionSprite(this.pCollisionSpriteBatch);

            Random rnd = new Random();
            int    num = rnd.Next(20, 50);

            TimerMan.Add(name, this, num);
        }
        override public void Execute(float deltaTime)
        {
            int pFreq = pRandom.Next(1, 10) / this.nCurrLevel;

            AlienGrid     pGrid  = (AlienGrid)GameObjectMan.Find(GameObject.Name.AlienGrid);
            AlienCategory pAlien = pGrid.GetRandomAlien();

            // HACK don't crash pleease
            if (pAlien == null)
            {
                TimerMan.Add(TimeEvent.Name.BombSpawn, this, pFreq);
                return;
            }

            int          type          = pRandom.Next(0, 2);
            FallStrategy pFallStrategy = null;

            switch (type)
            {
            case (0):
                pFallStrategy = new FallZigZag();
                break;

            case (1):
                pFallStrategy = new FallDagger();
                break;

            case (2):
                pFallStrategy = new FallStraight();
                break;
            }
            type = pRandom.Next(0, 2);
            GameSprite.Name pGameSpriteName = GameSprite.Name.Uninitialized;
            switch (type)
            {
            case (0):
                pGameSpriteName = GameSprite.Name.BombZigZag;
                break;

            case (1):
                pGameSpriteName = GameSprite.Name.BombDagger;
                break;

            case (2):
                pGameSpriteName = GameSprite.Name.BombStraight;
                break;
            }

            Bomb pBomb = new Bomb(GameObject.Name.Bomb, pGameSpriteName, pFallStrategy, pAlien.x, pAlien.y);

            pBomb.ActivateCollisionSprite(this.pSB_Boxes);
            pBomb.ActivateGameSprite(this.pSB_Bombs);

            GameObject pBombRoot = GameObjectMan.Find(GameObject.Name.BombRoot);

            Debug.Assert(pBombRoot != null);

            pBombRoot.Add(pBomb);
            TimerMan.Add(TimeEvent.Name.BombSpawn, this, pFreq);
        }
        public override void Notify()
        {
            this.num--;

            if (this.num == this.initial / 5 * 4)
            {
                // increate move rate
                // change sound
                TimerMan.UpdateEvent(0.7f);
            }
            else if (this.num == this.initial / 2)
            {
                TimerMan.UpdateEvent(0.7f);
            }
            else if (this.num == this.initial / 5)
            {
                TimerMan.UpdateEvent(0.7f);
            }
            //Debug.WriteLine(" Snd_Observer: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);
            //GameObject.Name name = this.pSubject.pObjB.GetName();


            //Font pTestMessage = FontMan.Find(Font.Name.Score1);
            //Debug.Assert(pTestMessage != null);
            //int newScore = Int32.Parse(pTestMessage.GetMessage()) + this.pScore;
            //String newScoreString = newScore.ToString().PadLeft(4, '0');
            //pTestMessage.UpdateMessage(newScoreString);
        }
Exemple #8
0
        public override void execute()
        {
            this.pUFO.remove();
            UFOEvent pUFOEvent = new UFOEvent();

            TimerMan.Add(TimeEvent.Name.MovementAnimation, pUFOEvent, UFOMan.getDeltaTime());
        }
        public override void Execute(float deltaTime)
        {
            Debug.WriteLine(" {0} time:{1} ", this.pString, TimerMan.GetCurrTime());

            // Add itself back to timer
            TimerMan.Add(TimeEvent.Name.RepeatSample, this, this.repeatDelta);
        }
        public override void Execute(float deltaTime)
        {
            this.pGrid.MoveGrid();

            // Add itself back to timer
            TimerMan.Add(TimeEvent.Name.MoveGrid, this, deltaTime);
        }
Exemple #11
0
        public static void Update(float TotalTime)
        {
            TimerMan pTMan = TimerMan.PrivGetInstance();

            Debug.Assert(pTMan != null);

            //wasn't sure how we started the timer until i saw its use in the game.cs
            pTMan.mCurrentTime = TotalTime;

            TimeEvent pEvent = (TimeEvent)pTMan.BaseGetActive();

            //set the next to walk the list
            TimeEvent pNextEvent = null;

            while (pTMan.mCurrentTime >= pEvent.trigger)
            {
                //trigger event
                if (pTMan.mCurrentTime >= pEvent.trigger)
                {
                    pEvent.Process();

                    //intially i instantiated this outside of the loop "as-is" and it caused issues
                    pNextEvent = (TimeEvent)pEvent.pNext;

                    pTMan.BaseRemove(pEvent);
                }



                pEvent = pNextEvent;
            }
        }
        public override void Execute(float deltaTime, bool repeat)
        {
            ImageHolder pImageHolder = (ImageHolder)SLink.GetNext(this.pCurrImage);

            if (pImageHolder == null)
            {
                pImageHolder = (ImageHolder)poHeadImage;
            }

            this.pCurrImage = pImageHolder;

            this.pSprite.SwapImage(pImageHolder.GetpImange());

            if (repeat == true)
            {
                if (pSprite.name == GameSprite.Name.Squid)
                {
                    TimerMan.Add(TimerEvent.Name.SquidAnimation, this, deltaTime);
                }
                else if (pSprite.name == GameSprite.Name.Crab)
                {
                    TimerMan.Add(TimerEvent.Name.CrabAnimation, this, deltaTime);
                }
                else if (pSprite.name == GameSprite.Name.Octopus)
                {
                    TimerMan.Add(TimerEvent.Name.OctopusAnimation, this, deltaTime);
                }
                else if (pSprite.name == GameSprite.Name.ShipDies)
                {
                    TimerMan.Add(TimerEvent.Name.AnimShip, this, deltaTime);
                }
            }
        }
Exemple #13
0
        public static void Update(float totalTime)
        {
            // Get the instance
            TimerMan pMan = TimerMan.PrivGetInstance();

            Debug.Assert(pMan != null);

            // squirrel away
            pMan.mCurrTime = totalTime;

            // walk the list
            TimeEvent pEvent     = (TimeEvent)pMan.BaseGetActive();
            TimeEvent pNextEvent = null;

            // Walk the list until there is no more list OR currTime is greater than timeEvent
            // ToDo Fix: List needs to be sorted
            while (pEvent != null && (pMan.mCurrTime >= pEvent.triggerTime))
            {
                // Difficult to walk a list and remove itself from the list
                // so squirrel away the next event now, use it at bottom of while
                pNextEvent = (TimeEvent)pEvent.pNext;

                if (pMan.mCurrTime >= pEvent.triggerTime)
                {
                    // call it
                    pEvent.Process();

                    // remove from list
                    pMan.BaseRemove(pEvent);
                }

                // advance the pointer
                pEvent = pNextEvent;
            }
        }
Exemple #14
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);
        }
Exemple #15
0
        public override void Execute()
        {
            GameObject pAlienObject = (GameObject)this.pAlien;
            GameObject pColumn      = (GameObject)Iterator.GetParent(pAlienObject);

            SpaceInvaders pGame = GameMan.GetGame();


            //always remove the alien
            pAlienObject.Remove();

            //check if Column has aliens left
            //true means we have no more children, and safe to remove column
            if (PrivCheckParent(pColumn) == true)
            {
                GameObject pGroup = (GameObject)Iterator.GetParent(pColumn);
                pColumn.Remove();

                //check if Grid/Group had any columns left
                //true means we have no more children, and safe to change states
                if (PrivCheckParent(pGroup) == true)
                {
                    //We just beat a wave, so call the the states handle
                    // to either go to next wave or to see if its the end of the game
                    TimerMan.Add(TimeEvent.Name.GameStateChange, new GameStateChange(true), 5.0f);
                }
            }
        }
Exemple #16
0
        public override void execute()
        {
            this.pBomb.getProxySprite().setGameSprite(GameSpriteMan.Find(GameSprite.Name.Bomb_Explosion));
            ExplosionEvent pExplosionEvent = new ExplosionEvent(this.pBomb);

            TimerMan.Add(TimeEvent.Name.ExplosionEvent, pExplosionEvent, 0.1f);
        }
Exemple #17
0
 public override void Transition()
 {
     SpriteBatchMan.SetActive(this.poSpriteBatchMan);
     GameObjectMan.SetActive(this.poGameObjectMan);
     InputMan.SetActive(this.poInputMan);
     TimerMan.SetActive(this.poTimerMan);
 }
        public override void Notify()
        {
            GameObject pObject = this.pSubject.pObjB;

            Debug.Assert(pObject != null);

            GameSprite pUFOSplat = GameSpriteMan.Find(GameSprite.Name.UFOsplat);

            //future concept
            //pObject.GetProxy().SetRealSprite(this.pSprite);


            //get the locations and render the image
            pUFOSplat.PosX(pObject.x);
            pUFOSplat.PosY(pObject.y);
            pUFOSplat.Update();

            SpriteBatch pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);


            pSB_Aliens.Attach(pUFOSplat);


            TimerMan.Add(TimeEvent.Name.SplatAnim, new SplatAnim(pUFOSplat, pSB_Aliens), 0.5f);
        }
        public override void Notify()
        {
            //when this notify is called we swap the images and draw it to the alien spritebatch
            //then maybe add a time event that..... removes it somehow... remove from spritebatch after a half second

            GameObject pObject = this.pSubject.pObjB;

            Debug.Assert(pObject != null);

            GameSprite pShipSplat = GameSpriteMan.Find(GameSprite.Name.ShipSplat);

            //future concept
            //pObject.GetProxy().SetRealSprite(this.pSprite);


            //get the locations and render the image
            //I'm really upset about this........ but here we are creating a new
            pShipSplat.PosX(pObject.x);
            pShipSplat.PosY(pObject.y);
            pShipSplat.Update();

            SpriteBatch pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);

            pSB_Aliens.Attach(pShipSplat);

            TimerMan.Add(TimeEvent.Name.SplatAnim, new SplatAnim(pShipSplat, pSB_Aliens), 0.5f);
        }
Exemple #20
0
        public override void Execute()
        {
            // Let the gameObject deal with this...
            //this.pAlien.Remove();

            GameObject pA = (GameObject)this.pUFO;
            GameObject pB = (GameObject)Iterator.GetParent(pA);

            pA.Remove();

            // TODO:  update score - may need a better way (maybe an observer)
            SceneContext sc = SceneContext.GetInstance();

            sc.GetState().UpdateScore(this.pUFO.GetScore());

            // TODO: Splat Alien - needs a better way
            this.pSplat = new Splat(GameObject.Name.Splat, GameSprite.Name.SplatUFO, pUFO.x, pUFO.y);
            pSplat.ActivateCollisionSprite(this.pSB_Boxes);
            pSplat.ActivateGameSprite(this.pSB_Aliens);

            GameObject pSplatbRoot = GameObjectMan.Find(GameObject.Name.SplatRoot);

            Debug.Assert(pSplatbRoot != null);
            pSplatbRoot.Add(pSplat);

            TimerMan.Add(TimeEvent.Name.SplatRemoveUFO, new SplatRemoveEvent(this.pSplat), 0.5f);
        }
Exemple #21
0
        public static void Update(float totalTime)
        {
            TimerMan pMan = TimerMan.privGetInstance();

            Debug.Assert(pMan != null);

            pMan.mCurrTime = totalTime;

            TimeEvent pEvent     = (TimeEvent)pMan.baseGetActive();
            TimeEvent pNextEvent = null;

            while (pEvent != null)// && (pMan.mCurrTime >= pEvent.triggerTime))
            {
                pNextEvent = (TimeEvent)pEvent.pNext;

                if (pMan.mCurrTime >= pEvent.triggerTime)
                {
                    pEvent.Process();

                    pMan.baseRemove(pEvent);
                }

                pEvent = pNextEvent;
            }
        }
        override public void Execute(float deltaTime)
        {
            this.pUFO = new UFO(GameObject.Name.UFO, GameSprite.Name.UFO, -20, 530);
            Debug.Assert(this.pUFO != null);
            pUFO.ActivateCollisionSprite(this.pSB_Boxes);
            pUFO.ActivateGameSprite(this.pSB_Aliens);

            pUFO.animate = true;

            SwapDirection();

            // Attach the missile to the Bomb root
            GameObject pUFORoot = GameObjectMan.Find(GameObject.Name.UFORoot);

            Debug.Assert(pUFORoot != null);

            // Add to GameObject Tree - {update and collisions}
            pUFORoot.Add(pUFO);

            // Add timer event UFO Tempo
            UFOTempoEvent pUFOTempo = new UFOTempoEvent(pUFO);

            pUFOTempo.Attach(SoundEngine.Name.UFO_HighPitch);
            TimerMan.Add(TimeEvent.Name.UFOSoundTempo, pUFOTempo, 0.5f);

            // Add timer event
            TimerMan.Add(TimeEvent.Name.UFORandom, this, pRandom.Next(8, 25));

            // Add timer event for UFO Bombs
            TimerMan.Add(TimeEvent.Name.BombRandomUFO, new BombSpawnEvent(pRandom, pUFO), pRandom.Next(1, 4));
        }
        public override void Notify()
        {
            Bomb pBomb = null;

            if (this.pSubject.pObjA.name == GameObject.Name.Bomb)
            {
                pBomb = (Bomb)this.pSubject.pObjA;
            }
            else if (this.pSubject.pObjB.name == GameObject.Name.Bomb)
            {
                pBomb = (Bomb)this.pSubject.pObjB;
            }

            Debug.Assert(pBomb != null);

            pBomb.Reset();

            pBomb.Remove();

            if (showSplat == true)
            {
                // TODO: Splat Alien - needs a better way
                this.pSplat = new Splat(GameObject.Name.Splat, GameSprite.Name.SplatBomb, pBomb.x, pBomb.y);
                pSplat.ActivateCollisionSprite(this.pSB_Boxes);
                pSplat.ActivateGameSprite(this.pSB_Aliens);

                GameObject pSplatbRoot = GameObjectMan.Find(GameObject.Name.SplatRoot);
                Debug.Assert(pSplatbRoot != null);
                pSplatbRoot.Add(pSplat);

                TimerMan.Add(TimeEvent.Name.SplatRemoveBomb, new SplatRemoveEvent(this.pSplat), 0.5f);
            }
        }
Exemple #24
0
        public static void DumpTimeEvents()
        {
            TimerMan pTMan = TimerMan.PrivGetInstance();

            Debug.Assert(pTMan != null);

            pTMan.BaseDumpNodes();
        }
Exemple #25
0
        public static void StatDump()
        {
            TimerMan pTMan = TimerMan.PrivGetInstance();

            Debug.Assert(pTMan != null);

            pTMan.BaseStatDump();
        }
        //----------------------------------------------------------------------
        // Override Abstract methods
        //----------------------------------------------------------------------
        public override void execute(float deltaTime)
        {
            // move the grid
            ((AlienGroup)this.pGameObj).MoveGrid();

            // add itself back to TimerMan
            TimerMan.Add(TimeEvent.Name.MovementAnimation, this, deltaTime);
        }
Exemple #27
0
        public static void Create(int reserveNum = 3, int reserveGrow = 1)
        {
            Debug.Assert(reserveNum > 0);
            Debug.Assert(reserveGrow > 0);
            Debug.Assert(pInstance == null);

            pInstance = new TimerMan(reserveNum, reserveGrow);
        }
Exemple #28
0
        //----------------------------------------------------------------------
        // Override Abstract methods
        //----------------------------------------------------------------------
        public override void execute(float deltaTime)
        {
            // move the grid
            ((AlienGroup)this.pGameObj).dropBomb();

            // add itself back to TimerMan
            TimerMan.Add(TimeEvent.Name.DropBombAnination, this, deltaTime);
        }
Exemple #29
0
        public static void Dump()
        {
            TimerMan pMan = TimerMan.PrivGetInstance();

            Debug.Assert(pMan != null);

            pMan.BaseDump();
        }
Exemple #30
0
        public override void execute(float deltaTime)
        {
            UFOMan.ActiveUFO();
            SoundMan.Play("ufo_lowpitch.wav");
            UfOBomb pUFOBomb = new UfOBomb();

            TimerMan.Add(TimeEvent.Name.UFOBombAnination, pUFOBomb, UFOMan.getShootTime());
        }