示例#1
0
        public override void Execute(float deltaTime)
        {
            // TODO add parameters for border edges [Left, Right, Top, Bottom] for when to reset movement
            // TODO Probably need to create sub-commands for different types of movement?

            spriteProxyRect      = this.pGameObject.GetSpriteProxy().GetSpriteScreenRect();
            spriteProxyHalfWidth = spriteProxyRect.width / 2.0f;

            // + ( (deltaX > 0.0f) ? spriteProxyHalfWidth : (-1.0f * spriteProxyHalfWidth))
            this.currX = this.pGameObject.GetX() + this.deltaX;
            this.currY = this.pGameObject.GetY() + this.deltaY;

            // If past window edge, change directions
            if ((this.currX + spriteProxyHalfWidth) > 896.0f)
            {
                deltaX = (-1.0f * deltaX);
                currX  = 896.0f - spriteProxyHalfWidth;
            }
            else if ((this.currX + -(spriteProxyHalfWidth)) < 0.0f)
            {
                deltaX = (-1.0f * deltaX);
                currX  = 0.0f + spriteProxyHalfWidth;
            }

            // Update X, Y in Sprite
            this.pGameObject.SetX(this.currX);
            this.pGameObject.SetY(this.currY);

            // Add itself back to timer
            TimerManager.Add(TimeEvent.Name.SpriteMovement, this, deltaTime);
        }
        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());
            }

        }
        public static void Reset()
        {
            // Get the instance
            TimerManager pMan = TimerManager.pActiveMan;

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


            while (pEvent != null)
            {
                // 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;
                TimerManager.poNodeCopy.Set(pEvent.GetName(), pEvent.GetCommand(), pEvent.deltaTime);

                TimerManager.Remove(pEvent);
                TimerManager.Add(TimerManager.poNodeCopy.GetName(), TimerManager.poNodeCopy.GetCommand(), TimerManager.poNodeCopy.deltaTime);


                pEvent = pNextEvent;
            }
        }
示例#4
0
        public override void Execute(float deltaTime)
        {
            int bombStyle = pRandom.Next(0, 3);

            GameObject pUFO = (GameObject)this.pGridHead.poHead;

            Bomb pBomb;

            if (pUFO.isDead == false)
            {
                switch (bombStyle)
                {
                case 0:
                    pBomb = BombManager.GetZigZagFall(pUFO.x, pUFO.y);
                    break;

                case 1:
                    pBomb = BombManager.GetStraightFall(pUFO.x, pUFO.y);
                    break;

                case 2:
                    pBomb = BombManager.GetCrossFall(pUFO.x, pUFO.y);
                    break;

                default:
                    Debug.Assert(false);
                    break;
                }
            }
            float nextDeltaTime = pRandom.Next(2, 4);

            TimerManager.Add(TimeEvent.Name.SpawnBomb, this, nextDeltaTime);
        }
示例#5
0
 public override void Update()
 {
     if (GameManager.GetGame().GetState() is GameActiveState)
     {
         GameObject ship = ShipManager.GetShip();
         if (ship != null)
         {
             ship.Remove();
             GameObject pShipRoot = GameObjectManager.Find(GameObjectName.ShipRoot);
             pShipRoot.Remove();
         }
         Alien       pExplosion = new Explosion(GameObjectName.Explosion, SpriteBaseName.Explosion, AlienType.Explosion, ship, ColorName.Green, 0);
         SpriteBatch sbAliens   = SpriteBatchManager.Find(SpriteBatchName.Aliens);
         SpriteBatch sbBoxes    = SpriteBatchManager.Find(SpriteBatchName.Boxes);
         pExplosion.ActivateGameSprite(sbAliens);
         pExplosion.ActivateCollisionSprite(sbBoxes);
         GameObjectManager.AttachTree(pExplosion);
         Game pGame = GameManager.GetGame();
         pGame.roundNum = 1;
         ScoreManager.ClearLives();
         TimerManager.ClearTimerManager();
         pExplosion.Remove();
         pGame.Die();
         TimerManager.Add(TimerEventName.GameStart, TimerManager.GetCurrentTime() + 10.0f, 10.0f, new GameStartEvent(pGame));
     }
 }
