Inheritance: MonoBehaviour
        public async Task<bool> Pin(TileInfo info)
        {
            System.Diagnostics.Contracts.Contract.Requires(info != null, "TileInfo");
            if (Exists(info))
                return true;

            var tile = new SecondaryTile()
            {
                TileId = info.TileId,
                DisplayName = info.DisplayName,
                Arguments = info.Arguments,
                PhoneticName = info.PhoneticName,
                LockScreenDisplayBadgeAndTileText = info.LockScreenDisplayBadgeAndTileText,
                LockScreenBadgeLogo = info.LockScreenBadgeLogo,
            };

            tile.VisualElements.BackgroundColor = info.VisualElements.BackgroundColor;
            tile.VisualElements.ForegroundText = info.VisualElements.ForegroundText;
            tile.VisualElements.ShowNameOnSquare150x150Logo = info.VisualElements.ShowNameOnSquare150x150Logo;
            tile.VisualElements.ShowNameOnSquare310x310Logo = info.VisualElements.ShowNameOnSquare310x310Logo;
            tile.VisualElements.ShowNameOnWide310x150Logo = info.VisualElements.ShowNameOnWide310x150Logo;
            tile.VisualElements.Square150x150Logo = info.VisualElements.Square150x150Logo;
            tile.VisualElements.Square30x30Logo = info.VisualElements.Square30x30Logo;
            tile.VisualElements.Square310x310Logo = info.VisualElements.Square310x310Logo;
            tile.VisualElements.Square70x70Logo = info.VisualElements.Square70x70Logo;
            tile.VisualElements.Wide310x150Logo = info.VisualElements.Wide310x150Logo;

            var result = await tile.RequestCreateForSelectionAsync(info.Rect(), info.RequestPlacement);
            return result;
        }
Exemple #2
0
 public bool areSame(TileInfo other)
 {
     if(other == null || !(other is TileInfo) ) {
         throw new System.ArgumentException("uncomparable other tile");
     }
     return type == other.type;
 }
		private string[] _subDomains; // for being able to access it from a background thread

		/// <summary>
		/// Initializes a new instance of the <see cref="WebTiledLayer"/> class.
		/// </summary>
		public WebTiledLayer()
		{
			//This default layer's spatial reference
			SpatialReference = new SpatialReference(Wkid);
			//Full extent fo the layer
			base.FullExtent = new Envelope(-CornerCoordinate, -CornerCoordinate, CornerCoordinate, CornerCoordinate)
			{
				SpatialReference = SpatialReference
			};
			//Set up tile information. Each tile is 256x256px, 19 levels.
			TileInfo = new TileInfo
			{
				Height = 256,
				Width = 256,
				Origin = new MapPoint(-CornerCoordinate, CornerCoordinate) { SpatialReference = SpatialReference },
				SpatialReference = SpatialReference,
				Lods = new Lod[19]
			};
			//Set the resolutions for each level. Each level is half the resolution of the previous one.
			double resolution = CornerCoordinate * 2 / 256;
			for (int i = 0; i < TileInfo.Lods.Length; i++)
			{
				TileInfo.Lods[i] = new Lod { Resolution = resolution };
				resolution /= 2;
			}
		}
        public static byte[] ToBitmap(IList<LayerInfo> layerInfos, TileInfo tileInfo)
        {
            var random = new Random();

            using (var bitmap = new Bitmap(TileWidth, TileHeight))
            using (var canvas = Graphics.FromImage(bitmap))
            {
                foreach (var layerInfo in layerInfos)
                {
                    foreach (var feature in layerInfo.FeatureCollection.Features)
                    {
                        if (feature.Geometry.Type == GeoJSONObjectType.Polygon)
                        {
                            var polygon = (Polygon) feature.Geometry;

                            foreach (var lineString in polygon.Coordinates)
                            {
                                canvas.Transform = CreateTransformMatrix(tileInfo);
                                using (var brush = new SolidBrush(
                                    Color.FromArgb(random.Next(256), random.Next(256), random.Next(256))))
                                {
                                    canvas.FillPolygon(brush, ToGdi(lineString));

                                }
                            }
                        }
                    }
                }

                return ToBytes(bitmap);
            }
        }
Exemple #5
0
        public override void Initialize()
        {
            FullExtent = new Envelope(-cornerCoordinate, -cornerCoordinate, cornerCoordinate, cornerCoordinate)
            {
                SpatialReference = new SpatialReference(WKID)
            };
            //This layer's spatial reference
            //Set up tile information. Each tile is 256x256px, 19 levels.
            TileInfo = new TileInfo
            {
                Height = 256,
                Width = 256,
                Origin = new MapPoint(-cornerCoordinate, cornerCoordinate) { SpatialReference = new SpatialReference(WKID) },
                Lods = new Lod[6]
            };
            //Set the resolutions for each level. Each level is half the resolution of the previous one.
            var resolution = cornerCoordinate * 2 / 256;
            for (var i = 0; i < TileInfo.Lods.Length; i++)
            {
                TileInfo.Lods[i] = new Lod { Resolution = resolution };
                resolution /= 2;
            }
            //Call base initialize to raise the initialization event
            base.Initialize();

            base.Initialize();
        }
 public override byte[] GetTile(TileInfo tileInfo)
 {
     var bytes = base.GetTile(tileInfo);
     var index = tileInfo.Index;
     var layerInfos = VectorTileParser.Parse(new MemoryStream(bytes), index.Col, index.Row, Int32.Parse(index.Level));
     return VectorTileConverter.ToBitmap(layerInfos, tileInfo);
 }
