//---------------------------------------------------------------------------------- // 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() { GameObject placeObject; if (this.p == 1) { placeObject = this.pSubject.pObjA; } else { placeObject = this.pSubject.pObjB; } // TODO new ?? GameObject pGameObjDies = this.factory.Create(this.pGOname, this.pGSname, this.container, placeObject.x, placeObject.y); //SpriteBatch pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens); //SpriteBatch pSB_Box = SpriteBatchMan.Find(SpriteBatch.Name.Boxes); //GameObject pGameObjDies = new AlienDies(this.pGOname, this.pGSname, placeObject.x, placeObject.y); //GameObject pExplosionGroup = GameObjectMan.Find(GameObject.Name.ExplosionGroup); //Debug.Assert(pExplosionGroup != null); //pExplosionGroup.Add(pGameObjDies); //pGameObjDies.ActivateGameSprite(pSB_Aliens); //pGameObjDies.ActivateCollisionSprite(pSB_Box); this.pGameObj = pGameObjDies; if (pGameObj.bMarkForDeath == false) { pGameObj.bMarkForDeath = true; // Delay ExplosionObserver pObserver = new ExplosionObserver(this); DelayedObjectMan.Attach(pObserver); } }
public ExplosionObserver(ExplosionObserver b) { Debug.Assert(b != null); this.pGameObj = b.pGameObj; }
public ExplosionObserver(ExplosionObserver pObserver) { this.pTargetObj = pObserver.pTargetObj; this.pExplosion = pObserver.pExplosion; this.name = pObserver.name; }