public virtual void Remove(SpriteBatch.Name gameObjSpriteBatch, SpriteBatch.Name collisionBoxSpriteBatch) { // Very difficult at first... if you are messy, you will pay here! // Given a game object.... // Since the Root object is being drawn // 1st set its size to zero this.pCollisionObject.GetCollisionRect().Set(0, 0, 0, 0); this.Update(); // Update the parent GameObject pParent = (GameObject)this.pParent; if (pParent != null) { pParent.Update(); } // Remove from SpriteBatch GameStateManager.GetGame().GetStateSpriteBatchManager().Find(gameObjSpriteBatch).Detach(pSpriteProxy); GameStateManager.GetGame().GetStateSpriteBatchManager().Find(collisionBoxSpriteBatch).Detach(pCollisionObject.GetCollisionSpriteBox()); // Remove from GameObjectManager GameStateManager.GetGame().GetStateGameObjectManager().Detach(this); // Attach to GhostManager for later use GameStateManager.GetGame().GetStateGhostManager().Attach(this); // Reset death flag this.markedForDeath = false; }
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 override void Notify() { //Debug.WriteLine("Shoot Observer"); CoreCannon pShip = GameStateManager.GetGame().GetStateCoreCannonManager().GetShip(); pShip.ShootMissile(); }
public override void Notify() { Debug.WriteLine("PlayerDeathObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB); Player pPlayer = GameStateManager.GetGame().GetPlayer(playerName); // Decrement life count pPlayer.LoseLife(); // Update Life count display Font pPlayerLives = FontManager.Find(livesFont); Debug.Assert(pPlayerLives != null); pPlayerLives.UpdateMessage("LIVES " + pPlayer.GetNumLives().ToString()); // Remove CoreCannon GameObject pCoreCannon = GameStateManager.GetGame().GetStateGameObjectManager().Find(GameObject.Name.CoreCannon); if (!pCoreCannon.IsMarkedForDeath()) { pCoreCannon.MarkForDeath(); // Delay - remove object later PlayerDeathObserver pObserver = new PlayerDeathObserver(this); GameStateManager.GetGame().GetStateDelayedObjectManager().Attach(pObserver); } // Set State Change Flag GameStateManager.GetGame().SetStateChangeFlag(true); }
public override void Notify() { //Debug.WriteLine("RemoveMissileObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB); if (this.pSubject.pObjA.GetType() == typeof(Missile)) { this.pMissile = (Missile)this.pSubject.pObjA; } else { this.pMissile = (Missile)this.pSubject.pObjB; } //Debug.WriteLine("MissileRemoveObserver: --> delete missile {0}", pMissile); if (!pMissile.IsMarkedForDeath()) { pMissile.MarkForDeath(); // Delay - remove object later RemoveMissileObserver pObserver = new RemoveMissileObserver(this); GameStateManager.GetGame().GetStateDelayedObjectManager().Attach(pObserver); } }
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 Notify() { //Debug.WriteLine("Move Right"); CoreCannon pCoreCannon = GameStateManager.GetGame().GetStateCoreCannonManager().GetShip(); pCoreCannon.MoveRight(); }
public override void Handle(SpaceInvaders pGame) { bool isTwoPlayer = GameStateManager.GetGame().IsTwoPlayerMode(); Player pPlayer1 = GameStateManager.GetGame().GetPlayer(Player.Name.Player1); if (isTwoPlayer) { // Two-Player Mode if (pPlayer1.GetNumLives() < 1) { // Update HiScore this.UpdateHiScore(pGame, pPlayer1.GetPoints()); } // Switch to player 2 this.SwitchState(pGame, GameStateManager.GameState.Player2); } else { // One-Player Mode if (pPlayer1.GetNumLives() < 1) { // Update HiScore this.UpdateHiScore(pGame, pPlayer1.GetPoints()); // Go to End state this.SwitchState(pGame, GameStateManager.GameState.End); } } }
public override void Execute(float deltaTime) { GhostManager pGhostManager = GameStateManager.GetGame().GetStateGhostManager(); GameObjectManager pGameObjectManager = GameStateManager.GetGame().GetStateGameObjectManager(); SpriteBatchManager pSpriteBatchManager = GameStateManager.GetGame().GetStateSpriteBatchManager(); Composite pCoreCannonGroup = GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.CoreCannonGroup); GameObject pGameObj = pGhostManager.Find(GameObject.Name.CoreCannon); // Remove game object from ghost manager pGhostManager.Detach(pGameObj); // Reset position pGameObj.SetX(200); pGameObj.SetY(100); // Reset Collision Object Azul.Rect pSpriteProxyScreenRect = pGameObj.GetSpriteProxy().GetSpriteScreenRect(); CollisionObject pCollisionObject = pGameObj.GetCollisionObject(); pCollisionObject.GetCollisionRect().Set(pSpriteProxyScreenRect); pCollisionObject.GetCollisionSpriteBox().Set(SpriteBox.Name.Box, 200, 100, pSpriteProxyScreenRect.width, pSpriteProxyScreenRect.height); // Add to GameObjectManager Debug.Assert(pGameObj != null); pGameObjectManager.Attach(pGameObj); // Add to Composite pCoreCannonGroup.Add(pGameObj); // Attach to SpriteBatch pGameObj.ActivateSprite(pSpriteBatchManager.Find(SpriteBatch.Name.CoreCannon)); pGameObj.ActivateCollisionSprite(pSpriteBatchManager.Find(SpriteBatch.Name.CollisionBox)); }
//----------------------------------------------------------------------------- // Game::Update() // Called once per frame, update data, tranformations, etc // Use this function to control process order // Input, AI, Physics, Animation, and Graphics //----------------------------------------------------------------------------- public override void Update() { // Sound Engine update - keeps everything moving and updating smoothly SoundEngineManager.GetSoundEngine().Update(); // Input InputManager.Update(); // Fire off the timer events TimerManager.Update(GameStateManager.GetGame().GetTime()); // Update all objects this.pGameObjectManager.Update(); // Process Collisions CollisionPairManager.Process(); // Delete any objects here this.pDelayedObjectManager.Process(); // Chage State if flag is true if (this.changeState) { this.Handle(GameStateManager.GetGame()); this.changeState = false; } }
public static GameObject RecreateAlienGrid(AlienGrid pAlienGrid, float startingGridSpeed, float start_x = 0.0f, float start_y = 0.0f) { GhostManager pGhostManager = GameStateManager.GetGame().GetStateGhostManager(); GameObjectManager pGameObjectManager = GameStateManager.GetGame().GetStateGameObjectManager(); // Attach Composite objects Composite pCol; for (int i = 0; i < 11; i++) { pCol = (Composite)pGhostManager.Find(GameObject.Name.AlienGridColumn); pGhostManager.Detach(pCol); pGameObjectManager.Attach(pCol); // Recreate Aliens & Attach to Column RecreateAlienGridColumn(pCol, (start_x + (60.0f * i)), start_y); // Append Columns to AlienGrid pAlienGrid.Add(pCol); } // Add Initial AlienGridMovement Event AlienGridMovement pAlienGridMovement = new AlienGridMovement(pAlienGrid); GameStateManager.GetGame().GetStateQueuedTimeEventManager().Enqueue(TimeEvent.Name.AlienGridMovement, pAlienGridMovement, startingGridSpeed); return(pAlienGrid); }
private void CleanPlayerState(Player.Name playerToClean) { // Clean player Player cleanPlayer = new Player(playerToClean); GameStateManager.GetGame().SetPlayer(playerToClean, cleanPlayer); //Find Player Points Font Font.Name pointsFont = Font.Name.Uninitialized; Font.Name livesFont = Font.Name.Uninitialized; switch (playerToClean) { case Player.Name.Player1: pointsFont = Font.Name.Player1Score; livesFont = Font.Name.Player1Lives; break; case Player.Name.Player2: pointsFont = Font.Name.Player2Score; livesFont = Font.Name.Player2Lives; break; } // Update Points display Font pPlayerScoreFont = FontManager.Find(pointsFont); Debug.Assert(pPlayerScoreFont != null); pPlayerScoreFont.UpdateMessage(cleanPlayer.GetPoints().ToString("D4")); // Update Lives display Font pPlayerLivesFont = FontManager.Find(livesFont); Debug.Assert(pPlayerLivesFont != null); pPlayerLivesFont.UpdateMessage("LIVES " + cleanPlayer.GetNumLives().ToString()); }
public static GameObject CreateAlienGrid(float start_x = 0.0f, float start_y = 0.0f) { // Create Composite objects Composite pAlienGrid = new AlienGrid(Composite.CompositeName.AlienGrid, 20.0f, 0.0f); pAlienGrid.SetCollisionObjectLineColor(1.0f, 1.0f, 0.0f); pAlienGrid.ActivateSprite(GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.Alien)); pAlienGrid.ActivateCollisionSprite(GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.CollisionBox)); GameStateManager.GetGame().GetStateCompositeManager().Attach(pAlienGrid); GameStateManager.GetGame().GetStateGameObjectManager().Attach(pAlienGrid); Composite pCol; for (int i = 0; i < 11; i++) { pCol = new AlienGridColumn(Composite.CompositeName.AlienCol1 + i); GameStateManager.GetGame().GetStateGameObjectManager().Attach(pCol); // Generate Aliens & Attach to Column GenerateNewAlienGridColumn(pCol, (start_x + (60.0f * i)), start_y); // Append Columns to AlienGrid pAlienGrid.Add(pCol); } // Add Initial AlienGridMovement Event AlienGridMovement pAlienGridMovement = new AlienGridMovement(pAlienGrid); GameStateManager.GetGame().GetStateQueuedTimeEventManager().Enqueue(TimeEvent.Name.AlienGridMovement, pAlienGridMovement, GameStateManager.GetGame().GetStateLevelInitialAlienGridSpeed()); return(pAlienGrid); }
public CoreCannon ActivateCoreCannon() { // copy over safe copy CoreCannon pCoreCannon = new CoreCannon(GameObject.Name.CoreCannon, Sprite.Name.CoreCannon, 200, 100); this.pCoreCannon = pCoreCannon; // Attach to GameObjectManager - {update and collisions} GameStateManager.GetGame().GetStateGameObjectManager().Attach(pCoreCannon); // Attach the sprite to the correct sprite batch SpriteBatch pCoreCannon_SpriteBatch = GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.CoreCannon); SpriteBatch pCollisionBox_SpriteBatch = GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.CollisionBox); pCoreCannon.ActivateSprite(pCoreCannon_SpriteBatch); pCoreCannon.ActivateCollisionSprite(pCollisionBox_SpriteBatch); // Attach the Core Cannon to the CoreCannonGroup GameObject pCoreCannonGroup = GameStateManager.GetGame().GetStateGameObjectManager().Find(GameObject.Name.CoreCannonGroup); Debug.Assert(pCoreCannonGroup != null); // Add to Composite pCoreCannonGroup.Add(this.pCoreCannon); this.pCoreCannon.SetMissileState(CoreCannonManager.MissileState.Ready); this.pCoreCannon.SetMoveState(CoreCannonManager.MoveState.Free); return(this.pCoreCannon); }
public Missile ActivateMissile() { // copy over safe copy Missile pMissile = new Missile(GameObject.Name.Missile, Sprite.Name.Missile, 400, 100); this.pMissile = pMissile; // Attach to GameObjectManager - {update and collisions} GameStateManager.GetGame().GetStateGameObjectManager().Attach(pMissile); // Attached to SpriteBatches SpriteBatch pMissile_SpriteBatch = GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.Missile); SpriteBatch pCollisionBox_SpriteBatch = GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.CollisionBox); pMissile.ActivateSprite(pMissile_SpriteBatch); pMissile.ActivateCollisionSprite(pCollisionBox_SpriteBatch); // Attach the missile to the missile root GameObject pMissileGroup = GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.MissileGroup); Debug.Assert(pMissileGroup != null); // Add to Composite pMissileGroup.Add(this.pMissile); return(this.pMissile); }
public MissileMovement(GameObject.Name gameObjectName, float deltaY) { // Find the sprite that the movement is attached to this.pGameObject = GameStateManager.GetGame().GetStateGameObjectManager().Find(gameObjectName); Debug.Assert(this.pGameObject != null); this.deltaY = deltaY; }
public void Recreate(Alien.Type type, float posX, float posY) { GameObject pGameObj = null; GhostManager pGhostManager = GameStateManager.GetGame().GetStateGhostManager(); GameObjectManager pGameObjectManager = GameStateManager.GetGame().GetStateGameObjectManager(); switch (type) { case Alien.Type.Crab: pGameObj = pGhostManager.Find(GameObject.Name.CrabAlien); break; case Alien.Type.FlyingSaucer: pGameObj = pGhostManager.Find(GameObject.Name.FlyingSaucer); break; case Alien.Type.JellyFish: pGameObj = pGhostManager.Find(GameObject.Name.JellyFishAlien); break; case Alien.Type.Squid: pGameObj = pGhostManager.Find(GameObject.Name.SquidAlien); break; default: // something is wrong Debug.Assert(false); break; } // Remove game object from ghost manager pGhostManager.Detach(pGameObj); // Reset position pGameObj.SetX(posX); pGameObj.SetY(posY); // Reset Collision Object Azul.Rect pSpriteProxyScreenRect = pGameObj.GetSpriteProxy().GetSpriteScreenRect(); CollisionObject pCollisionObject = pGameObj.GetCollisionObject(); pCollisionObject.GetCollisionRect().Set(pSpriteProxyScreenRect); pCollisionObject.GetCollisionSpriteBox().Set(SpriteBox.Name.Box, posX, posY, pSpriteProxyScreenRect.width, pSpriteProxyScreenRect.height); // Add to GameObjectManager Debug.Assert(pGameObj != null); pGameObjectManager.Attach(pGameObj); // Add to Composite pComposite.Add(pGameObj); // Attach to SpriteBatch pGameObj.ActivateSprite(this.pAlienSpriteBatch); pGameObj.ActivateCollisionSprite(this.pCollisionBoxSpriteBatch); }
public override void ExecuteDelayed() { // Let the gameObject deal with this... this.pMissile.Remove(SpriteBatch.Name.Missile, SpriteBatch.Name.CollisionBox); // Remove from MissileGroup Composite pMissileGroup = GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.MissileGroup); pMissileGroup.Remove(this.pMissile); }
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 ShieldFactory(SpriteBatch.Name spriteBatchName, SpriteBatch.Name collisionSpriteBatch, Composite pTree) { this.pSpriteBatch = GameStateManager.GetGame().GetStateSpriteBatchManager().Find(spriteBatchName); Debug.Assert(this.pSpriteBatch != null); this.pCollisionSpriteBatch = GameStateManager.GetGame().GetStateSpriteBatchManager().Find(collisionSpriteBatch); Debug.Assert(this.pCollisionSpriteBatch != null); Debug.Assert(pTree != null); this.pTree = pTree; }
public AlienFactory(SpriteBatch.Name alienSpriteBatchName, SpriteBatch.Name collisionBoxSpriteBatchName, Composite alienComposite) { this.pAlienSpriteBatch = GameStateManager.GetGame().GetStateSpriteBatchManager().Find(alienSpriteBatchName); Debug.Assert(this.pAlienSpriteBatch != null); this.pCollisionBoxSpriteBatch = GameStateManager.GetGame().GetStateSpriteBatchManager().Find(collisionBoxSpriteBatchName); Debug.Assert(this.pCollisionBoxSpriteBatch != null); Debug.Assert(alienComposite != null); this.pComposite = alienComposite; }
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 ShootMissile(CoreCannon pShip) { // Activate and position missile Missile pMissile = GameStateManager.GetGame().GetStateCoreCannonManager().ActivateMissile(); pMissile.SetPos(pShip.GetX(), pShip.GetY() + 20); pMissile.SetActive(true); // Play shoot sound IrrKlang.ISound pSnd = SoundEngineManager.GetSoundEngine().Play2D("shoot.wav"); // switch states this.Handle(pShip); }
private static void GenerateNewAlienGridColumn(Composite pCol, float x, float yStart, float yDelta = -40.0f) { pCol.ActivateSprite(GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.Alien)); pCol.ActivateCollisionSprite(GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.CollisionBox)); pCol.GetCollisionObject().GetCollisionSpriteBox().SetLineColor(1.0f, 1.0f, 1.0f); AlienFactory pAlienFactory = new AlienFactory(SpriteBatch.Name.Alien, SpriteBatch.Name.CollisionBox, pCol); pAlienFactory.Create(Alien.Type.Squid, x, yStart); pAlienFactory.Create(Alien.Type.Crab, x, yStart + (yDelta)); pAlienFactory.Create(Alien.Type.Crab, x, yStart + (yDelta * 2)); pAlienFactory.Create(Alien.Type.JellyFish, x, yStart + (yDelta * 3)); pAlienFactory.Create(Alien.Type.JellyFish, x, yStart + (yDelta * 4)); }
public override void ExecuteDelayed() { // Let the gameObjects deal with this... if (this.pAlien != null) { this.pAlien.Remove(SpriteBatch.Name.FlyingSaucer, SpriteBatch.Name.CollisionBox); } // Remove from Root Composite pFlyingSaucerRoot = GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.FlyingSaucerRoot); pFlyingSaucerRoot.Remove(this.pAlien); }
public override void Notify() { this.pAlien = (Alien)this.pSubject.pObjA; Player pPlayer = GameStateManager.GetGame().GetPlayer(playerName); // Add points pPlayer.AddPoints(pAlien.GetPoints()); // Update Points display Font pPlayer1ScoreFont = FontManager.Find(pointsFont); Debug.Assert(pPlayer1ScoreFont != null); pPlayer1ScoreFont.UpdateMessage(pPlayer.GetPoints().ToString("D4")); }
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)); } }
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); } }
public override void ExecuteDelayed() { // Let the gameObjects deal with this... GameObject pCoreCannon = GameStateManager.GetGame().GetStateGameObjectManager().Find(GameObject.Name.CoreCannon); // Remove from composite Composite pCoreCannonGroup = GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.CoreCannonGroup); pCoreCannonGroup.Remove(pCoreCannon); if (pCoreCannon != null) { pCoreCannon.Remove(SpriteBatch.Name.CoreCannon, SpriteBatch.Name.CollisionBox); } // Add Timer Event to restore CoreCannon TimerManager.Add(TimeEvent.Name.ResetCoreCannon, new ResetCoreCannonCommand(), 1.0f); }
public override void Handle(SpaceInvaders pGame) { if (!firstGame) { // Clean Player States for new game this.CleanPlayerState(Player.Name.Player1); this.CleanPlayerState(Player.Name.Player2); // Clean Game States for new game ResetGameCommand resetGame = new ResetGameCommand(); ResetCoreCannonCommand resetCannon = new ResetCoreCannonCommand(); // Reset Player1 State this.SwitchState(pGame, GameStateManager.GameState.Player1); resetGame.Execute(1.0f); GameStateManager.GetGame().SetStateLevelInitialAlienGridSpeed(GameStateManager.GetGame().GetGameInitialAlienGridSpeed()); GameStateManager.GetGame().SetStateLevelInitialAlienGridYPosition(GameStateManager.GetGame().GetGameInitialGridYPosition()); GameObject pCoreCannon = GameStateManager.GetGame().GetStateGhostManager().Find(GameObject.Name.CoreCannon); if (pCoreCannon != null) { resetCannon.Execute(1.0f); } // Reset Player2 State this.SwitchState(pGame, GameStateManager.GameState.Player2); resetGame.Execute(1.0f); GameStateManager.GetGame().SetStateLevelInitialAlienGridSpeed(GameStateManager.GetGame().GetGameInitialAlienGridSpeed()); GameStateManager.GetGame().SetStateLevelInitialAlienGridYPosition(GameStateManager.GetGame().GetGameInitialGridYPosition()); pCoreCannon = GameStateManager.GetGame().GetStateGhostManager().Find(GameObject.Name.CoreCannon); if (pCoreCannon != null) { resetCannon.Execute(1.0f); } } else { // Set new game flag to false this.firstGame = false; } this.SwitchState(pGame, GameStateManager.GameState.Player1); }