Exemple #7
0
        private static TileInfo InitializeTile(int id)
        {
            Bitmap bmp = Art.GetLand(id);

            if (bmp == null)
            {
                bmp = new Bitmap(44, 44);
                Graphics g = Graphics.FromImage(bmp);
                g.Clear(Color.Black);
                g.Dispose();
            }

            Bitmap[] images = new Bitmap[8];

            Color c = bmp.GetPixel(22, 22);

            images[0] = RotateTile(bmp, -45, 2, 2);
            images[1] = RotateTile(bmp, -45, 3, 3);
            images[2] = RotateTile(bmp, -45, 4, 4);
            images[3] = RotateTile(bmp, -45, 5, 5);
            images[4] = RotateTile(bmp, -45, 10, 10);
            images[5] = RotateTile(bmp, -45, 20, 20);
            images[6] = RotateTile(bmp, -45, 30, 30);

            TileInfo ti = new TileInfo(c, images);
            TileCache.Add(id,ti);

            bmp.Dispose();

            return ti;
        }
 public FileStore(string resource)
 {
     BasePath = resource;
     Directory.CreateDirectory(BasePath);
     
     // Get TileInfo
     string infopath = Path.Combine(BasePath, "metadata.json");
     if (File.Exists(infopath))
     {
         string json = File.ReadAllText(infopath);
         Info = JsonConvert.DeserializeObject<TileInfo>(
             json,
             new JsonSerializerSettings 
             { 
                 ContractResolver = new FileTileInfoContractResolver(),
                 NullValueHandling = NullValueHandling.Ignore,
                 Converters = new List<JsonConverter>() { new StringEnumConverter() { CamelCaseText = true } }
             }
        );
     }
     else 
     {
         Info = new TileInfo();
     }
 }
    //http://www.redblobgames.com/grids/hexagons/#range
    public static bool canHeroMoveToTile(HeroInfo heroInfo, TileInfo tileInfo)
    {
        if (heroInfo == null || tileInfo == null) {
            //Debug.Log ("something was null");
            return false;
        }

        if (tileInfo.UnitOnTile != null) {
            //Debug.Log ("something was on the tile");
            return false;
        }

        TileInfo heroTile = heroInfo.tile;

        int dX = tileInfo.x - heroTile.x;
        int dY = tileInfo.y - heroTile.y;
        int dZ = tileInfo.z - heroTile.z;

        float d = Mathf.Abs (dX) + Mathf.Abs (dY) + Mathf.Abs (dZ);

        d = d / 2;

        if (d <= heroInfo.move) {
            return true;
        }

        return false;
    }
 public TileSet(int numTiles)
 {
     tileInfos = new TileInfo[numTiles];
     for (int i = 0; i < numTiles; ++i)
     {
         tileInfos[i] = new TileInfo();
     }
 }
Exemple #11
0
 public void WmscRequest_Version130()
 {
     var request = new WmscRequest(new Uri("http://testserver.com"), new SphericalMercatorWorldSchema(), new List<string>(new string[] { "Layer One" }), null, null, "1.3.0");
     var ti = new TileInfo();
     var uri = request.GetUri(ti);
     StringAssert.Contains("VERSION=1.3.0", uri.ToString());
     StringAssert.Contains("CRS=", uri.ToString());
 }
Exemple #12
0
 public void WmscRequest_Version130()
 {
     var request = new WmscRequest(new Uri("http://testserver.com"), new GlobalSphericalMercator(YAxis.TMS), new List<string>(new[] { "Layer One" }), null, null, "1.3.0");
     var ti = new TileInfo { Index = new TileIndex(0, 0, "0") };
     var uri = request.GetUri(ti);
     StringAssert.Contains("VERSION=1.3.0", uri.ToString());
     StringAssert.Contains("CRS=", uri.ToString());
 }
 public static async Task<byte[]> GetTileAsync(this HttpTileSource tileSource, HttpClient httpClient, TileInfo tileInfo)
 {
     var bytes = tileSource.PersistentCache.Find(tileInfo.Index);
     if (bytes != null) return bytes;
     bytes = await httpClient.GetByteArrayAsync(tileSource.GetUri(tileInfo));
     if (bytes != null) tileSource.PersistentCache.Add(tileInfo.Index, bytes);
     return bytes;
 }
 public async Task<bool> Unpin(TileInfo info)
 {
     System.Diagnostics.Contracts.Contract.Requires(info != null, "TileInfo");
     if (!SecondaryTile.Exists(info.TileId))
         return true;
     var tile = new SecondaryTile(info.TileId);
     var result = await tile.RequestDeleteForSelectionAsync(info.Rect(), info.RequestPlacement);
     return result;
 }
Exemple #15
0
 /// <summary>
 /// Generates a URI at which to get the data for a tile.
 /// </summary>
 /// <param name="info">Information about a tile.</param>
 /// <returns>The URI at which to get the data for the specified tile.</returns>
 public Uri GetUri(TileInfo info)
 {
     var stringBuilder = new StringBuilder(_urlFormatter);
     stringBuilder.Replace(QuadKeyTag, TileXyToQuadKey(info.Index.Col, info.Index.Row, info.Index.Level));
     stringBuilder.Replace(ApiVersionTag, ApiVersion);
     stringBuilder.Replace(UserKeyTag, _userKey);
     InsertServerNode(stringBuilder, _serverNodes, ref _nodeCounter);
     return new Uri(stringBuilder.ToString());
 }
Exemple #16
0
        public Uri GetUri(TileInfo info)
        {
            var url = new StringBuilder();

            url.AppendFormat(CultureInfo.InvariantCulture, "{0}/{1}/{2}/{3}.{4}",
                _baseUrl, LevelToHex(info.Index.Level.ToString()), RowToHex(info.Index.Row), ColumnToHex(info.Index.Col), _format);
            AppendCustomParameters(url);
            return new Uri(url.ToString());
        }
 /// <summary>
 /// Generates a URI at which to get the data for a tile.
 /// </summary>
 /// <param name="info">Information about a tile.</param>
 /// <returns>The URI at which to get the data for the specified tile.</returns>
 public Uri GetUri(TileInfo info)
 {
     var url = new StringBuilder(GetUrlForLevel(info.Index.Level));
     InsertRandomServerNode(url, _serverNodes, _random);
     AppendXY(url, info);
     AppendImageFormat(url, _imageFormat);
     AppendCustomParameters(url, _customParameters);
     return new Uri(url.ToString());
 }
Exemple #18
0
 public static void swap(TileInfo one, TileInfo two)
 {
     int temp = one.row;
     one.row = two.row;
     two.row = temp;
     temp = one.column;
     one.column = two.column;
     two.column = temp;
 }
 static private async void UpdateTile(string url, TileInfo tileInfo)
 {
     await PopulateImages(tileInfo);
     var tileData = CreateTileData(tileInfo);
     var activeTile = ShellTile.ActiveTiles.FirstOrDefault(r => r.NavigationUri.ToString().EqualNoCase(url));
     if (activeTile != null)
     {
         activeTile.Update(tileData);
     }
 }
Exemple #20
0
 public byte[] GetTile(TileInfo tileInfo)
 {
     var bytes = _persistentCache.Find(tileInfo.Index);
     if (bytes == null)
     {
         bytes = RequestHelper.FetchImage(_webRequestFactory(_request.GetUri(tileInfo)));
         if (bytes != null) _persistentCache.Add(tileInfo.Index, bytes);
     }
     return bytes;
 }
 public byte[] GetTile(TileInfo tileInfo)
 {
     var bytes = _persistentCache.Find(tileInfo.Index);
     if (bytes == null)
     {
         bytes = _fetchTile(Request.GetUri(tileInfo));
         if (bytes != null) _persistentCache.Add(tileInfo.Index, bytes);
     }
     return bytes;
 }
