Ejemplo n.º 1
0
    public void UpdateUI(GPSTracker gps, float goalDistance)
    {
        speedDisplay.text = gps.GetCurrentSpeedFormatted();

        double currentBaseSpeed = gps.CalculateCurrentSpeedWithoutUnits();
        int    speedIndex       = 0;

        foreach (float threshold in speedThresholds)
        {
            if (currentBaseSpeed >= threshold)
            {
                speedIndex++;
            }
        }

        speedImage.sprite = speedIcons[Mathf.Min(speedIndex, speedIcons.Length - 1)];

        LocationInfo?location = gps.GetPreviousLocationData();

        if (location.HasValue)
        {
            LocationInfo locationObj = location.Value;
            positionDisplay.text = $"Latitude: {locationObj.latitude.ToString("f3")}  Longitude: {locationObj.longitude.ToString("f3")}";
        }

        double distance = gps.GetTotalDistance();
        float  progress = Mathf.Clamp01((float)distance / goalDistance);

        distanceProgress.UpdateProgress(progress);
        if (progress >= 0.5f)
        {
            halfGoalFlag.RotateFlag();
        }
        if (progress >= 1f)
        {
            goalFlag.RotateFlag();
        }

        GPSUnit distanceUnit = gps.GetDistanceUnit();

        goalText.text     = distanceUnit.Format(goalDistance);
        halfGoalText.text = distanceUnit.Format(goalDistance / 2);
    }
Ejemplo n.º 2
0
        public static ObservableCollection <GPSUnit> GetGPSUnitList(JObject jsUnits)
        {
            _gpsUnits = new ObservableCollection <GPSUnit>();
            JArray jUnits = jsUnits["units"].Value <JArray>();

            foreach (var ju in jUnits)
            {
                GPSUnit unit = new GPSUnit
                {
                    Id    = ju["id"].Value <long>(),
                    Name  = ju["name"]?.Value <string>(),
                    Plate = ju["plate"]?.Value <string>()
                };

                _gpsUnits.Add(unit);
            }

            return(_gpsUnits);
        }
Ejemplo n.º 3
0
 public double ConvertToUnit(double value, GPSUnit unit)
 {
     return(unit.ConvertFromBase(this.ConvertToBase(value)));
 }
Ejemplo n.º 4
0
 public void SetUnits(GPSUnit distance, GPSUnit time)
 {
     this.distanceUnit = distance;
     this.timeUnit     = time;
 }