//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); }
public AnimateAlienExplosionObserver(AnimateAlienExplosionObserver m) { //transfer data here; this.pAlienExplosionObj = m.pAlienExplosionObj; this.pos_x = m.pos_x; this.pos_y = m.pos_y; }