Exemple #22
0
 /// <summary>
 /// Generates a URI at which to get the data for a tile.
 /// </summary>
 /// <param name="info">Information about a tile.</param>
 /// <returns>The URI at which to get the data for the specified tile.</returns>
 public Uri GetUri(TileInfo info)
 {
     var stringBuilder = new StringBuilder(_urlFormatter);
     stringBuilder.Replace(XTag, info.Index.Col.ToString(CultureInfo.InvariantCulture));
     stringBuilder.Replace(YTag, info.Index.Row.ToString(CultureInfo.InvariantCulture));
     stringBuilder.Replace(ZTag, info.Index.Level.ToString(CultureInfo.InvariantCulture));
     stringBuilder.Replace(ApiKeyTag, _apiKey);
     InsertServerNode(stringBuilder, _serverNodes, ref _nodeCounter);
     return new Uri(stringBuilder.ToString());
 }
 public override byte[] GetTile(TileInfo tileInfo)
 {
     var bytes = base.GetTile(tileInfo);
     var index = tileInfo.Index;
     var layerInfos = VectorTileParser.Parse(new MemoryStream(bytes), index.Col, index.Row, Int32.Parse(index.Level));
     var tileWidth = Schema.GetTileWidth(tileInfo.Index.Level);
     var tileHeight = Schema.GetTileHeight(tileInfo.Index.Level);
     var geoJSONRenderer = new GeoJSONToOpenTKRenderer(tileWidth, tileHeight, ToGeoJSONArray(tileInfo.Extent));
     return geoJSONRenderer.Render(layerInfos.Select(i => i.FeatureCollection));
 }
 static private async Task PopulateImages(TileInfo tileInfo)
 {
     if (!String.IsNullOrEmpty(tileInfo.BackgroundImagePath))
     {
         tileInfo.BackgroundImagePath = await PopulateImage(tileInfo.BackgroundImagePath);
     }
     if (!String.IsNullOrEmpty(tileInfo.BackBackgroundImagePath))
     {
         tileInfo.BackBackgroundImagePath = await PopulateImage(tileInfo.BackBackgroundImagePath);
     }
 }
Exemple #25
0
        public Uri GetUri(TileInfo info)
        {
            var urlFormatter = GetNextServerNode();
            var stringBuilder = new StringBuilder(urlFormatter.Template);

            stringBuilder.Replace(XTag, info.Index.Col.ToString(CultureInfo.InvariantCulture));
            stringBuilder.Replace(YTag, info.Index.Row.ToString(CultureInfo.InvariantCulture));
            stringBuilder.Replace(ZTag, info.Index.Level);

            return new Uri(stringBuilder.ToString());
        }
		public async Task Unpin(Windows.UI.Xaml.FrameworkElement anchorElement)
		{
			// Unpin, then delete the feed item locally.
			var tileInfo = new TileInfo(this.FormatSecondaryTileId(), anchorElement, Windows.UI.Popups.Placement.Above);
			this.IsFeedItemPinned = !await this.secondaryPinner.Unpin(tileInfo);

			if (!this.IsFeedItemPinned)
			{
				await RemovePinnedFeedItem();
			}
		}
Exemple #27
0
        public void GetUriTest()
        {
            // arrange
            var request = new BasicRequest("http://{S}.tile.openstreetmap.org/{Z}/{X}/{Y}.png", new[] {"a", "b", "c"});
            var tileInfo = new TileInfo {Index = new TileIndex(3, 4, 5)};
        
            // act
            var url = request.GetUri(tileInfo);

            // assert
            Assert.True(url.ToString() == "http://a.tile.openstreetmap.org/5/3/4.png");
        }
 static private StandardTileData CreateTileData(TileInfo tileInfo)
 {
     return new StandardTileData
     {
         Title = HtmlUtil.CleanHtml(tileInfo.Title),
         Count = tileInfo.Count,
         BackTitle = HtmlUtil.CleanHtml(tileInfo.BackTitle),
         BackContent = HtmlUtil.CleanHtml(tileInfo.BackContent),
         BackgroundImage = String.IsNullOrEmpty(tileInfo.BackgroundImagePath) ? null : new Uri(tileInfo.BackgroundImagePath, UriKind.RelativeOrAbsolute),
         BackBackgroundImage = String.IsNullOrEmpty(tileInfo.BackBackgroundImagePath) ? null : new Uri(tileInfo.BackBackgroundImagePath, UriKind.RelativeOrAbsolute)
     };
 }
Exemple #29
0
        public void WhenInitializedWithServerNodesShouldReturnCorrectUri()
        {
            // arrange
            var request = new TmsRequest("http://{S}.tileserver.com", "png", new[] { "a", "b"});
            var tileInfo = new TileInfo { Index = new TileIndex(1, 2, 3) };
            
            // act
            var uri = request.GetUri(tileInfo);

            // assert
            Assert.True(new [] { "http://a.tileserver.com/3/1/2.png", "http://b.tileserver.com/3/1/2.png" }.Contains(uri.ToString()));
        }
Exemple #30
0
        public void WhenInitializedShouldReturnCorrectUri()
        {
            // arrange
            var request = new TmsRequest("http://tileserver.com", "png");
            var tileInfo = new TileInfo {Index = new TileIndex(1, 2, 3)};
            
            // act
            var uri = request.GetUri(tileInfo);

            // assert
            Assert.AreEqual(uri.ToString(), "http://tileserver.com/3/1/2.png"); 
        }
Exemple #31
0
 public void WriteSlotValue(int x, int y, TileInfo tileInfo)
 {
     m_data[y, x] = tileInfo;
     OnChanged(EventArgs.Empty);
 }
Exemple #32
0
 public void SetTileTypeAt(int x, int y, TileInfo tile)
 {
     tiles[x, y].tileType = tile.name;
 }
Exemple #33
0
 private bool IsTilePassable(TileInfo tile)
 {
     return tile.Height > WaterLevel & tile.Feature != TileFeature.River & tile.Feature != TileFeature.Mountain;
 }
Exemple #34
0
 public byte[] GetTile(TileInfo tileInfo)
 {
     return(_dictionary[tileInfo.Index]);
 }
