static public void Process() { DelayedObjectManager pDelayMan = DelayedObjectManager.GetInstance(); CollisionObserver pNode = pDelayMan.head; while (pNode != null) { // Fire off listener pNode.Execute(); pNode = (CollisionObserver)pNode.pNext; } // remove pNode = pDelayMan.head; CollisionObserver pTmp = null; while (pNode != null) { pTmp = pNode; pNode = (CollisionObserver)pNode.pNext; // remove pDelayMan.Detach(pTmp, ref pDelayMan.head); } }
protected override void derivedUpdate(ColSubject pColSubject) { //Debug.WriteLine("ShipRemoveMissileObserver: {0} vs {1}", pColSubject.pObjA.name, pColSubject.pObjB.name); // Missle will always be pObjA GameObject pGameObjA = pColSubject.pObjA; GameObject pGameObjB = pColSubject.pObjB; Debug.Assert(pGameObjA != null); Debug.Assert(pGameObjB != null); Missile pMissile = null; if (pGameObjA.name == GameObject.Name.Missle) { pMissile = (Missile)pGameObjA; } else if (pGameObjB.name == GameObject.Name.Missle) { pMissile = (Missile)pGameObjB; } else { Debug.Assert(false, "Neither of the objects are Missle"); } if (pMissile.bMarkForDeath == false) { pMissile.bMarkForDeath = true; // Delay - remove object later ShipRemoveMissileObserver pObserver = new ShipRemoveMissileObserver(); DelayedObjectManager.Attach(pObserver); } }
public override void ReinitializeLevel(GameManager pGameManager) { SoundManager.StopAllSounds(); TimerManager.PurgeAllNodes(); GameObjectManager.PurgeAllNodes(); SpriteBatch pSBatch = SpriteBatchManager.Find(SpriteBatch.Name.Boxes); pSBatch.GetSBNodeManager().PurgeAllNodes(); pSBatch = SpriteBatchManager.Find(SpriteBatch.Name.Sprites); pSBatch.GetSBNodeManager().PurgeAllNodes(); ColPairManager.PurgeAllNodes(); DelayedObjectManager.PurgeAll(); if (pGameManager.pActivePlayer.name == PlayerArtifact.Name.PlayerOne) { PlayerOneInit(pGameManager); pGameManager.poPlayer1.RestoreManagerStates(pGameManager.pGame.GetTime()); pGameManager.SetActivePlayer(PlayerArtifact.Name.PlayerOne); } else { PlayerTwoInit(pGameManager); pGameManager.poPlayer2.RestoreManagerStates(pGameManager.pGame.GetTime()); pGameManager.SetActivePlayer(PlayerArtifact.Name.PlayerTwo); } }
public override void Notify() { // Delete missile //Debug.WriteLine("ShipRemoveMissileObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB); // At this point we have two game objects // Actually we can control the objects in the visitor // Alphabetical ordering... A is missile, B is wall // This cast will throw an exception if I'm wrong this.pBomb = (Bomb)this.pSubject.pObjA; this.pSubB = this.pSubject.pObjB; //Debug.WriteLine("MissileRemoveObserver: --> delete missile {0}", pBomb); if (pBomb.bMarkForDeath == false) { pBomb.bMarkForDeath = true; // Delay - remove object later // TODO - reduce the new functions RemoveBombObserver pObserver = new RemoveBombObserver(this); DelayedObjectManager.Attach(pObserver); } //this.pBomb.pOwner.Handle(); }
//this observer triggers the explosion animation before removing an alien; public override void Notify() { //todo - create an explosion manager that can add and remove explosion objects //can't simply swap image of the alien object due to proxy pattern - stupid //get the coordinates of the destroyed subject; this.pos_x = this.pSubject.pObjB.x; this.pos_y = this.pSubject.pObjB.y; //create a game object to temporarily render in the position of the destroyed subject //game sprites and sprite batch stuff is taken care of in the constructor; this.pAlienExplosionObj = new ExplodingAlien(GameObject.Name.ExplodingAlien, GameSprite.Name.AlienExplosion, 0, this.pos_x, this.pos_y); this.pAlienExplosionObj.x = this.pos_x; this.pAlienExplosionObj.y = this.pos_y; GameObjectManager.AttachTree(this.pAlienExplosionObj); this.pAlienExplosionObj.Update(); //pass to delay manager AnimateAlienExplosionObserver pObserver = new AnimateAlienExplosionObserver(this); DelayedObjectManager.Attach(pObserver); }
//---------------------------------------------------------------------------------- // Abstract Methods //---------------------------------------------------------------------------------- public override void Notify() { // Delete missile //Debug.WriteLine("RemoveBrickObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB); this.pAlien = (AlienGO)this.pSubject.pObjB; Debug.Assert(this.pAlien != null); if (pAlien.bMarkForDeath == false) { //Award points int points = ((AlienGO)this.pAlien).GetPoints(); Debug.WriteLine(" +{0} points!", points); Score.IncreaseScore(points); Score.Refresh(); pAlien.bMarkForDeath = true; // Delay RemoveAlienObserver pObserver = new RemoveAlienObserver(this); DelayedObjectManager.Attach(pObserver); } else { pAlien.bMarkForDeath = true; } }
// Should be called at some point before leaving state public override void CleanUp(GameManager pGameManager) { GameManager.PushHighScoreToFont(); ShipManager.Purge(); TimerManager.PurgeAllNodes(); GameObjectManager.PurgeAllNodes(); SpriteBatch pSBatch = SpriteBatchManager.Find(SpriteBatch.Name.Boxes); pSBatch.GetSBNodeManager().PurgeAllNodes(); pSBatch = SpriteBatchManager.Find(SpriteBatch.Name.Sprites); pSBatch.GetSBNodeManager().PurgeAllNodes(); ColPairManager.PurgeAllNodes(); DelayedObjectManager.PurgeAll(); InputSubject pInputSubject = InputManager.GetArrowLeftSubject(); pInputSubject.PurgeAll(); pInputSubject = InputManager.GetArrowRightSubject(); pInputSubject.PurgeAll(); pInputSubject = InputManager.GetSpaceSubject(); pInputSubject.PurgeAll(); Handle(pGameManager); }
public override void Update(float systemTime) { // Single Step, Free running... Simulation.Update(systemTime); // Handels Keyboard input InputManager.Update(); // Run based on simulation stepping if (Simulation.GetTimeStep() > 0.0f) { // Fire off the timer events TimerManager.Update(Simulation.GetTotalTime()); // walk through all objects and push to flyweight GameObjectManager.Update(); // Do the collision checks CollPairManager.Process(); // Delete any objects here... DelayedObjectManager.Process(); // Check to see if all aliens are dead to move to the next level. Level.Update(); } }
public override void Update(float systemTime) { InputManager.Update(); FontManager.Update(Font.Name.Player1Score, SpaceInvaders.pPlayer1Score); FontManager.Update(Font.Name.Player2Score, SpaceInvaders.pPlayer2Score); FontManager.Update(Font.Name.HiScore, SpaceInvaders.pHiScore); FontManager.Update(Font.Name.Lives, ScenePlay.ShipLives.ToString()); this.RunTime = Simulation.GetTotalTime() - ScenePlay.StartTimeDelta; //Debug.WriteLine(this.RunTime); TimerManager.Update(this.RunTime); GameObjectManager.Update(); //Collision Checks CollisionPairManager.Process(); // Delete any objects here... DelayedObjectManager.Process(); //check if all alien killed AlienGrid pGrid = (AlienGrid)GameObjectManager.Find(GameObject.Name.AlienGrid); if (pGrid.GetAlienCount() < 1) { pGrid.IncreaseStartRate(); this.ResetAll(); } }
//---------------------------------------------------------------------------------- // Abstract Methods //---------------------------------------------------------------------------------- public override void Notify() { // Delete missile //Debug.WriteLine("RemoveMissileObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB); if (this.pSubject.pObjA.GetName() == GameObject.Name.Missile) { this.pMissile = (Missile)this.pSubject.pObjA; } else if (this.pSubject.pObjB.GetName() == GameObject.Name.Missile) { this.pMissile = (Missile)this.pSubject.pObjB; } Debug.Assert(this.pMissile != null); if (pMissile.bMarkForDeath == false) { pMissile.bMarkForDeath = true; // Delay RemoveMissileObserver pObserver = new RemoveMissileObserver(this); DelayedObjectManager.Attach(pObserver); } else { pMissile.bMarkForDeath = true; } }
protected override void derivedUpdate(ColSubject pColSubject) { //Debug.WriteLine("RemoveShieldBrickObserver: {0} vs {1}", pColSubject.pObjA.name, pColSubject.pObjB.name); // No Clue which is which so just check the names GameObject pGameObjA = pColSubject.pObjA; GameObject pGameObjB = pColSubject.pObjB; Debug.Assert(pGameObjA != null); Debug.Assert(pGameObjB != null); if (pGameObjA.name == GameObject.Name.ShieldBrick) { this.pShieldBrick = pGameObjA; } else if (pGameObjB.name == GameObject.Name.ShieldBrick) { this.pShieldBrick = pGameObjB; } else { Debug.Assert(false, "Neither of the objects are shields"); } if (this.pShieldBrick.bMarkForDeath == false) { this.pShieldBrick.bMarkForDeath = true; // Delay - remove object later RemoveShieldBrickObserver pObserver = new RemoveShieldBrickObserver(this); DelayedObjectManager.Attach(pObserver); } }
//---------------------------------------------------------------------------------- // Abstract Methods //---------------------------------------------------------------------------------- public override void Notify() { // Delete missile //Debug.WriteLine("RemoveBombObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB); // Need to separate out collision-pairs since this class can handle multiple Explosion cases. switch (this.name) { case GameSprite.Name.AlienExplosion: this.pTargetObj = this.pSubject.pObjB; break; case GameSprite.Name.MissileExplosion: this.pTargetObj = this.pSubject.pObjA; break; case GameSprite.Name.BombExplosion: this.pTargetObj = this.pSubject.pObjA; break; case GameSprite.Name.SaucerExplosion: this.pTargetObj = this.pSubject.pObjB; break; case GameSprite.Name.ShipExplosionA: this.pTargetObj = this.pSubject.pObjB; break; case GameSprite.Name.ShipExplosionB: this.pTargetObj = this.pSubject.pObjB; break; default: Debug.WriteLine("There is no Default explosion. Make sure you enter the name you want."); Debug.Assert(false); break; } Debug.Assert(this.pTargetObj != null); float px = this.pTargetObj.x; float py = this.pTargetObj.y; // Factor attaches to the correct sprite batches // Could be an AlienExplosion, BombExplosion, MissileExplosion // Should be explosion sprites this.pExplosionSprite = EF.Create(this.name, px, py); this.pExplosionSprite.SetPosition(px, py); // Delay ExplosionSpriteObserver pObserver = new ExplosionSpriteObserver(this); DelayedObjectManager.Attach(pObserver); }
public static void Attach(Observer pObserver) { // protection Debug.Assert(pObserver != null); DelayedObjectManager pDelayMan = DelayedObjectManager.privGetInstance(); DLink.AddToFront(ref pDelayMan.pHead, pObserver); }
private static DelayedObjectManager privGetInstance() { // Do the initialization if (instance == null) { instance = new DelayedObjectManager(); } return(instance); }
public static void PurgeAll() { DelayedObjectManager pDelayMan = DelayedObjectManager.privGetInstance(); // remove all from list while (pDelayMan.pHead != null) { DLink.RemoveFront(ref pDelayMan.pHead); } }
//----------------------------------------------------------------------------- // Game::Draw() // This function is called once per frame // Use this for draw graphics to the screen. // Only do rendering here //----------------------------------------------------------------------------- public override void Draw() { //----------------------------------------------- //sprites //SpriteBatchManager.renderBoxes = true; //draw all the sprites attached to sprite batches SpriteBatchManager.Draw(); // Delete any objects here... DelayedObjectManager.Process(); }
private static DelayedObjectManager privGetInstance() { // Do the initialization if (pInstance == null) { pInstance = new DelayedObjectManager(); } // Safety - this forces users to call create first Debug.Assert(pInstance != null); return(pInstance); }
//---------------------------------------------------------------------------------- // Abstract Methods //---------------------------------------------------------------------------------- public override void Notify() { // Delete missile //Debug.WriteLine("RemoveBombObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB); // Need to separate out collision-pairs since this class can handle multiple Explosion cases. switch (this.name) { case GameObject.Name.AlienExplosion: this.pTargetObj = this.pSubject.pObjB; break; case GameObject.Name.MissileExplosion: this.pTargetObj = this.pSubject.pObjA; break; case GameObject.Name.BombExplosion: this.pTargetObj = this.pSubject.pObjA; break; default: Debug.WriteLine("There is no Default explosion. Make sure you enter the name you want."); Debug.Assert(false); break; } Debug.Assert(this.pTargetObj != null); float px = this.pTargetObj.x; float py = this.pTargetObj.y; // Factor attaches to the correct sprite batches // Could be an AlienExplosion, BombExplosion, MissileExplosion this.pExplosion = EF.Create(this.name, px, py); // Attach the missile to the missile root GameObject pExplosionRoot = GameObjectManager.Find(GameObject.Name.ExplosionRoot); Debug.Assert(pExplosionRoot != null); // Add to GameObject Tree - {update and collisions} pExplosionRoot.Add(this.pExplosion); // Delay ExplosionObserver pObserver = new ExplosionObserver(this); DelayedObjectManager.Attach(pObserver); }
public override void Notify() { this.pAlien = this.pSubject.pObjB; if (this.pAlien.bMarkForDeath == false) { this.pAlien.bMarkForDeath = true; // Delay - remove object later // TODO - reduce the new functions RemoveAlienObserver pObserver = new RemoveAlienObserver(this); DelayedObjectManager.Attach(pObserver); } }
protected override void derivedUpdate(ColSubject pColSubject) { //Debug.WriteLine("[Observer({4})] ColPair {5}({3}) - RemoveCollisionPairObserver: {0} vs {1}({2})", pColSubject.pObjA.name, pColSubject.pObjB.name, pColSubject.pObjB.GetHashCode(), this.pColPair.GetHashCode(), this.GetHashCode(), this.pColPair.name); //Debug.WriteLine(this.pColPair + "MARKED FOR DEATH"); if (this.pColPair.bMarkForDeath == false) { //ColPairManager.PrintReport(); this.pColPair.bMarkForDeath = true; //Delay - remove object later RemoveCollisionPairObserver pObserver = new RemoveCollisionPairObserver(this); DelayedObjectManager.Attach(pObserver); } }
public override void Notify() { // Delete missile Debug.WriteLine("ShipRemoveMissileObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB); this.pMissile = MissileCategory.GetMissile(this.pSubject.pObjA, this.pSubject.pObjB); Debug.WriteLine("MissileRemoveObserver: --> delete missile {0}", pMissile); if (pMissile.markForDeath == false) { pMissile.markForDeath = true; // Delay ShipRemoveMissileObserver pObserver = new ShipRemoveMissileObserver(this); DelayedObjectManager.Attach(pObserver); } }
public override void Notify() { // Delete missile //Debug.WriteLine("RemoveMissileObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB); this.pBrick = (ShieldBrick)this.pSubject.pObjB; Debug.Assert(this.pBrick != null); if (pBrick.markForDeath == false) { pBrick.markForDeath = true; // Delay RemoveBrickObserver pObserver = new RemoveBrickObserver(this); DelayedObjectManager.Attach(pObserver); } }
// Should be called during the Update part of gameloop public override void Update(GameManager pGameManager) { // Debug.WriteLine("Tick" + this.GetTime()); InputManager.Update(); // Sprite animations and motions being handled in TimerManger TimerManager.Update(pGameManager.pGame.GetTime()); // Pushes updates from Gameobjects to proxysprites GameObjectManager.Update(); ColPairManager.Process(); DelayedObjectManager.Process(); pGameManager.HandleEndOfPlayerTurn(); }
public override void Notify() { // Delete missile this.pBrick = (ShieldBrick)this.pSubject.pObjB; Debug.Assert(this.pBrick != null); if (pBrick.bMarkForDeath == false) { pBrick.bMarkForDeath = true; // Delay RemoveBrickObserver pObserver = new RemoveBrickObserver(this); DelayedObjectManager.Attach(pObserver); } //else // { //pBrick.bMarkForDeath = true; //} }
static public void Process() { DelayedObjectManager pDelayMan = DelayedObjectManager.privGetInstance(); Observer pObserver = (Observer)pDelayMan.pHead; while (pObserver != null) { // Fire off remove method pObserver.Execute(); pObserver = (Observer)pObserver.GetNext(); } // remove all from list while (pDelayMan.pHead != null) { DLink.RemoveFront(ref pDelayMan.pHead); } }
public override void Notify() { // Delete missile //Debug.WriteLine("RemoveBombObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB); //this.pBomb = BombCategory.GetBomb(this.pSubject.pObjA, this.pSubject.pObjB); this.pBomb = (Bomb)this.pSubject.pObjA; Debug.Assert(this.pBomb != null); //Debug.WriteLine("RemoveBombObserver: --> delete bomb {0}", pBomb); if (pBomb.markForDeath == false) { pBomb.markForDeath = true; // Delay //todo replace this new with a find from object pool; RemoveBombObserver pObserver = new RemoveBombObserver(this); DelayedObjectManager.Attach(pObserver); } }
public override void Notify() { // At this point we have two game objects // Actually we can control the objects in the visitor // Alphabetical ordering... A is missile, B is wall // This cast will throw an exception if I'm wrong this.pMissile = (Missile)this.pSubject.pObjB; //Debug.WriteLine("MissileRemoveObserver: --> delete missile {0}", pMissile); if (pMissile.bMarkForDeath == false) { pMissile.bMarkForDeath = true; // Delay - remove object later // TODO - reduce the new functions ShipRemoveMissileObserverAltPair pObserver = new ShipRemoveMissileObserverAltPair(this); DelayedObjectManager.Attach(pObserver); } }
public override void Notify() { //Debug.WriteLine("RemoveBombObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB); this.pBomb = (Bomb)this.pSubject.pObjA; this.pShip = (Ship)this.pSubject.pObjB; Debug.Assert(this.pBomb != null); Debug.Assert(this.pShip != null); if (pShip.bMarkForDeath == false) { pShip.bMarkForDeath = true; // Delay ShipTakeDamageObserver pObserver = new ShipTakeDamageObserver(this); DelayedObjectManager.Attach(pObserver); } else { pShip.bMarkForDeath = true; } }
protected override void derivedUpdate(ColSubject pColSubject) { //Debug.WriteLine(this.GetHashCode() + " RemoveBombObserver: {0} vs {1}", pColSubject.pObjA.name, pColSubject.pObjB.name); // Bomb will always be pObjB GameObject pGameObjA = pColSubject.pObjA; GameObject pGameObjB = pColSubject.pObjB; Debug.Assert(pGameObjA != null); Debug.Assert(pGameObjB != null); if (pGameObjA.name == GameObject.Name.Bomb) { this.pBomb = (Bomb)pGameObjA; } else if (pGameObjB.name == GameObject.Name.Bomb) { this.pBomb = (Bomb)pGameObjB; } else { Debug.Assert(false, "Neither of the objects are Bombs"); } //Debug.WriteLine("Set state of Invader to true" + this.pBomb.pInvaderWhoDroppedMe); if (this.pBomb.bMarkForDeath == false) { this.pBomb.pInvaderWhoDroppedMe.canLaunchBomb = true; pBomb.bMarkForDeath = true; OneTimeAnimation pDeathAnimation = new OneTimeAnimation(Sprite.Name.BombDeath, this.pBomb.x, this.pBomb.y); pDeathAnimation.Attach(Image.Name.BombDeath); TimerManager.Add(TimeEvent.Name.InvaderDeath, pDeathAnimation, 0.1f); // Delay - remove object later RemoveBombObserver pObserver = new RemoveBombObserver(this); DelayedObjectManager.Attach(pObserver); } }
public override void Move(InvaderGrid pGrid) { if (this.alreadyMovedDown) { //Debug.WriteLine("Grid Colliding with Right Wall : Moving Left"); pGrid.speedX = -Math.Abs(pGrid.roStaticSpeedX); pGrid.speedY = 0.0f; this.Handle(pGrid); this.alreadyMovedDown = false; } else { //Debug.WriteLine("Grid Colliding with Right Wall : Moving Down"); pGrid.speedX = 0.0f; pGrid.speedY = -Math.Abs(pGrid.roStaticSpeedY); this.alreadyMovedDown = true; SpeedUpGridMarchObserver pObserver = new SpeedUpGridMarchObserver(pGrid.speedUpMultiplier); DelayedObjectManager.Attach(pObserver); } }