示例#6
0
        public static void InitializeTimerManager()
        {
            Grid            pGrid            = (Grid)GameObjectManager.Find(GameObjectName.Grid);
            float           marchSpeed       = pGrid.marchSpeed;
            AnimationSprite animSpriteSquids = new AnimationSprite(SpriteBaseName.Squid);

            animSpriteSquids.Attach(ImageName.SquidA);
            animSpriteSquids.Attach(ImageName.SquidB);
            AnimationSprite animSpriteCrabs = new AnimationSprite(SpriteBaseName.Crab);

            animSpriteCrabs.Attach(ImageName.CrabA);
            animSpriteCrabs.Attach(ImageName.CrabB);
            AnimationSprite animSpriteOctopi = new AnimationSprite(SpriteBaseName.Octopus);

            animSpriteOctopi.Attach(ImageName.OctopusA);
            animSpriteOctopi.Attach(ImageName.OctopusB);
            SoundCommand playFastInvader1 = new SoundCommand(SoundName.fastInvader1);
            SoundCommand playFastInvader2 = new SoundCommand(SoundName.fastInvader2);
            SoundCommand playFastInvader3 = new SoundCommand(SoundName.fastInvader3);
            SoundCommand playFastInvader4 = new SoundCommand(SoundName.fastInvader4);

            TimerManager.Add(TimerEventName.MoveGrid, GetCurrentTime() + marchSpeed, marchSpeed, new MoveGridEvent());
            TimerManager.Add(TimerEventName.AnimateSquids, GetCurrentTime() + marchSpeed, marchSpeed, animSpriteSquids);
            TimerManager.Add(TimerEventName.AnimateCrabs, GetCurrentTime() + marchSpeed, marchSpeed, animSpriteCrabs);
            TimerManager.Add(TimerEventName.AnimateOctopi, GetCurrentTime() + marchSpeed, marchSpeed, animSpriteOctopi);
            TimerManager.Add(TimerEventName.PlayFastInvaders4, GetCurrentTime() + marchSpeed, 4 * marchSpeed, playFastInvader4);
            TimerManager.Add(TimerEventName.PlayFastInvaders1, GetCurrentTime() + 2 * marchSpeed, 4 * marchSpeed, playFastInvader1);
            TimerManager.Add(TimerEventName.PlayFastInvaders2, GetCurrentTime() + 3 * marchSpeed, 4 * marchSpeed, playFastInvader2);
            TimerManager.Add(TimerEventName.PlayFastInvaders3, GetCurrentTime() + 4 * marchSpeed, 4 * marchSpeed, playFastInvader3);
            TimerManager.Add(TimerEventName.BombSpawn, GetCurrentTime() + marchSpeed, pGrid.bombFrequency, new BombSpawnEvent(pGrid));
            TimerManager.Add(TimerEventName.UFOSpawn, GetCurrentTime() + (float)random.Next(5, 10), (float)random.Next(5, 10), new UFOSpawnEvent());
        }
示例#7
0
 public override void Notify()
 {
     if (ScenePlay.ShipLives == 1 || (ScenePlay2.ShipLives > 0 && SpaceInvaders.Player1Mode == false))
     {
         TimerManager.Add(TimeEvent.Name.SwitchState, this.pEvent, 1.4f);
     }
 }
        //command pattern for delayed manager
        public override void Execute()
        {
            // Let the gameObject deal with this...
            this.pShip.pProxySprite.Set(GameSprite.Name.ShipExplosion);
            Ship pShipCopy = (Ship)this.pShip;

            pShipCopy.SetState(ShipManager.State.Dead);

            SwapShipExplosionEvent pSwapEvent  = new SwapShipExplosionEvent(Image.Name.ShipExplosionA); //move to ship manager?
            SwapShipExplosionEvent pSwapEvent2 = new SwapShipExplosionEvent(Image.Name.ShipExplosionB); //move to ship manager?


            TimerManager.Add(TimeEvent.Name.SwapShipExplosion, pSwapEvent2, 0.2f);
            TimerManager.Add(TimeEvent.Name.SwapShipExplosion, pSwapEvent, 0.4f);
            TimerManager.Add(TimeEvent.Name.SwapShipExplosion, pSwapEvent2, 0.6f);
            TimerManager.Add(TimeEvent.Name.SwapShipExplosion, pSwapEvent, 0.8f);
            TimerManager.Add(TimeEvent.Name.SwapShipExplosion, pSwapEvent2, 1.0f);
            TimerManager.Add(TimeEvent.Name.SwapShipExplosion, pSwapEvent, 1.2f);



            ResetShipEvent pEvent = new ResetShipEvent();//move to ship manager?

            TimerManager.Add(TimeEvent.Name.RemoveShip, pEvent, 1.4f);
        }