Exemple #35
0
        public async Task Run(GameContext context, BaseWorkerWindow vm, Action <string> statusUpdater, CancellationToken cancellationToken)
        {
            using (NDC.Push("Mapper Worker")) {
                await Task.Delay(1);

                var map    = new WorldMap(context);
                var stride = (int)Math.Ceiling(484D / SubScanBounds.Width);
                var scans  = (int)Math.Ceiling(484D / SubScanBounds.Height);
                var linear = Phase;
                ProcessedTiles = RecognizedTiles = FailedTiles = 0;
                TotalTiles     = 484 * 484 / Period;

                TileInfo[][] mapData = null;
                var          clog    = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "logs", "map.json");
                var          ilog    = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "logs", "tiles");
                var          jss     = new JsonSerializerSettings {
                    TypeNameHandling = TypeNameHandling.All
                };
                if (!Directory.Exists(Path.GetDirectoryName(clog)))
                {
                    Directory.CreateDirectory(clog);
                }
                if (!Directory.Exists(ilog))
                {
                    Directory.CreateDirectory(ilog);
                }
                if (File.Exists(clog))
                {
                    try {
                        mapData = JsonConvert.DeserializeObject <TileInfo[][]>(File.ReadAllText(clog), jss);
                    } catch {
                    }
                }

                if (mapData == null || mapData.Length != 492)
                {
                    mapData = new TileInfo[492][];
                }
                for (var i = 0; i < mapData.Length; i++)
                {
                    if (mapData[i] == null || mapData[i].Length != 492)
                    {
                        mapData[i] = new TileInfo[492];
                    }
                }

                while (!cancellationToken.IsCancellationRequested)
                {
                    if (linear > stride * scans)
                    {
                        break;
                    }
                    var cx = 8 + (linear % stride) * SubScanBounds.Width - SubScanBounds.X;
                    var cy = 8 + (linear / stride) * SubScanBounds.Height - SubScanBounds.Y;
                    statusUpdater($"Mapping at {cx},{cy} ({linear})");

                    if (!map.IsScreenActive())
                    {
                        await Task.Delay(500, cancellationToken);

                        if (!map.IsScreenActive())
                        {
                            Logger.Fatal("World map screen not detected! Bailing out.");
                            throw new InvalidOperationException("Not on the world map screen");
                        }
                    }

                    var needTiles = 0;
                    for (var xx = SubScanBounds.Left; xx < SubScanBounds.Right; xx++)
                    {
                        for (var yy = SubScanBounds.Top; yy < SubScanBounds.Bottom; yy++)
                        {
                            if (xx + cx < 8 || xx + cx > 492 || yy + cy < 8 || yy + cy > 492)
                            {
                                continue;
                            }
                            ProcessedTiles++;
                            if (mapData[cx + xx][cy + yy] == null)
                            {
                                needTiles++;
                            }
                        }
                    }

                    cancellationToken.ThrowIfCancellationRequested();
                    if (needTiles > 0)
                    {
                        statusUpdater($"Mapping {needTiles} tiles at {cx},{cy} ({linear})");
                        await map.GoTo(cx, cy, cancellationToken);

                        for (var xx = SubScanBounds.Left; xx < SubScanBounds.Right; xx++)
                        {
                            for (var yy = SubScanBounds.Top; yy < SubScanBounds.Bottom; yy++)
                            {
                                if (xx + cx < 8 || xx + cx > 492 || yy + cy < 8 || yy + cy > 492)
                                {
                                    continue;
                                }
                                mapData[cx + xx][cy + yy] = await map.SelectTile(xx, yy, Path.Combine(ilog, $"tile{cx + xx},{cy + yy}"), cancellationToken);

                                if (mapData[cx + xx][cy + yy] != null)
                                {
                                    mapData[cx + xx][cy + yy].CenterPoint = new Point(cx + xx, cy + yy);
                                    RecognizedTiles++;
                                }
                                else
                                {
                                    FailedTiles++;
                                }
                            }
                        }

                        File.WriteAllText(clog, JsonConvert.SerializeObject(mapData, jss));
                    }

                    linear += Period;
                }
            }
        }
Exemple #36
0
 public Uri GetUri(TileInfo tileInfo)
 {
     return(_request.GetUri(tileInfo));
 }
Exemple #37
0
 private void SortLayers()
 {
     lock (board.ParentControl)
     {
         for (int i = 0; i < 2; i++)
         {
             TileObjs.Sort(
                 delegate(LayeredItem a, LayeredItem b)
             {
                 if (a.Layer.LayerNumber > b.Layer.LayerNumber)
                 {
                     return(1);
                 }
                 else if (a.Layer.LayerNumber < b.Layer.LayerNumber)
                 {
                     return(-1);
                 }
                 else
                 {
                     if (a is TileInstance && b is TileInstance)
                     {
                         TileInfo ai = (TileInfo)a.BaseInfo;
                         TileInfo bi = (TileInfo)b.BaseInfo;
                         if (ai.z > bi.z)
                         {
                             return(1);
                         }
                         else if (ai.z < bi.z)
                         {
                             return(-1);
                         }
                         else
                         {
                             if (a.Z > b.Z)
                             {
                                 return(1);
                             }
                             else if (a.Z < b.Z)
                             {
                                 return(-1);
                             }
                             else
                             {
                                 return(0);
                             }
                         }
                     }
                     if (a is ObjectInstance && b is ObjectInstance)
                     {
                         if (a.Z > b.Z)
                         {
                             return(1);
                         }
                         else if (a.Z < b.Z)
                         {
                             return(-1);
                         }
                         else
                         {
                             return(0);
                         }
                     }
                     else if (a is TileInstance && b is ObjectInstance)
                     {
                         return(1);
                     }
                     else
                     {
                         return(-1);
                     }
                 }
             }
                 );
         }
     }
 }
Exemple #38
0
    void pre_build_check()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hitinfo;

        //		MeshCollider collider = GetComponent<MeshCollider> ();
        MeshCollider collider = tile_map.GetComponent <MeshCollider> ();

        //MeshRenderer renderer = GetComponent<MeshRenderer> ();

        if (collider.Raycast(ray, out hitinfo, Mathf.Infinity))
        {
            Vector3 local_position = transform.InverseTransformPoint(hitinfo.point);
            Debug.Log("local position: " + local_position);

            Vector3 tile_position = new Vector3(Mathf.Floor(local_position.x), local_position.y + 0.01f, Mathf.Floor(local_position.z));

            Debug.Log("tile_position: " + tile_position);

            //game_object.SetActive(true);
            //Vector3 current_tile = new Vector3( hitinfo.point.x /
            //game_object.transform.position = tile_position;

            building_cursor.transform.position = tile_position;

            //game_object.GetComponent<MeshRenderer> ().material.color = Color.green;

            //if (BuildingCheck.can_build (tile_position, tile_map.GetComponent<TileMap>().tile_info_, game_object.GetComponent<Building> () ) )
            if (BuildingCheck.can_build(tile_position, tile_map.GetComponent <TileMap>().tile_info_, building_cursor.GetComponent <Building> ()))
            {
                building_cursor.GetComponentInChildren <MeshRenderer> ().material.color = Color.green;
                //game_object.GetComponentInChildren<MeshRenderer> ().material.color = Color.green;
            }
            else
            {
                building_cursor.GetComponentInChildren <MeshRenderer> ().material.color = Color.red;
                //game_object.GetComponentInChildren<MeshRenderer> ().material.color = Color.red;
            }

            if (Input.GetMouseButton(0))
            {
                if (game_object.GetComponentInChildren <MeshRenderer> ().material.color == Color.green)
                {
                    //build
                    Building building = game_object.GetComponent <Building>();

                    for (int x = 0; x < building.size_x; ++x)
                    {
                        for (int y = 0; y < building.size_y; ++y)
                        {
                            Vector2 pos = new Vector2(tile_position.x + x, tile_position.z + y);
                            if (tile_map.GetComponent <TileMap>().tile_info_.ContainsKey(pos))
                            {
                                TileInfo info = tile_map.GetComponent <TileMap>().tile_info_ [pos];
                                info.building = game_object;
                            }
                        }
                    }
                    //free game_object
                    game_object = Instantiate(game_object);
                }
            }
        }
        else
        {
            //renderer.material.color = Color.green;
        }
    }
