Пример #1
0
 /// <summary>
 /// Returns the Continent for the given map
 /// </summary>
 /// <param name="map">map entry</param>
 /// <returns>Continent of the map supplied</returns>
 public static ContinentEntry GetContinent(MapEntryBase map)
 {
     if (map is MapEntry) return  Continents[(map as MapEntry).ContinentId];
     return Continents[Maps[map.Id].ContinentId];
 }
Пример #2
0
 public static string GetTileUrlFromWorldPos(MapEntryBase map, int floor, int zoomLevel, Gw2Point worldPosition, string errorTileUrl)
 {
     MapEntry mapEntry = map is MapEntry ? (map as MapEntry) : GwApi.GetMap()[map.Id];
     int continentId = mapEntry.ContinentId;
     return GetTileUrl(continentId, floor, zoomLevel, WorldPosToTile(map, worldPosition, zoomLevel), errorTileUrl);
 }
Пример #3
0
 public static Gw2Point WorldPosToTile(MapEntryBase map, Gw2Point worldPosition, int zoom)
 {
     var point = PixelToTile(WorldPosToPixel(map, worldPosition, zoom));
     return point;
 }
Пример #4
0
 public static Gw2Point WorldPosToTilePixel(MapEntryBase map, Gw2Point worldPosition, int zoom)
 {
     Gw2Point pixelAtZoom = WorldPosToPixel(map, worldPosition, zoom);
     Gw2Point tile = WorldPosToTile(map, worldPosition, zoom);
     Gw2Point tilePixel = pixelAtZoom - (tile*Constants.TileSize);
     return tilePixel;
 }
Пример #5
0
 public static Gw2Point WorldPosToPixel(MapEntryBase map, Gw2Point worldPosition, int zoom)
 {
     try
     {
         var continent = GetContinent(map);
         int zoomFromMax = continent.MaxZoom - zoom;
         int projection = 1 << zoomFromMax;
         var Xpn = map.ContinentRectangle[0][0] + (worldPosition.X - map.MapRectangle[0][0]) * Constants.WorldPosToPixelRatio;
         var Ypn = map.ContinentRectangle[0][1] + (map.MapRectangle[1][1] - worldPosition.Y) * Constants.WorldPosToPixelRatio;
         return new Gw2Point { X = Xpn, Y = Ypn } / projection;
     }
     catch (Exception e)
     {
         Logger.Error(e);
     }
     return new Gw2Point(0, 0);
 }
Пример #6
0
 public static Gw2Point PixelToWorldPos(MapEntryBase map, Gw2Point pixel, int zoom)
 {
     try
     {
         var continent = GetContinent(map);
         int zoomFromMax = continent.MaxZoom - zoom;
         int projection = 1 << zoomFromMax;
         pixel *= projection;
         var Xwn = (pixel.X - map.ContinentRectangle[0][0]) * Constants.PixelToWorldPosRatio + map.MapRectangle[0][0];
         var Ywn = map.MapRectangle[1][1] - (pixel.Y - map.ContinentRectangle[0][1]) * Constants.PixelToWorldPosRatio;
         return new Gw2Point { X = Xwn, Y = Ywn };
     }
     catch (Exception e)
     {
         Logger.Error(e);
     }
     return new Gw2Point( 0, 0 );
 }