示例#9
0
        public void SwitchState(SpaceInvaders pGame, GameStateManager.GameState nextState)
        {
            // Detach current state input observers
            pGame.DetachStateInputObservers();

            // Queue any Time Events for later
            TimeEvent pTimeEvent = TimerManager.Pop();

            while (pTimeEvent != null)
            {
                this.GetQueuedTimeEventManager().Enqueue(pTimeEvent.GetName(), pTimeEvent.GetCommand(), pTimeEvent.GetDeltaTime());
                pTimeEvent = TimerManager.Pop();
            }

            // Change game state
            pGame.SetGameState(nextState);

            // Load up TimerManager with next state's Time Events
            QueuedTimeEvent qte = pGame.GetStateQueuedTimeEventManager().Dequeue();

            while (qte != null)
            {
                TimerManager.Add(qte.GetTimeEventName(), qte.GetCommand(), qte.GetTimeEventDelta());

                // Get next queued event
                qte = pGame.GetStateQueuedTimeEventManager().Dequeue();
            }

            // Attach next state input observers
            pGame.AttachStateInputObservers();
        }
示例#10
0
        public override void Execute(float deltaTime)
        {
            // advance to next image
            ImageHolder pImageHolder = (ImageHolder)this.pCurrentImage.pNext;

            if (pImageHolder != null)
            {
                // squirrel away for next timer event
                this.pCurrentImage = pImageHolder;

                // change image
                this.pSprite.SwapImage(pImageHolder.pImage);

                // Add itself back to timer
                TimerManager.Add(this.name, this, deltaTime);
            }
            else
            {
                // if at end of list dont add back to timer
                //this.pSprite.GetSBNode().GetSBNodeMan().Remove(this.pSprite.GetSBNode());
                this.pSprite.x = -50;
                this.pSprite.y = -50;
                this.pSprite.Update();
                this.pSprite = null;
            }
        }
示例#11
0
        public override void execute(float currentTime)
        {
            AnimationSprite animSpriteSquids = new AnimationSprite(SpriteBaseName.Squid);

            animSpriteSquids.Attach(ImageName.SquidA);
            animSpriteSquids.Attach(ImageName.SquidB);
            AnimationSprite animSpriteCrabs = new AnimationSprite(SpriteBaseName.Crab);

            animSpriteCrabs.Attach(ImageName.CrabA);
            animSpriteCrabs.Attach(ImageName.CrabB);
            AnimationSprite animSpriteOctopi = new AnimationSprite(SpriteBaseName.Octopus);

            animSpriteOctopi.Attach(ImageName.OctopusA);
            animSpriteOctopi.Attach(ImageName.OctopusB);
            SoundCommand playFastInvader1 = new SoundCommand(SoundName.fastInvader1);
            SoundCommand playFastInvader2 = new SoundCommand(SoundName.fastInvader2);
            SoundCommand playFastInvader3 = new SoundCommand(SoundName.fastInvader3);
            SoundCommand playFastInvader4 = new SoundCommand(SoundName.fastInvader4);
            Grid         pGrid            = (Grid)GameObjectManager.Find(GameObjectName.Grid);
            float        marchSpeed       = pGrid.marchSpeed;
            float        bombFrequency    = pGrid.bombFrequency;

            TimerManager.Dump();
            TimerManager.Add(TimerEventName.MoveGrid, marchSpeed, marchSpeed, new MoveGridEvent());
            TimerManager.Add(TimerEventName.AnimateSquids, marchSpeed, marchSpeed, animSpriteSquids);
            TimerManager.Add(TimerEventName.AnimateCrabs, marchSpeed, marchSpeed, animSpriteCrabs);
            TimerManager.Add(TimerEventName.AnimateOctopi, marchSpeed, marchSpeed, animSpriteOctopi);
            TimerManager.Add(TimerEventName.PlayFastInvaders4, marchSpeed, 4 * marchSpeed, playFastInvader4);
            TimerManager.Add(TimerEventName.PlayFastInvaders1, 2 * marchSpeed, 4 * marchSpeed, playFastInvader1);
            TimerManager.Add(TimerEventName.PlayFastInvaders2, 3 * marchSpeed, 4 * marchSpeed, playFastInvader2);
            TimerManager.Add(TimerEventName.PlayFastInvaders3, 4 * marchSpeed, 4 * marchSpeed, playFastInvader3);
            TimerManager.Add(TimerEventName.BombSpawn, bombFrequency, bombFrequency, new BombSpawnEvent(pGrid));
            TimerManager.Add(TimerEventName.UFOSpawn, TimerManager.GetCurrentTime() + (float)UFOManager.GetRandom().Next(5, 10), (float)UFOManager.GetRandom().Next(5, 10), new UFOSpawnEvent());
        }