Exemple #39
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cancelToken"></param>
        /// <param name="tileProvider"></param>
        /// <param name="tileInfo"></param>
        /// <param name="bitmaps"></param>
        /// <param name="retry"></param>
        /// <returns>true if thread finished without getting cancellation signal, false = cancelled</returns>
        private bool GetTileOnThread(CancellationToken cancelToken, ITileProvider tileProvider, TileInfo tileInfo, MemoryCache <Bitmap> bitmaps, bool retry)
        {
            byte[] bytes;
            try
            {
                if (cancelToken.IsCancellationRequested)
                {
                    cancelToken.ThrowIfCancellationRequested();
                }


                //We may have gotten the tile from another thread now..
                if (bitmaps.Find(tileInfo.Index) != null)
                {
                    return(true);
                }

                if (Logger.IsDebugEnabled)
                {
                    Logger.DebugFormat("Calling gettile on provider for tile {0},{1},{2}", tileInfo.Index.Level, tileInfo.Index.Col, tileInfo.Index.Row);
                }

                bytes = tileProvider.GetTile(tileInfo);
                if (cancelToken.IsCancellationRequested)
                {
                    cancelToken.ThrowIfCancellationRequested();
                }

                using (var ms = new MemoryStream(bytes))
                {
                    Bitmap bitmap = new Bitmap(ms);
                    bitmaps.Add(tileInfo.Index, bitmap);
                    if (_fileCache != null && !_fileCache.Exists(tileInfo.Index))
                    {
                        AddImageToFileCache(tileInfo, bitmap);
                    }


                    if (cancelToken.IsCancellationRequested)
                    {
                        cancelToken.ThrowIfCancellationRequested();
                    }
                    OnMapNewTileAvaliable(tileInfo, bitmap);
                }
                return(true);
            }
            catch (WebException ex)
            {
                if (Logger.IsDebugEnabled)
                {
                    Logger.DebugFormat("Exception downloading tile {0},{1},{2} {3}", tileInfo.Index.Level, tileInfo.Index.Col, tileInfo.Index.Row, ex.Message);
                }

                if (retry)
                {
                    return(GetTileOnThread(cancelToken, tileProvider, tileInfo, bitmaps, false));
                }
                else
                {
                    if (_showErrorInTile)
                    {
                        var tileWidth  = _source.Schema.GetTileWidth(tileInfo.Index.Level);
                        var tileHeight = _source.Schema.GetTileHeight(tileInfo.Index.Level);
                        //an issue with this method is that one an error tile is in the memory cache it will stay even
                        //if the error is resolved. PDD.
                        var bitmap = new Bitmap(tileWidth, tileHeight);
                        using (var graphics = Graphics.FromImage(bitmap))
                        {
                            graphics.DrawString(ex.Message, new Font(FontFamily.GenericSansSerif, 12), new SolidBrush(Color.Black),
                                                new RectangleF(0, 0, tileWidth, tileHeight));
                        }
                        //Draw the Timeout Tile
                        OnMapNewTileAvaliable(tileInfo, bitmap);
                        //With timeout we don't add to the internal cache
                        //bitmaps.Add(tileInfo.Index, bitmap);
                    }
                    return(true);
                }
            }
            catch (System.OperationCanceledException tex)
            {
                if (Logger.IsInfoEnabled)
                {
                    Logger.InfoFormat("TileAsyncLayer - Thread aborting: {0}", Thread.CurrentThread.Name);
                    Logger.InfoFormat(tex.Message);
                }
                return(false);
            }
            catch (Exception ex)
            {
                Logger.Warn("TileAsyncLayer - GetTileOnThread Exception", ex);
                //This is not due to cancellation so return true
                return(true);
            }
        }
Exemple #40
0
 public static Tile Parse(TileInfo tileInfo)
 {
     return(new Tile(tileInfo.RowNumber, tileInfo.ColumnNumber, tileInfo.ZoomLevel));
 }
Exemple #41
0
 public TileCacheTracker(TileInfo tileInfo)
 {
     TileInfo       = tileInfo ?? throw new ArgumentNullException(nameof(tileInfo));
     LevelsOfDetail = tileInfo.LevelsOfDetail.Select(x => new TileCacheTrackerLevel(tileInfo, x)).OrderByDescending(x => x.LevelOfDetail.Scale).ToArray();
 }
Exemple #42
0
        public static byte[] GetTileAsJpeg(this DeepZoomGenerator dz, int level, int locationX, int locationY, out TileInfo info, int quality = 75)
        {
            if (dz == null)
            {
                throw new ArgumentNullException(nameof(dz));
            }

            var tileInfo = dz.GetTileInfo(level, locationX, locationY);

            info = tileInfo;
            using (var image = new Image <Rgba32>((int)tileInfo.Width, (int)tileInfo.Height))
            {
                WriteImage(dz, image, tileInfo);

                byte[] buffer = ArrayPool <byte> .Shared.Rent(EnsureMinimumSize(tileInfo.TileWidth *tileInfo.TileHeight * 4 * 2));

                try
                {
                    using (var ms = new MemoryStream(buffer))
                    {
                        image.SaveAsJpeg(ms, new JpegEncoder()
                        {
                            Quality = quality
                        });
                        ms.SetLength(ms.Position);
                        return(ms.ToArray());
                    }
                }
                finally
                {
                    ArrayPool <byte> .Shared.Return(buffer);
                }
            }
        }
Exemple #43
0
    private void DisplayTileConnections(RaycastHit hit)
    {
        TileInfo parentsInfo = hit.transform.GetComponentInParent <TileInfo>();

        parentsInfo.tileNode.DisplayConnections();
    }
Exemple #44
0
 public void WriteSlotValue(Vector2 pos, TileInfo tileInfo)
 {
     WriteSlotValue((int)pos.x, (int)pos.y, tileInfo);
 }
