45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Mapbox.Unity.Location;
|
|
using Mapbox.Unity.Utilities;
|
|
using Mapbox.Utils;
|
|
using UnityEngine;
|
|
|
|
public class GoldDuckEditorLocationProvider : AbstractEditorLocationProvider
|
|
{
|
|
[SerializeField] CollectableDuckData[] _ducks;
|
|
|
|
[SerializeField]
|
|
Vector2d _latitudeOffset = new Vector2d(0.0001, 0);
|
|
|
|
/// The mock heading value.
|
|
/// </summary>
|
|
[SerializeField]
|
|
[Range(0, 359)]
|
|
float _heading;
|
|
|
|
|
|
private int idx = -1;
|
|
Vector2d LatitudeLongitude
|
|
{
|
|
get
|
|
{
|
|
idx++;
|
|
// reset index to keep looping through the location array
|
|
if (idx >= _ducks.Length) { idx = 0; }
|
|
return _ducks[idx].LatitudeLongitude + _latitudeOffset;
|
|
}
|
|
}
|
|
|
|
protected override void SetLocation()
|
|
{
|
|
_currentLocation.UserHeading = _heading;
|
|
_currentLocation.LatitudeLongitude = LatitudeLongitude;
|
|
_currentLocation.Accuracy = _accuracy;
|
|
_currentLocation.Timestamp = UnixTimestampUtils.To(DateTime.UtcNow);
|
|
_currentLocation.IsLocationUpdated = true;
|
|
_currentLocation.IsUserHeadingUpdated = true;
|
|
}
|
|
}
|