Пример #1
0
        public MapLevel GetMapLevelUpper(PixelLocation pixelLocation, int zoomLevel)
        {
            var mapLevel = GetMapLevelInternal(pixelLocation, zoomLevel);

            mapLevel.transform.localScale *= 0.25F;
            return(mapLevel);
        }
Пример #2
0
 public void Construct(PixelLocation location)
 {
     this.location = location;
     scale         = mapLevelContext.TileScale;
     GetComponent <Renderer>().sharedMaterial = Instantiate <Material>(GetComponent <Renderer>().sharedMaterial);
     UpdateTile();
 }
Пример #3
0
        private void ConstructInternal()
        {
            var converter                      = new MapPixelConverter();
            var tileStep                       = mapViewContext.TileResolution * converter.GetZoomMultiplier(zoomLevel);
            var cut                            = mapViewContext.Cut;
            var startLocation                  = initLocation + new PixelLocation(-1, 1) * (int)(tileStep * 0.5F * (cut - 1));
            var levelStep                      = tileStep * cut;
            var tileScale                      = 1F / cut;
            Func <int, float>    place         = (index) => (tileScale - 1F) * 0.5F + tileScale * index;
            Func <int, int, int> locationPlace = (center, index) => (int)(center + tileStep * index);
            var mapLevelContext                = new MapLevelContext(zoomLevel, levelStep, tileScale);
            var mapTileFactory                 = new MapTileFactory(tileRefObject, mapLevelContext, mapTileUpdater);

            for (var x = 0; x < cut; ++x)
            {
                for (var z = 0; z < cut; ++z)
                {
                    var location = new PixelLocation()
                    {
                        X = locationPlace(startLocation.X, x), Z = locationPlace(startLocation.Z, -z)
                    };
                    var tile = mapTileFactory.GetMapTile();
                    tile.gameObject.SetParent(gameObject);
                    tile.transform.localPosition = new Vector3(place(x), 0F, place(z));
                    tile.transform.localScale    = Vector3.one * tileScale;
                    tile.Construct(location);
                    tiles.Add(tile);
                }
            }
        }
Пример #4
0
        public void SpownMapLevel(PixelLocation pixelLocation, int zoomLevel, MapLevelAlign mapLevelAlign)
        {
            if (zoomLevel <= 0 || zoomLevel >= 21 || mapLevels.Any(p => p.ZoomLevel == zoomLevel))
            {
                return;
            }
            MapLevel mapLevel = null;

            switch (mapLevelAlign)
            {
            case MapLevelAlign.Lower:
                mapLevel = mapLevelFactory.GetMapLevelLower(pixelLocation, zoomLevel);
                break;

            case MapLevelAlign.Upper:
                mapLevel = mapLevelFactory.GetMapLevelUpper(pixelLocation, zoomLevel);
                break;

            default:
                break;
            }
            mapLevel.SpownMapLevelCallback = (l, z, a) => SpownMapLevel(l, z, a);
            mapLevel.OnDestroyCallback     = () => mapLevels.Remove(mapLevel);
            mapLevels.Add(mapLevel);
        }
Пример #5
0
        public MapLevel GetMapLevelInternal(PixelLocation pixelLocation, int zoomLevel)
        {
            var mapLevel = new GameObject("MapLevel").AddComponent <MapLevel>();

            mapLevel.MapViewContext = mapViewContext;
            mapLevel.MapTileUpdater = mapTileUpdater;
            mapLevel.TileRefObject  = tileRefObject;

            mapLevel.gameObject.SetParent(parent);
            mapLevel.transform.localPosition = Vector3.zero;
            mapLevel.transform.localScale    = Vector3.one;

            mapLevel.Construct(pixelLocation, zoomLevel);

            return(mapLevel);
        }
Пример #6
0
        private void Start()
        {
            var tileLoadingService = new TileLoadingService(this, mapServiceWaitTime);
            var mapViewContext     = new MapViewContext(cut, tileResolution, tileLoadingService);

            var mapTileUpdater = new MapTileUpdater(mapViewContext);

            var converter     = new MapPixelConverter();
            var pixelLocation = new PixelLocation()
            {
                X = converter.LonToX(longitude), Z = converter.LatToZ(latitude)
            };

            var mapLevelFactory = new MapLevelFactory(mapViewContext, mapTileUpdater, tileRefObject, gameObject);

            mapLevelSpowner = new MapLevelSpowner(mapLevelFactory);
            mapLevelSpowner.SpownMapLevel(pixelLocation, zoomLevel);



            collider = GetComponent <Collider>();
            InputMaster.Instance.AddPointDragEventHandler(collider, OnPointerDrag);
            InputMaster.Instance.AddWheelScrollEventHandler(collider, OnScrollWheel);
        }
Пример #7
0
 public MapLevel GetMapLevelLower(PixelLocation pixelLocation, int zoomLevel)
 {
     return(GetMapLevelInternal(pixelLocation, zoomLevel));
 }
Пример #8
0
 public void Construct(PixelLocation initLocation, int zoomLevel)
 {
     this.zoomLevel    = zoomLevel;
     this.initLocation = initLocation;
     ConstructInternal();
 }
Пример #9
0
 public void SpownMapLevel(PixelLocation pixelLocation, int zoomLevel)
 {
     SpownMapLevel(pixelLocation, zoomLevel, MapLevelAlign.Lower);
 }