using System; using System.Diagnostics; namespace SpaceInvaders { public class RemoveMissileObserver : CollisionObserver { //------------------------------------------------------------------- // FIELDS //------------------------------------------------------------------- private GameObject pMissile; //------------------------------------------------------------------- // CONSTRUCTION //------------------------------------------------------------------- public RemoveMissileObserver() : base() { this.pMissile = null; } public RemoveMissileObserver(RemoveMissileObserver m) : base() { Debug.Assert(m.pMissile != null); this.pMissile = m.pMissile; } //------------------------------------------------------------------- // PUBLIC METHODS //------------------------------------------------------------------- public override void Notify() { //get missile if(this.pSubject.pObjA.GetType() == typeof(Missile)) { this.pMissile = (Missile)this.pSubject.pObjA; } else { this.pMissile = (Missile)this.pSubject.pObjB; } //set as dead & remove if(pMissile.isDead == false) { pMissile.isDead = true; RemoveMissileObserver pObserver = new RemoveMissileObserver(this); DelayObjectMan.AttachDelay(pObserver); } } public override void Execute() { //game object deletes it this.pMissile.Remove(); } } // end class } // end namespace