示例#12
0
        public override void Notify()
        {
            //Debug.WriteLine("Grid_Observer: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);

            // OK do some alphabetic magic
            AlienGrid    pGrid = (AlienGrid)this.pSubject.pObjA;
            WallCategory pWall = (WallCategory)this.pSubject.pObjB;


            if (pWall.GetCategoryType() == WallCategory.Type.Right)
            {
                // Was set true in the collision

                if (pGrid.GetIsOnWall())
                {
                    Debug.WriteLine("---- Hiding : Wall Hit");
                    TimerManager.Add(TimeEvent.Name.HideUFO, new HideUFO(pGrid), pGrid.movementTimeInterval);
                }
            }
            else if (pWall.GetCategoryType() == WallCategory.Type.Left)
            {
                // Was set true in the collision

                if (pGrid.GetIsOnWall())
                {
                    Debug.WriteLine("---- Hiding : Wall Hit");
                    TimerManager.Add(TimeEvent.Name.HideUFO, new HideUFO(pGrid), pGrid.movementTimeInterval);
                }
            }

            else
            {
                Debug.Assert(false);
            }
        }
示例#13
0
        //----------------------------------------------------------------------------------
        // Private Methods
        //----------------------------------------------------------------------------------
        private void DropBomb()
        {
            // Assumes all the columns are there
            int columns = this.CountChildren();

            // Generate random # to access bomb dropping frequency
            float bombFrequency = ((float)this.pBombProb.Next(1, 1000000)) / 1000000.0f;
            float bombThreshold = ((float)columns) * 0.090909f;


            Debug.WriteLine("{0} : {1} < {2}", bombFrequency <= bombThreshold, bombFrequency, bombThreshold);
            // Only drop a bomb if we have an active column in the grid
            // Only fire if your random number is within the bomb threshold
            // corrects problem of dropping too many bombs with fewer columns

            if (columns > 0 && bombFrequency <= bombThreshold)
            {
                int columnSelected = this.pBombProb.Next(1, columns + 1);
                //Debug.WriteLine("column {0} of {1} was selected...", columnSelected, columns);

                Component pColumn = this.GetNthChild(columnSelected);

                float xMin = (float)((GameObject)pColumn).x;
                float yMin = ((GameObject)pColumn).y - 0.5f * ((GameObject)pColumn).poCollObj.poColRect.height;
                //Debug.WriteLine("({0}, {1})", xMin, yMin);

                TimerManager.Add(TimeEvent.Name.DropBomb, new DropBomb(xMin, yMin), 0.5f * this.movementTimeInterval);
            }
        }
