using System; using System.Diagnostics; namespace SpaceInvaders { public class ShipMoveObserver : CollisionObserver { //------------------------------------------------------------------- // CONSTRUCTION //------------------------------------------------------------------- public ShipMoveObserver() : base() { } //------------------------------------------------------------------- // PUBLIC METHODS //------------------------------------------------------------------- public override void Notify() { //grab current ship & bumper Ship pShip = ShipMan.GetShip(); Bumpers pBumper = (Bumpers)this.pSubject.pObjB; //ship collide w/ left bumper if(pBumper.GetBumperType() == Bumpers.BumperType.LeftBumper) { pShip.SetMoveState(ShipMan.MoveState.MoveRight); } //ship collide w/ right bumper if(pBumper.GetBumperType() == Bumpers.BumperType.RightBumper) { pShip.SetMoveState(ShipMan.MoveState.MoveLeft); } } } // end class } // end namespace