Пример #1
0
        /// <summary> Runs game after all Start() methods are called. </summary>
        void OnEnable()
        {
            // utymap is better to start on non-UI thread
            Observable.Start(() =>
            {
                // convert and load map data into memory
                var stylesheet = _appManager.GetService <Stylesheet>();
                var range      = new Range <int>(LevelOfDetails, LevelOfDetails);

                // NOTE it's better not to mix borders and admin areas due to polygon clipping issues.
                if (LoadBorder)
                {
                    _mapDataLoader.AddToStore(MapStorageType.InMemory, @"NaturalEarth/ne_110m_admin_0_boundary_lines_land", stylesheet, range);
                    _mapDataLoader.AddToStore(MapStorageType.InMemory, @"NaturalEarth/ne_110m_land", stylesheet, range);
                }
                else
                {
                    _mapDataLoader.AddToStore(MapStorageType.InMemory, @"NaturalEarth/ne_110m_admin_0_scale_rank", stylesheet, range);
                }

                _mapDataLoader.AddToStore(MapStorageType.InMemory, @"NaturalEarth/ne_110m_lakes", stylesheet, range);
                _mapDataLoader.AddToStore(MapStorageType.InMemory, @"NaturalEarth/ne_110m_rivers_lake_centerlines", stylesheet, range);

                LoadGlobe();
            }, Scheduler.ThreadPool).Subscribe();
        }
Пример #2
0
        public void OnImportClick()
        {
            var sourcePath  = SourcePathField.text;
            var storageType = StorageTypeToggle.isOn ? MapStorageType.InMemory : MapStorageType.Persistent;
            var range       = new Range <int>((int)MinSlider.value, (int)MaxSlider.value);

            // NOTE if button is not enabled then import is still in progress
            // or error occured.
            if (!ImportButton.enabled || String.IsNullOrEmpty(sourcePath))
            {
                return;
            }

            ImportButton.enabled = false;

            Observable
            .Start(() => _mapDataLoader.AddToStore(storageType, sourcePath, _stylesheet, range))
            .SubscribeOn(Scheduler.ThreadPool)
            .ObserveOn(Scheduler.MainThread)
            .Subscribe(_ => { }, () => ImportButton.enabled = true);
        }