示例#14
0
        public override void Update()
        {
            GameObject gameObjectA = this.pSubject.goA;
            GameObject gameObjectB = this.pSubject.goB;
            GameObject go          = Missile.GetNonMissile(gameObjectA, gameObjectB);
            ColorName  pColorName  = ColorName.White;

            if (go.gameObjectName == GameObjectName.Bomb)
            {
                pColorName = ColorName.Orange;
            }
            else if (go.gameObjectName == GameObjectName.UFO)
            {
                pColorName = ColorName.Red;
            }
            else if (go.gameObjectName == GameObjectName.UFOBomb)
            {
                pColorName = ColorName.Yellow;
            }
            Alien       pExplosion = new Explosion(GameObjectName.Splat, SpriteBaseName.Splat, AlienType.Splat, gameObjectB, pColorName, 0);
            SpriteBatch sbAliens   = SpriteBatchManager.Find(SpriteBatchName.Aliens);
            SpriteBatch sbBoxes    = SpriteBatchManager.Find(SpriteBatchName.Boxes);

            pExplosion.ActivateGameSprite(sbAliens);
            pExplosion.ActivateCollisionSprite(sbBoxes);
            GameObjectManager.AttachTree(pExplosion);
            TimerManager.Add(TimerEventName.RemoveGameObject, TimerManager.GetCurrentTime(), TimerManager.GetCurrentTime(), new RemoveGameObjectCommand(pExplosion));
        }
示例#15
0
 public override void Notify()
 {
     if (ScenePlay2.ShipLives == 1 || ScenePlay.ShipLives > 0)
     {
         TimerManager.Add(TimeEvent.Name.SwitchState, this.pEvent, 1.4f);
     }
 }
示例#16
0
        public override void Execute(float deltaTime)
        {
            Debug.Assert(this.pGameObject != null);
            ForwardIterator pFwdItor = new ForwardIterator(this.pGameObject);

            Component  pNode    = pFwdItor.First();
            GameObject pGameObj = (GameObject)pNode;

            // Move the first node before getting speed
            // just in case the move method changes the speed
            pGameObj.Move();

            float groupSpeedX = pGameObj.speedX;
            float groupSpeedY = pGameObj.speedY;

            pGameObj = (GameObject)pFwdItor.Next();
            while (!pFwdItor.IsDone())
            {
                // Apply group speed to every game object in the group.
                pGameObj.speedX = groupSpeedX;
                pGameObj.speedY = groupSpeedY;

                pGameObj.Move();

                pGameObj = (GameObject)pFwdItor.Next();
            }

            // Add itself back to timer
            TimerManager.Add(this.name, this, deltaTime);
        }
示例#17
0
        public override void Execute(float deltaTime)
        {
            Debug.Print("******************************************Debug TimerEvent: deltaTime = {0}", deltaTime);

            // Add itself back to timer
            TimerManager.Add(TimeEvent.Name.DebugCommand, this, deltaTime);
        }
示例#18
0
        private void SpawnUFO()
        {
            int random = UFOManager.GetRandom().Next(7, 10);

            this.pUFO = UFOManager.ActivateUFO(GameManager.GetCollisionBoxes());
            TimerManager.Add(TimerEventName.PlayUFOSound, TimerManager.GetCurrentTime() + 0.2f, 0.2f, new StartUFOSoundCommand());
            TimerManager.Add(TimerEventName.UFOSpawnBomb, TimerManager.GetCurrentTime() + (float)UFOManager.GetRandom().Next(1, 6), TimerManager.GetCurrentTime() + (float)UFOManager.GetRandom().Next(1, 6), new UFOBombSpawnEvent());
        }
示例#19
0
        //----------------------------------------------------------------------------------
        // Methods
        //----------------------------------------------------------------------------------

        public override void Execute(float deltaTime)
        {
            this.pAlienGrid.MoveGrid();
            //Debug.WriteLine("   ------ Moved Off Wall");
            this.pAlienGrid.SetIsOnWall(false);

            // Restart the movement process
            TimerManager.Add(TimeEvent.Name.MoveGrid, new MoveGrid(this.pAlienGrid), this.pAlienGrid.movementTimeInterval);
        }
示例#20
0
        public override void Execute()
        {
            // Let the gameObject deal with this...
            this.pAlien.pProxySprite.Set(GameSprite.Name.AlienExplosion);
            //add removal to timer event
            this.pEvent.SetAlien(this.pAlien);

            TimerManager.Add(TimeEvent.Name.RemoveAlien, this.pEvent, 0.5f);
        }
示例#21
0
        public override void Execute(float deltaTime)
        {
            this.pSound.PlaySound();

            if (this.pUFO.pProxySprite.pSprite.name != GameSprite.Name.NullObject)
            {
                TimerManager.Add(TimeEvent.Name.PlayUFOSound, this, deltaTime);
            }
        }
