/// <summary> /// Retrieves map information using the provided continent coordinates, /// or null if the coordinates do not fall into any current zone /// </summary> /// <param name="continentId">ID of the continent that the coordinates are for</param> /// <param name="continentCoordinates">Continent coordinates to use</param> /// <returns>The map data, or null if not found</returns> public Data.Entities.Map GetMap(int continentId, Point continentCoordinates) { var continent = this.GetContinent(continentId); var floorService = LocalizationUtil.IsSupportedCulture() ? GW2.V1.Floors.ForCurrentUICulture(continentId) : GW2.V1.Floors.ForDefaultCulture(continentId); var floor = this.GetFloor(continentId, continent.FloorIds.First()); if (floor != null && floor.Regions != null) { foreach (var region in floor.Regions.Values) { foreach (var map in region.Maps.Values) { if (continentCoordinates.X >= map.ContinentRectangle.X && continentCoordinates.X <= (map.ContinentRectangle.X + map.ContinentRectangle.Width) && continentCoordinates.Y >= map.ContinentRectangle.Y && continentCoordinates.Y <= (map.ContinentRectangle.Y + map.ContinentRectangle.Height)) { Data.Entities.Map mapData = new Data.Entities.Map(map.MapId); mapData.MaxLevel = map.MaximumLevel; mapData.MinLevel = map.MinimumLevel; mapData.DefaultFloor = map.DefaultFloor; mapData.ContinentId = continent.Id; mapData.RegionId = region.RegionId; mapData.RegionName = region.Name; mapData.MapRectangle.X = map.MapRectangle.X; mapData.MapRectangle.Y = map.MapRectangle.Y; mapData.MapRectangle.Height = map.MapRectangle.Height; mapData.MapRectangle.Width = map.MapRectangle.Width; mapData.ContinentRectangle.X = map.ContinentRectangle.X; mapData.ContinentRectangle.Y = map.ContinentRectangle.Y; mapData.ContinentRectangle.Height = map.ContinentRectangle.Height; mapData.ContinentRectangle.Width = map.ContinentRectangle.Width; // Done - return the data return(mapData); } } } } // Not found return(null); }
/// <summary> /// Retrieves the map information for the given map ID /// </summary> /// <param name="mapId">The ID of a zone</param> /// <returns>The map data</returns> public Data.Entities.Map GetMap(int mapId) { try { // Get the current map info var map = LocalizationUtil.IsSupportedCulture() ? GW2.V2.Maps.ForCurrentUICulture().Find(mapId) : GW2.V2.Maps.ForDefaultCulture().Find(mapId); if (map != null) { Data.Entities.Map m = new Data.Entities.Map(mapId); m.MaxLevel = map.MaximumLevel; m.MinLevel = map.MinimumLevel; m.DefaultFloor = map.DefaultFloor; m.ContinentId = map.ContinentId; m.RegionId = map.RegionId; m.RegionName = map.RegionName; m.MapRectangle.X = map.MapRectangle.X; m.MapRectangle.Y = map.MapRectangle.Y; m.MapRectangle.Height = map.MapRectangle.Height; m.MapRectangle.Width = map.MapRectangle.Width; m.ContinentRectangle.X = map.ContinentRectangle.X; m.ContinentRectangle.Y = map.ContinentRectangle.Y; m.ContinentRectangle.Height = map.ContinentRectangle.Height; m.ContinentRectangle.Width = map.ContinentRectangle.Width; return(m); } } catch (Exception ex) { // Don't crash if something goes wrong, but log the error logger.Error(ex); } return(null); }
/// <summary> /// Retrieves map information using the provided continent coordinates, /// or null if the coordinates do not fall into any current zone /// </summary> /// <param name="continentId">ID of the continent that the coordinates are for</param> /// <param name="continentCoordinates">Continent coordinates to use</param> /// <returns>The map data, or null if not found</returns> public Data.Entities.Map GetMap(int continentId, Point continentCoordinates) { var continent = this.GetContinent(continentId); var floorService = GW2.V1.Floors.ForCurrentUICulture(continentId); var floor = this.GetFloor(continentId, continent.FloorIds.First()); if (floor != null && floor.Regions != null) { foreach (var region in floor.Regions.Values) { foreach (var map in region.Maps.Values) { if (continentCoordinates.X >= map.ContinentRectangle.X && continentCoordinates.X <= (map.ContinentRectangle.X + map.ContinentRectangle.Width) && continentCoordinates.Y >= map.ContinentRectangle.Y && continentCoordinates.Y <= (map.ContinentRectangle.Y + map.ContinentRectangle.Height)) { Data.Entities.Map mapData = new Data.Entities.Map(map.MapId); mapData.MaxLevel = map.MaximumLevel; mapData.MinLevel = map.MinimumLevel; mapData.DefaultFloor = map.DefaultFloor; mapData.ContinentId = continent.Id; mapData.RegionId = region.RegionId; mapData.RegionName = region.Name; mapData.MapRectangle.X = map.MapRectangle.X; mapData.MapRectangle.Y = map.MapRectangle.Y; mapData.MapRectangle.Height = map.MapRectangle.Height; mapData.MapRectangle.Width = map.MapRectangle.Width; mapData.ContinentRectangle.X = map.ContinentRectangle.X; mapData.ContinentRectangle.Y = map.ContinentRectangle.Y; mapData.ContinentRectangle.Height = map.ContinentRectangle.Height; mapData.ContinentRectangle.Width = map.ContinentRectangle.Width; // Done - return the data return mapData; } } } } // Not found return null; }
/// <summary> /// Retrieves the map information for the given map ID /// </summary> /// <param name="mapId">The ID of a zone</param> /// <returns>The map data</returns> public Data.Entities.Map GetMap(int mapId) { try { // Get the current map info var map = GW2.V2.Maps.ForCurrentUICulture().Find(mapId); if (map != null) { Data.Entities.Map m = new Data.Entities.Map(mapId); m.MaxLevel = map.MaximumLevel; m.MinLevel = map.MinimumLevel; m.DefaultFloor = map.DefaultFloor; m.ContinentId = map.ContinentId; m.RegionId = map.RegionId; m.RegionName = map.RegionName; m.MapRectangle.X = map.MapRectangle.X; m.MapRectangle.Y = map.MapRectangle.Y; m.MapRectangle.Height = map.MapRectangle.Height; m.MapRectangle.Width = map.MapRectangle.Width; m.ContinentRectangle.X = map.ContinentRectangle.X; m.ContinentRectangle.Y = map.ContinentRectangle.Y; m.ContinentRectangle.Height = map.ContinentRectangle.Height; m.ContinentRectangle.Width = map.ContinentRectangle.Width; return m; } } catch (Exception ex) { // Don't crash if something goes wrong, but log the error logger.Error(ex); } return null; }