public void OpenScreenUseScreenLocation_WhenNoMatchingScreenIsOpen_CreatesNewScreen() { var conductor = CreateConductor(); var firstSubject = new BaseSubject { Value = "First Subject" }; var differentSubject = new BaseSubject { Value = "Different Subject" }; conductor.OpenScreen( ScreenFactory .For <MultipleInstancesScreen>(Locator) ); conductor.OpenScreen( ScreenFactory .WithSubject(firstSubject) .For <LocatableScreen>(Locator) ); conductor.OpenScreen( ScreenFactory .WithSubject(differentSubject) .For <LocatableScreen>(Locator) ); CollectionAssert.AreEqual( new[] { firstSubject, differentSubject }, GetSubjectsOfOpenScreens(conductor) ); }
public void Notify(BaseSubject subject) { if (subject is GPS) { double distance = trigger.keyPosition.GetMeterDistanceTo(((GPS)subject).currentPosition); if (distance <= trigger.toleranceRadius) { KeyIsFind(); } } }
public void Update(BaseSubject <string> baseSubject, params string[] args) { if (baseSubject == this.baseSubject) { if (this.baseSubject.GetType() == typeof(NotifyPropertyChange)) { var subject = this.baseSubject as NotifyPropertyChange; var changedProperty = subject.NotifiableProperty; Console.WriteLine($"Changed Property: {changedProperty}"); } } }
public void Notify(BaseSubject subject) { //////////////// Peut être désactiver le StepDetector //////////////// Le "if" ici et au dessus le ToolBox.Instance.sensorManager.stepDetector.AddObserver(this); //////////////// La classe StepDetector //////////////// SensorManager -> 2 lignes : 20 et 11 if (subject is StepDetector) { Vector3 direction = Quaternion.Euler(0, 0, -ToolBox.Instance.sensorManager.orientation.azimut) * Vector3.up; currentPosition.SetCoordinate(currentPosition.ToVector()/*+ (direction.normalized * LENGHT_STEP)*/); NotifyAllObservers(); } }
public void Notify(BaseSubject subject) { if (subject is NextStep) { if (inPre) { inPre = false; ExecuteTrigger(); } else if (inPost) { inPost = false; GameToolBox.Instance.nextStep.RemoveObserver(this); NotifyAllObservers(); } } }
public void Notify(BaseSubject subject) { if (subject is Download) { DownloadType type = ((Download)subject).theDownload.type; if (type == DownloadType.Attractions) { if (toolBox.data.attractions != null) { BuildMenuAttractions(); } else { ActiveMenuAttraction(false); ActiveMainMenu(true); toolBox.loadingScreen.enable(false); } } else if (type == DownloadType.Route) { if (toolBox.data.route != null) { if (openRoute) { GotoNavigation(); } else { save.SaveRoute(); toolBox.data.eleRoute = null; ActiveOptionRoute(false); } } else { toolBox.loadingScreen.enable(false); } } } else if (subject is GPS) { subject.RemoveObserver(this); toolBox.download.EnqueueAttraction(toolBox.sensorManager.gps.currentPosition); } }
public void OpenScreenUseScreenLocation_WhenScreenFactoryIsDowncasted_Works() { var conductor = CreateConductor(); var singleSubject = new BaseSubject { Value = "Single Subject" }; conductor.OpenScreen( ScreenFactory .WithSubject(singleSubject) .For <DerivedLocatableScreen>(Locator) ); IScreenFactory <IScreenBase> downcasted = ScreenFactory .WithSubject(singleSubject) .For <DerivedLocatableScreen>(Locator); conductor.OpenScreen(downcasted); CollectionAssert.AreEqual( new[] { singleSubject }, GetSubjectsOfOpenScreens(conductor) ); }
public void OpenScreenUseScreenLocation_WhenAttributeIsOnBaseClass_Works() { var conductor = CreateConductor(); var singleSubject = new BaseSubject { Value = "Single Subject" }; conductor.OpenScreen( ScreenFactory .WithSubject(singleSubject) .For <DerivedLocatableScreen>(Locator) ); conductor.OpenScreen( ScreenFactory .WithSubject(singleSubject) .For <DerivedLocatableScreen>(Locator) ); CollectionAssert.AreEqual( new[] { singleSubject }, GetSubjectsOfOpenScreens(conductor) ); }
public void OpenScreenUseScreenLocation_WhenMatchingScreenIsAlreadyOpen_ActivatesScreen() { var conductor = CreateConductor(); var singleSubject = new BaseSubject { Value = "Single Subject" }; conductor.OpenScreen( ScreenFactory .WithSubject(singleSubject) .For <LocatableScreen>(Locator) ); conductor.OpenScreen( ScreenFactory .WithSubject(singleSubject) .For <LocatableScreen>(Locator) ); CollectionAssert.AreEqual( new[] { singleSubject }, GetSubjectsOfOpenScreens(conductor) ); }
public View(BaseSubject <string> baseSubject) { this.baseSubject = baseSubject; this.baseSubject.Attach(this); }
/// <summary> /// Call by the device sensor to orientate the camera /// </summary> /// <param name="subject">the sensor</param> public void Notify(BaseSubject subject) { if (subject is GPS) { position.UpdateArLocation(((GPS)subject).currentPosition); transform.position = position.position + (3 * Vector3.up);//we don't use the gps altitude so we manualy put de camera above the ground. } else if (subject is Orientation) { Orientation o = (Orientation)subject; transform.rotation = Quaternion.Euler(new Vector3(o.pitch, o.azimut, o.roll)); } }
/// <summary> /// call by a trigger when the user finish it /// </summary> /// <param name="subject">the trigger</param> public void Notify(BaseSubject subject) { if (subject is Trigger) { if (subject is MultipleChoiceTrigger) { MultipleChoiceTrigger trigger = (MultipleChoiceTrigger)subject; if (data.route.Waypoints.ContainsKey(trigger.ChoiceMade.Waypoint)) { nextGoal = data.route.Waypoints[trigger.ChoiceMade.Waypoint]; } } subject.RemoveObserver(this); executeNextCondition(); } else if (subject is Download) { Download download = (Download)subject; if (download.theDownload.type == DownloadType.Direction) { UpdateDirection(Polyline.GetPolylineFromXML(download.lastDownload.text)); } } }
/// <summary> /// call by the gps and compass to navigate. /// </summary> /// <param name="subject"></param> public void Notify(BaseSubject subject) { if (subject is GPS) { GPS gps = (GPS)subject; userGPSLocation = gps.currentPosition; UpdateGoogleMapNavigation(); } else if (subject is Orientation) { Orientation o = (Orientation)subject; cursor.rotation = Quaternion.Euler(new Vector3(cursor.rotation.eulerAngles.x, cursor.rotation.eulerAngles.y, -o.azimut)); } else if (subject is Download) { Download download = (Download)subject; if (download.theDownload.type == DownloadType.Map) { UpdateNewMap(download.lastDownload); } } }