示例#1
0
        /// <summary>
        ///     Starts the timer to update map objects and the handler to update position
        /// </summary>
        public static async Task InitializeDataUpdate()
        {
            if (SettingsService.Instance.IsCompassEnabled)
            {
                _compass = Compass.GetDefault();
                if (_compass != null)
                {
                    _compassTimer = new DispatcherTimer
                    {
                        Interval = TimeSpan.FromMilliseconds(Math.Max(_compass.MinimumReportInterval, 50))
                    };
                    _compassTimer.Tick += (s, e) =>
                    {
                        if (SettingsService.Instance.IsAutoRotateMapEnabled)
                        {
                            HeadingUpdated?.Invoke(null, _compass.GetCurrentReading());
                        }
                    };
                    _compassTimer.Start();
                }
            }
            _geolocator = new Geolocator
            {
                DesiredAccuracy         = PositionAccuracy.High,
                DesiredAccuracyInMeters = 5,
                ReportInterval          = 1000,
                MovementThreshold       = 5
            };

            Busy.SetBusy(true, Resources.CodeResources.GetString("GettingGpsSignalText"));
            Geoposition = Geoposition ?? await _geolocator.GetGeopositionAsync();

            GeopositionUpdated?.Invoke(null, Geoposition);
            _geolocator.PositionChanged += GeolocatorOnPositionChanged;
            // Before starting we need game settings
            GameSetting =
                await
                DataCache.GetAsync(nameof(GameSetting), async() => (await _client.Download.GetSettings()).Settings,
                                   DateTime.Now.AddMonths(1));

            // Update geolocator settings based on server
            _geolocator.MovementThreshold = GameSetting.MapSettings.GetMapObjectsMinDistanceMeters;
            if (_heartbeat == null)
            {
                _heartbeat = new Heartbeat();
            }
            await _heartbeat.StartDispatcher();

            // Update before starting timer
            Busy.SetBusy(true, Resources.CodeResources.GetString("GettingUserDataText"));
            //await UpdateMapObjects();
            await UpdateInventory();
            await UpdateItemTemplates();

            Busy.SetBusy(false);
        }
示例#2
0
 private static void compass_ReadingChanged(Compass sender, CompassReadingChangedEventArgs args)
 {
     HeadingUpdated?.Invoke(sender, args.Reading);
 }
 public void OnHeadingUpdated()
 {
     HeadingUpdated?.Invoke(this, EventArgs.Empty);
 }
示例#4
0
 private void OnHeadingUpdated(HeadingData data)
 {
     HeadingUpdated?.Invoke(this, new HeadingEventArgs(data));
 }