Ejemplo n.º 1
0
        private Distance GetDistanceToPlayerOrDefault(Thing t)
        {
            if (t == null)
            {
                return(null);
            }

            LocationVector lv = t.VectorFromPlayer;

            if (lv == null || lv.Distance == null)
            {
                return(null);
            }

            return(lv.Distance);
        }
Ejemplo n.º 2
0
		/// <summary>
		/// Raises the appearing event.
		/// </summary>
		public override void OnAppearing()
		{
			base.OnAppearing();

			App.GPS.PositionChanged += HandlePositionChanged;
			App.GPS.HeadingChanged += HandleHeadingChanged;

			if (this.activeObject != null)
			{
				this.activeObject.PropertyChanged += HandlePropertyChanged;
			}

			vecDirection = null;

			NotifyPropertyChanged(NamePropertyName);

			#if __HTML__
			NotifyPropertyChanged(HtmlSourcePropertyName);
			#else
			NotifyPropertyChanged(DescriptionPropertyName);
			NotifyPropertyChanged(HasDescriptionPropertyName);
			NotifyPropertyChanged(HasImagePropertyName);
			NotifyPropertyChanged(ImageSourcePropertyName);
			#endif

			NotifyPropertyChanged(HasDirectionPropertyName);

			UpdateHasDirection();
			UpdateDirection(true);
		}
Ejemplo n.º 3
0
		/// <summary>
		///  Update direction for active object
		/// </summary>
		/// <param name="updateDirection">Flag, if the direction should be calculated new.</param>
		private void UpdateDirection(bool updateDirection)
		{
			if (this.activeObject == null)
			{
				return;
			}

			if (Position == null)
			{
				Direction = double.NegativeInfinity;
				Distance = double.NegativeInfinity;

				return;
			}

			// Do it only for zones, where we are inside
			if (this.activeObject is Zone && ((Zone)this.activeObject).State == PlayerZoneState.Inside)
			{
				Direction = double.PositiveInfinity;
				Distance = double.PositiveInfinity;

				return;
			}

			double heading = 0;

			if (Position.Heading != null)
			{
				// Show always to north
				heading = 360.0 - (double)Position.Heading;
			}

			// Do it only for entries with ObjectLocation
			if (this.activeObject is Zone || this.activeObject.ObjectLocation != null)
			{
				if (updateDirection || vecDirection == null)
				{
					// Calculate values for this thing
					vecDirection = this.geoMathHelper.VectorToPoint(new ZonePoint(Position.Latitude, Position.Longitude, 0), this.activeObject.ObjectLocation);
				}

				// Set values
				Direction = (double)((vecDirection.Bearing + heading) % 360);
				Distance = vecDirection.Distance.Value;
			}
		}
 private void RefreshFromVector(LocationVector v)
 {
     if (v == null)
     {
         // No distance to show.
         bool distanceChanged = Distance != null;
         Distance = null;
         RefreshBearing(bearingFromNorth: 0);
         if (!distanceChanged)
         {
             RefreshFromDistance(null);
         }
     }
     else
     {
         // A distance to show!
         Distance = v.Distance;
         RefreshBearing(bearingFromNorth: v.Bearing);
     }
 }