Exemple #45
0
        private void GetTileOnThread(object parameter)
        {
            object[] parameters = (object[])parameter;
            if (parameters.Length != 6)
            {
                throw new ArgumentException("Six parameters expected");
            }
            ITileProvider tileProvider = (ITileProvider)parameters[0];
            TileInfo      tileInfo     = (TileInfo)parameters[1];
            //MemoryCache<Bitmap> bitmaps = (MemoryCache<Bitmap>)parameters[2];
            var            bitmaps        = (ConcurrentDictionary <TileIndex, Bitmap>)parameters[2];
            AutoResetEvent autoResetEvent = (AutoResetEvent)parameters[3];
            bool           retry          = (bool)parameters[4];
            var            takenFromCache = (IDictionary <TileIndex, bool>)parameters[5];

            var setEvent = true;

            try
            {
                byte[] bytes  = tileProvider.GetTile(tileInfo);
                Bitmap bitmap = new Bitmap(new MemoryStream(bytes));
                bitmaps.TryAdd(tileInfo.Index, bitmap);

                // this bitmap will later be memory cached
                takenFromCache.Add(tileInfo.Index, false);

                // add to persistent cache if enabled
                if (_fileCache != null)
                {
                    AddImageToFileCache(tileInfo, bitmap);
                }
            }
            catch (WebException ex)
            {
                if (retry)
                {
                    GetTileOnThread(new object[] { tileProvider, tileInfo, bitmaps, autoResetEvent, false, takenFromCache });
                    setEvent = false;
                    return;
                }
                if (_showErrorInTile)
                {
                    try
                    {
                        //an issue with this method is that one an error tile is in the memory cache it will stay even
                        //if the error is resolved. PDD.
                        var tileWidth  = _source.Schema.GetTileWidth(tileInfo.Index.Level);
                        var tileHeight = _source.Schema.GetTileHeight(tileInfo.Index.Level);
                        var bitmap     = new Bitmap(tileWidth, tileHeight);
                        using (var graphics = Graphics.FromImage(bitmap))
                        {
                            graphics.DrawString(ex.Message, new Font(FontFamily.GenericSansSerif, 12),
                                                new SolidBrush(Color.Black),
                                                new RectangleF(0, 0, tileWidth, tileHeight));
                        }
                        bitmaps.TryAdd(tileInfo.Index, bitmap);
                    }
                    catch (Exception e)
                    {
                        // we don't want fatal exceptions here!
                        Logger.Error(e);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
            }
            finally
            {
                if (setEvent)
                {
                    autoResetEvent.Set();
                }
            }
        }
Exemple #46
0
        //DrawingVisual Approach
        public Path AsTileUsingDrawingVisual(List <SqlGeometry> geometries, List <string> labels, double mapScale, TileInfo region, double tileWidth, double tileHeight, RectangleGeometry area, Func <Point, Point> viewTransform, sb.BoundingBox totalExtent)
        {
            if (geometries == null)
            {
                return(null);
            }

            //Pen pen = new Pen(this.VisualParameters.Stroke, this.VisualParameters.StrokeThickness);

            //if (this.VisualParameters.DashStyle != null)
            //{
            //    pen.DashStyle = this.VisualParameters.DashStyle;
            //}
            var pen = this.VisualParameters.GetWpfPen();

            Brush brush = this.VisualParameters.Fill;

            var transform = MapToTileScreenWpf(totalExtent, region.WebMercatorExtent, viewTransform);

            var drawingVisual = new SqlSpatialToDrawingVisual().ParseSqlGeometry(geometries, transform, pen, brush, this.VisualParameters.PointSize, this.PointSymbol);

            RenderTargetBitmap image = new RenderTargetBitmap((int)tileWidth, (int)tileHeight, 96, 96, PixelFormats.Pbgra32);

            image.Render(drawingVisual);

            if (labels != null)
            {
                this.DrawLabels(labels, geometries, image, transform);
            }

            image.Freeze();

            Path path = new Path()
            {
                Data = area,
                Tag  = new LayerTag(mapScale)
                {
                    Layer = this, IsTiled = true, Tile = region, IsDrawn = true, IsNew = true
                }
            };

            this.Element = path;

            path.Fill = new ImageBrush(image);

            return(path);
        }
Exemple #47
0
        public override byte[]? GetTile(TileInfo tileInfo)
        {
            base.GetTile(tileInfo); // Just for counting

            return(null);
        }
 public byte[] GetTile(TileInfo tileInfo)
 {
     return(Provider.GetTile(tileInfo));
 }
Exemple #49
0
        private void GetTileOnThread(BackgroundWorker worker, object parameter)
        {
            System.Threading.Thread.Sleep(50 + (r.Next(5) * 10));
            object[] parameters = (object[])parameter;
            if (parameters.Length != 4)
            {
                throw new ArgumentException("Four parameters expected");
            }
            ITileProvider        tileProvider = (ITileProvider)parameters[0];
            TileInfo             tileInfo     = (TileInfo)parameters[1];
            MemoryCache <Bitmap> bitmaps      = (MemoryCache <Bitmap>)parameters[2];
            bool retry = (bool)parameters[3];


            byte[] bytes;
            try
            {
                if (worker.CancellationPending == true)
                {
                    return;
                }
                bytes = tileProvider.GetTile(tileInfo);
                if (worker.CancellationPending == true)
                {
                    return;
                }
                Bitmap bitmap = new Bitmap(new MemoryStream(bytes));
                bitmaps.Add(tileInfo.Index, bitmap);
                if (_fileCache != null && !_fileCache.Exists(tileInfo.Index))
                {
                    AddImageToFileCache(tileInfo, bitmap);
                }

                if (worker.CancellationPending == true)
                {
                    return;
                }
                OnMapNewTileAvaliable(tileInfo, bitmap);
                if (worker.CancellationPending == true)
                {
                    return;
                }
            }
            catch (WebException ex)
            {
                if (retry == true)
                {
                    parameters[3] = false;
                    GetTileOnThread(worker, parameters);
                }
                else
                {
                    if (_showErrorInTile)
                    {
                        //an issue with this method is that one an error tile is in the memory cache it will stay even
                        //if the error is resolved. PDD.
                        Bitmap   bitmap   = new Bitmap(_source.Schema.Width, _source.Schema.Height);
                        Graphics graphics = Graphics.FromImage(bitmap);
                        graphics.DrawString(ex.Message, new Font(FontFamily.GenericSansSerif, 12), new SolidBrush(Color.Black),
                                            new RectangleF(0, 0, _source.Schema.Width, _source.Schema.Height));
                        //Draw the Timeout Tile
                        OnMapNewTileAvaliable(tileInfo, bitmap);

                        //With timeout we don't add to the internal cache
                        //bitmaps.Add(tileInfo.Index, bitmap);
                    }
                }
            }
            catch (ThreadAbortException tex)
            {
                Console.WriteLine("TileAsyncLayer - Thread aborting: " + System.Threading.Thread.CurrentThread.Name);
            }
            catch (Exception ex)
            {
                Console.WriteLine("TileAsyncLayer - GetTileOnThread Exception: " + ex.ToString());
                //todo: log and use other ways to report to user.
            }
        }
Exemple #50
0
    private int groundMinheight = 1; //최소 floor 높이값
    /// <summary>
    /// 땅 생성 
    /// </summary>
    /// <param name="floortilelength"></param>
    /// <param name="groundtilelength"></param>
    public void SetGroundHegihtRandomly(int floortilelength, int groundtilelength)
    {
        int beforeheight = Random.Range(groundMinheight, (int)(room.yMax / 3));
        int currentheight = beforeheight;
        int beforewidth = 5;
        bool changeheight = false; //높이가 바뀔 때 설정

        int heightgapcount = 0;

        for (int i = 0; i < room.xMax; i++)
        {
            for (int j = currentheight; j >= 0; j--)
            {
                //제일 위일 경우 floor를 생성 
                if (j.Equals(currentheight))
                {
                    roomArray[i, j] = new TileInfo(TileType.Floor, Random.Range(0, floortilelength));
                }
                else
                {
                    //높이가 바뀌지 않을 경우 
                    if (!changeheight)
                    {
                        roomArray[i, j] = new TileInfo(TileType.Ground, Random.Range(0, groundtilelength));
                    }
                    //높이 바뀔 경우
                    else
                    {
                        heightgapcount = Mathf.Abs(beforeheight - currentheight);
                        //gap count가 1이하면 그대로 생성
                        if (heightgapcount < 1)
                        {
                            roomArray[i, j] = new TileInfo(TileType.Ground, Random.Range(0, groundtilelength));
                        }
                        //gap count가 2이상일 경우 생성
                        else
                        {
                            //땅이 높아질 경우 현재 땅들을 변경
                            if (beforeheight < currentheight)
                            {
                                //현재 j값의 - gapcount만큼 j값을 감소시키면서 셋팅함
                                var currentjvalue = j;
                                for (; j > (currentjvalue - heightgapcount); j--)
                                {
                                    roomArray[i, j] = new TileInfo(TileType.Wall, 0);
                                }

                            }
                            //땅이 낮아질 경우 이전 땅들을 변경 i-1 
                            else if (beforeheight > currentheight)
                            {
                                //현재 j값을 건들지 않고 처리 
                                var currentjvalue = j;
                                for (int k = currentjvalue + 1; k <= currentjvalue + heightgapcount; k++)
                                {
                                    roomArray[i - 1, k] = new TileInfo(TileType.Wall, 1);
                                }
                            }
                            roomArray[i, j] = new TileInfo(TileType.Ground, Random.Range(0, groundtilelength));
                            changeheight = false;
                        }
                    }
                }
            }

            //높이 변경 및 넓이 설정
            beforewidth--;
            if (beforewidth <= 0)
            {
                beforeheight = currentheight;
                //랜덤으로 설정할 경우 -가 계속되어 1이하로 내려가는 경우가 생기기 때문에 tmph를 따로 설정 하여 currenth를 따로 초기화
                var tmpH = Random.Range(-groundHeightValue, groundHeightValue);
                currentheight = (currentheight + tmpH >= groundMinheight) ? currentheight + tmpH : groundMinheight;

                beforewidth = Random.Range(groundWidthMin, groundWidthMax);

                changeheight = true;
            }
        }
    }
Exemple #51
0
 /// <summary>
 /// Generates a URI at which to get the data for a tile.
 /// </summary>
 /// <param name="info">Information about a tile.</param>
 /// <returns>The URI at which to get the data for the specified tile.</returns>
 public Uri GetUri(TileInfo info)
 {
     return(new Uri(_fixedUrl + $"&BBOX={info.Extent}"));
 }
Exemple #52
0
    private void InteractWithTile(RaycastHit hit)
    {
        TileInfo parentsInfo = hit.transform.GetComponentInParent <TileInfo>();

        parentsInfo.InteractWithTile();
    }
Exemple #53
0
 public DataChangedEventArgs(Exception error, bool cancelled, TileInfo tileInfo)
     : this(error, cancelled, tileInfo, string.Empty)
 {
 }
Exemple #54
0
        private void DownloadTiles(object args)
        {
            var downloadFinished = args as ManualResetEvent;

            // Loop through the tiles, and filter tiles that are already on disk.
            var downloadTiles = new List <TileInfo>();

            for (var i = 0; i < _tiles.Count(); i++)
            {
                if (!_fileCache.Exists(_tiles[i].Index))
                {
                    downloadTiles.Add(_tiles[i]);
                }
                else
                {
                    // Read tiles from disk
                    var name = _fileCache.GetFileName(_tiles[i].Index);

                    // Determine age of tile...
                    var fi = new FileInfo(name);
                    if ((DateTime.Now - fi.LastWriteTime).Days <= _tileTimeOut)
                    {
                        continue;
                    }
                    File.Delete(name);
                    downloadTiles.Add(_tiles[i]);
                }
            }

            if (downloadTiles.Count > 0)
            {
                int count    = 1;
                int allCount = 100;
                while ((count - 1) * allCount < downloadTiles.Count)
                {
                    try
                    {
                        int temp = allCount;
                        if (count * allCount > downloadTiles.Count)
                        {
                            temp = downloadTiles.Count - (count - 1) * allCount;
                        }
                        var doneEvents = new MultipleThreadResetEvent(temp);
                        ThreadPool.SetMaxThreads(25, 25);
                        for (int i = 0; i < temp; i++)
                        {
                            TileInfo t = downloadTiles[(count - 1) * allCount + i];
                            object   o = new object[] { t, doneEvents };
                            ThreadPool.QueueUserWorkItem(DownloadTile, o);
                        }
                        doneEvents.WaitAll();
                        doneEvents.Dispose();
                        //Thread.Sleep(10);
                        count++;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("下载异常:" + ex.Message);
                    }
                }
            }

            if (downloadFinished != null)
            {
                downloadFinished.Set();
            }
        }
Exemple #55
0
        //Gdi+ Approach
        public Path AsTileUsingGdiPlusAsync(List <SqlGeometry> geometries, List <string> labels, double mapScale, TileInfo region, double tileWidth, double tileHeight, RectangleGeometry area, Func <Point, Point> transform, sb.BoundingBox totalExtent)
        {
            if (geometries == null)
            {
                return(null);
            }

            //var pen = this.VisualParameters.Stroke != null ? new System.Drawing.Pen(this.VisualParameters.Stroke.AsGdiBrush(), (int)this.VisualParameters.StrokeThickness) : null;

            //if (this.VisualParameters.DashStyle != null)
            //{
            //    pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
            //}

            var pen = this.VisualParameters.GetGdiPlusPen();

            var shiftX = region.WebMercatorExtent.Center.X - totalExtent.TopLeft.X - region.WebMercatorExtent.Width / 2.0;
            var shiftY = region.WebMercatorExtent.Center.Y - totalExtent.TopLeft.Y + region.WebMercatorExtent.Height / 2.0;
            //;

            //var transform = MapToTileScreenWpf(totalExtent, region.MercatorExtent, viewTransform);
            //var mapShift = new Point(region.MercatorExtent.Center.X - totalExtent.TopLeft.X, region.MercatorExtent.Center.Y - totalExtent.BottomRight.Y);
            //var mapShift = (mapBoundingBoxOfTile.Center - new sb.Point(totalExtent.TopLeft.X + mapBoundingBoxOfTile.Width / 2.0, totalExtent.TopLeft.Y - mapBoundingBoxOfTile.Height / 2.0)).AsWpfPoint();


            var image = SqlSpatialToGdiBitmap.ParseSqlGeometry(
                geometries,
                tileWidth,
                tileHeight,
                //transform,
                p => transform(new Point(p.X - shiftX, p.Y - shiftY)),
                pen,
                this.VisualParameters.Fill.AsGdiBrush(),
                this.VisualParameters.PointSize,
                this.PointSymbol);

            if (image == null)
            {
                return(null);
            }

            if (labels != null)
            {
                //96.05.19
                //SqlSpatialToGdiBitmap.DrawLabels(labels, geometries, image, transform, Labels);
            }

            var bitmapImage = IRI.Jab.Common.Helpers.ImageUtility.AsBitmapImage(image, System.Drawing.Imaging.ImageFormat.Png);

            image.Dispose();

            Path path = new Path()
            {
                Data = area,
                Tag  = new LayerTag(mapScale)
                {
                    Layer = this, IsTiled = true, Tile = new TileInfo(region.RowNumber, region.ColumnNumber, region.ZoomLevel), IsDrawn = true, IsNew = true
                }
            };

            this.Element = path;

            path.Fill = new ImageBrush(bitmapImage);

            return(path);
        }
Exemple #56
0
 public Uri GetUri(TileInfo info)
 {
     return(OsmConfig.GetUri(info.Index));
 }
Exemple #57
0
        //Writeable Bitmap Approach
        //Consider Labeling
        public Path AsTileUsingWriteableBitmap(List <SqlGeometry> geometries, List <string> labels, double mapScale, TileInfo region, double tileWidth, double tileHeight, RectangleGeometry area, Func <Point, Point> viewTransform, sb.BoundingBox totalExtent)
        {
            if (geometries == null)
            {
                return(null);
            }

            Brush brush = this.VisualParameters.Fill;

            var color = ((SolidColorBrush)this.VisualParameters.Stroke)?.Color ?? ((SolidColorBrush)this.VisualParameters.Fill).Color;

            //var pen = new System.Drawing.Pen(System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B), (int)this.VisualParameters.StrokeThickness);

            //if (this.VisualParameters.DashStyle != null)
            //{
            //    pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
            //}

            var transform = MapToTileScreenWpf(totalExtent, region.WebMercatorExtent, viewTransform);

            var image = new SqlSpatialToWriteableBitmap().ParseSqlGeometry(
                geometries,
                transform,
                (int)tileWidth,
                (int)tileHeight,
                this.VisualParameters.Stroke.AsSolidColor().Value,
                this.VisualParameters.Fill.AsSolidColor().Value);

            if (image == null)
            {
                return(null);
            }

            Path path = new Path()
            {
                Data = area,
                Tag  = new LayerTag(mapScale)
                {
                    Layer = this, IsTiled = true, Tile = region, IsDrawn = true, IsNew = true
                }
            };

            this.Element = path;

            path.Fill = new ImageBrush(image);

            return(path);
        }
Exemple #58
0
        //OpenTK Approach
        public Path AsTileUsinOpenTK(List <SqlGeometry> geometries, List <string> labels, double mapScale, TileInfo region, double tileWidth, double tileHeight, RectangleGeometry area, Func <Point, Point> viewTransform, sb.BoundingBox totalExtent)
        {
            if (geometries == null)
            {
                return(null);
            }

            //Brush brush = this.VisualParameters.Fill;

            //var color = ((SolidColorBrush)this.VisualParameters.Stroke)?.Color ?? ((SolidColorBrush)this.VisualParameters.Fill).Color;

            //var pen = new System.Drawing.Pen(System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B), (int)this.VisualParameters.StrokeThickness);

            //if (this.VisualParameters.DashStyle != null)
            //{
            //    pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
            //}
            var pen = this.VisualParameters.GetGdiPlusPen();

            var brush = this.VisualParameters.GetGdiPlusFillBrush();

            var transform = MapToTileScreenWpf(totalExtent, region.WebMercatorExtent, viewTransform);

            var image = new SqlSpatialToOpenTKBitmap().ParseSqlGeometry(
                geometries,
                tileWidth,
                tileHeight,
                transform,
                pen,
                brush);

            if (image == null)
            {
                return(null);
            }

            if (labels != null)
            {
                SqlSpatialToGdiBitmap.DrawLabels(labels, geometries, image, transform, this.Labels);
            }

            BitmapImage bitmapImage = IRI.Jab.Common.Helpers.ImageUtility.AsBitmapImage(image, System.Drawing.Imaging.ImageFormat.Png);

            Path path = new Path()
            {
                Data = area,
                Tag  = new LayerTag(mapScale)
                {
                    Layer = this, IsTiled = true, Tile = region, IsDrawn = true, IsNew = true
                }
            };

            this.Element = path;

            path.Fill = new ImageBrush(bitmapImage);

            return(path);
        }
Exemple #59
0
    private void DestroyTower(RaycastHit hit)
    {
        TileInfo parentsInfo = hit.transform.GetComponentInParent <TileInfo>();

        parentsInfo.DestroyTower();
    }
Exemple #60
0
        /// <summary>
        /// Adds tiles to all exits of a tile
        /// </summary>
        /// <param name="worldTiles">Contains a list of already added tiles.</param>
        /// <param name="tileInfo">Originating tile</param>
        /// <param name="tiles">List of tiles to choose from</param>
        /// <param name="counter">Contains how many tiles were added. When counter reached it will look for an exit.
        /// If exit was not found look for deadend(filler?). </param>
        /// <param name="position">Position of originating tile.</param>
        /// <param name="x">Originating tile world x position</param>
        private static int AddAdjacentTiles(Dictionary <Vector3D, TileInfo> worldTiles, TileInfo tileInfo, Dictionary <int, TileInfo> tiles, int counter, Vector3D position)
        {
            Logger.Debug("Counter: {0}, ExitDirectionbitsOfGivenTile: {1}", counter, tileInfo.ExitDirectionBits);
            var lookUpExits = GetLookUpExitBits(tileInfo.ExitDirectionBits);

            Dictionary <TileExits, Vector3D> randomizedExitTypes = GetAdjacentPositions(position, true);

            //add adjacent tiles for each randomized direction
            foreach (var exit in randomizedExitTypes)
            {
                if ((lookUpExits & (int)exit.Key) > 0 && !worldTiles.ContainsKey(exit.Value))
                {
                    counter = AddadjacentTileAtExit(worldTiles, tiles, counter, exit.Value);
                }
            }

            return(counter);
        }