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(); }
protected override DLink DerivedCreateNode() { DLink pNode = new QueuedTimeEvent(); Debug.Assert(pNode != null); return(pNode); }
public void Enqueue(TimeEvent.Name inEventName, Command inCommand, float inTimeDelta) { QueuedTimeEvent pQueuedTimeEvent = (QueuedTimeEvent)BaseAdd(); Debug.Assert(pQueuedTimeEvent != null); // Initialize QTE pQueuedTimeEvent.Set(inEventName, inCommand, inTimeDelta); }
public QueuedTimeEvent Dequeue() { QueuedTimeEvent pNode = (QueuedTimeEvent)this.pActive; if (pNode != null) { BaseRemove(pNode); } // TODO Will this algorithm wipe the QTE before it is returned? // If so, may need to make a copy before wiping and return that? return(pNode); }
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); // Load Time Events into TimerManager QueuedTimeEvent qte = pGame.GetStateQueuedTimeEventManager().Dequeue(); while (qte != null) { TimerManager.Add(qte.GetTimeEventName(), qte.GetCommand(), qte.GetTimeEventDelta()); qte = pGame.GetStateQueuedTimeEventManager().Dequeue(); } }
protected override void DerivedDestroyNode(DLink pLink) { QueuedTimeEvent pQueuedTimeEvent = (QueuedTimeEvent)pLink; pQueuedTimeEvent.Set(TimeEvent.Name.Uninitialized, null, -1.0f); }