示例#22
0
        public override void Execute(float deltaTime)
        {
            DoAction();

            float multiplier = (float)this.pRandom.NextDouble();

            // Add itself back to timer
            TimerManager.Add(this.name, this, timeRange * multiplier);
        }
示例#23
0
        public void swarmAnimation(GameObject pAlienGrid)
        {
            GameObject pSwarmGrid = pAlienGrid;


            float   repeatInterval = ((AlienGrid)pSwarmGrid).movementTimeInterval;
            Command pMoveAlienGrid = new MoveGrid((AlienGrid)pSwarmGrid);
            //TimerManager.Add(TimeEvent.Name.MoveGrid, pMoveAlienGrid, repeatInterval);


            AnimationSprite pAnimatedAlien = new AnimationSprite(GameSprite.Name.Alien, (AlienGrid)pSwarmGrid);

            pAnimatedAlien.Attach(Image.Name.AlienA);
            pAnimatedAlien.Attach(Image.Name.AlienB);
            //TimerManager.Add(TimeEvent.Name.SpriteAnimation, pAnimatedAlien, repeatInterval);


            AnimationSprite pAnimatedSquid = new AnimationSprite(GameSprite.Name.Squid, (AlienGrid)pSwarmGrid);

            pAnimatedSquid.Attach(Image.Name.SquidA);
            pAnimatedSquid.Attach(Image.Name.SquidB);
            //TimerManager.Add(TimeEvent.Name.SpriteAnimation, pAnimatedSquid, repeatInterval);


            AnimationSprite pAnimatedOctopus = new AnimationSprite(GameSprite.Name.Octopus, (AlienGrid)pSwarmGrid);

            pAnimatedOctopus.Attach(Image.Name.OctopusA);
            pAnimatedOctopus.Attach(Image.Name.OctopusB);
            //TimerManager.Add(TimeEvent.Name.SpriteAnimation, pAnimatedOctopus, repeatInterval);



            PlaySound pAlienSoundCommand = new PlaySound((AlienGrid)pSwarmGrid);

            //Oscillates the sounds
            pAlienSoundCommand.Attach(Sound.Name.Fastinvader1);
            pAlienSoundCommand.Attach(Sound.Name.Fastinvader2);
            pAlienSoundCommand.Attach(Sound.Name.Fastinvader3);
            pAlienSoundCommand.Attach(Sound.Name.Fastinvader4);

            //TimerManager.Add(TimeEvent.Name.PlaySound, pAlienSoundCommand, repeatInterval);


            // Chaining all of the commands
            // Move, spites, and sound
            CommandChain pSwarmAnimate = new CommandChain();

            pSwarmAnimate.Attach(pMoveAlienGrid);
            pSwarmAnimate.Attach(pAnimatedAlien);
            pSwarmAnimate.Attach(pAnimatedSquid);
            pSwarmAnimate.Attach(pAnimatedOctopus);
            pSwarmAnimate.Attach(pAlienSoundCommand);
            TimerManager.Add(TimeEvent.Name.CommandChain, pSwarmAnimate, repeatInterval);
        }
示例#24
0
        //----------------------------------------------------------------------------------
        // Methods
        //----------------------------------------------------------------------------------

        public override void Execute(float deltaTime)
        {
            // Only move if you are not on the wall
            if (!this.pAlienGrid.GetIsOnWall())
            {
                this.pAlienGrid.MoveGrid();
                //Debug.WriteLine("   ------ Moved");

                TimerManager.Add(TimeEvent.Name.MoveGrid, this, this.pAlienGrid.movementTimeInterval);
            }
        }
示例#25
0
        public void RepopulateUFO()
        {
            GameObject pUFOGrid = GameObjectManager.Find(GameObject.Name.UFOGrid);

            Debug.Assert(pUFOGrid != null);
            GameObject pBoss = this.Create(GameObject.Name.Saucer, AlienCategory.Type.Saucer, 100.0f, 1100.0f);

            ((AlienGrid)pUFOGrid).SetMovementTimeInterval(0.5f);
            pUFOGrid.Add(pBoss);
            TimerManager.Add(TimeEvent.Name.SpawnUFO, new SpawnUFO((AlienGrid)pUFOGrid), 30.0f);
        }
