using System; using System.Diagnostics; namespace SpaceInvaders { public class ToggleObserver : InputObserver { //------------------------------------------------------------------- // FIELDS //------------------------------------------------------------------- SpriteBatch pBatch; //------------------------------------------------------------------- // CONSTRUCTION //------------------------------------------------------------------- public ToggleObserver() : base() { this.pBatch = SpriteBatchMan.FindBatch(SpriteBatch.BatchName.Boxes); Debug.Assert(this.pBatch != null); } public ToggleObserver(SpriteBatch batch) : base() { Debug.Assert(batch != null); this.pBatch = batch; } //------------------------------------------------------------------- // PUBLIC METHODS //------------------------------------------------------------------- public override void Notify() { if(pBatch.GetToggle() == true) { pBatch.SetToggle(false); } else { pBatch.SetToggle(true); } } } // end class } // end namespace