示例#26
0
        public override void Execute(float deltaTime)
        {
            // Update X, Y in Component
            // Movement Deltas are now being handled in AlienGrid
            this.pComponent.Move(0.0f, 0.0f);

            Debug.Print("Adding AlienGridMovement ({0}) back to timer - Delta: {1}", this.GetHashCode(), GameStateManager.GetGame().GetStateAlienGridSpeed());

            // Add itself back to timer
            TimerManager.Add(TimeEvent.Name.AlienGridMovementSound, this, GameStateManager.GetGame().GetStateAlienGridSpeed());
        }
        public override void Execute(float deltaTime)
        {
            String pCurrSound;

            // Select sound
            switch (currSoundIndex)
            {
            case 0:
                pCurrSound = pFastInvader1;
                break;

            case 1:
                pCurrSound = pFastInvader2;
                break;

            case 2:
                pCurrSound = pFastInvader3;
                break;

            case 3:
                pCurrSound = pFastInvader4;
                break;

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

            // Play current sound
            IrrKlang.ISound pSnd = SoundEngineManager.GetSoundEngine().Play2D(pCurrSound);

            // Increment sound index
            if (currSoundIndex == 3)
            {
                this.currSoundIndex = 0;
            }
            else
            {
                this.currSoundIndex += 1;
            }

            // If there is still at least one alien
            if (GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.AlienGrid).GetFirstChild() != null)
            {
                Debug.Print("Adding GridMovementSound ({0}) back to timer - Delta: {1}", this.GetHashCode(), GameStateManager.GetGame().GetStateAlienGridSpeed());

                // Add itself back to timer
                TimerManager.Add(TimeEvent.Name.AlienGridMovementSound, this, GameStateManager.GetGame().GetStateAlienGridSpeed());
            }
        }
        public override void Execute(float deltaTime)
        {
            float NewTime = RandomManager.RandomInt(45, 61);

            UFORoot      pUFORoot = (UFORoot)GameObjectManager.Find(GameObject.Name.UFORoot);
            OrangeSaucer pUFO     = (OrangeSaucer)pUFORoot.GetFirstChild();

            pUFO.RandomizeDirection();

            // Add itself back to timer
            TimerManager.Add(TimeEvent.Name.UFOSpawn, this, NewTime);

            TimerManager.Add(TimeEvent.Name.PlayUFOSound, this.pSoundEvent, 0.17f);
        }
示例#29
0
        public override void Execute(float deltaTime)
        {
            int bombStyle = pRandom.Next(0, 3);
            int numCol    = 0;

            AlienColumn pColumn = (AlienColumn)this.pGridHead.poHead;

            while (pColumn != null)
            {
                numCol++;
                pColumn = (AlienColumn)pColumn.pNext;
            }
            int col = pRandom.Next(0, numCol);

            pColumn = (AlienColumn)this.pGridHead.poHead;
            while (col > 0)
            {
                col--;
                pColumn = (AlienColumn)pColumn.pNext;
            }

            if (pColumn != null)
            {
                GameObject pAlien = (GameObject)pColumn.poLast;
                Bomb       pBomb;
                switch (bombStyle)
                {
                case 0:
                    pBomb = BombManager.GetZigZagFall(pAlien.x, pAlien.y);
                    break;

                case 1:
                    pBomb = BombManager.GetStraightFall(pAlien.x, pAlien.y);
                    break;

                case 2:
                    pBomb = BombManager.GetCrossFall(pAlien.x, pAlien.y);
                    break;

                default:
                    Debug.Assert(false);
                    break;
                }
            }

            float nextDeltaTime = pRandom.Next(5, 20);

            nextDeltaTime /= 10;
            TimerManager.Add(TimeEvent.Name.SpawnBomb, this, nextDeltaTime);
        }
示例#30
0
        public override void Notify()
        {
            if (this.IsValidCollision())
            {
                if (this.isMissileHit == true)
                {
                    ExplosionManager.GetUFOExplosion(this.pUFO);
                }
                UFOManager.DeactiveUFO();

                float    time   = pRandom.Next(10, 16);
                SpawnUFO pSpawn = new SpawnUFO();
                TimerManager.Add(TimeEvent.Name.SpawnBomb, pSpawn, time);
            }
        }