예제 #1
0
        /// <summary>
        /// Returns a marker by id
        /// </summary>
        /// <param name="mapId">Map Id</param>
        /// <param name="markerId">Marker Id</param>
        /// <returns>Map marker</returns>
        public async Task <KartaMapNamedMarkerQueryResult> GetMarkerById(string mapId, string markerId)
        {
            KartaMap map = await GetMapById(mapId);

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

            KartaMapNamedMarkerQueryResult marker = FindMarkerById(map, map.ItemMarker, MarkerType.Item, markerId);

            if (marker != null)
            {
                return(marker);
            }

            marker = FindMarkerById(map, map.QuestMarker, MarkerType.Quest, markerId);
            if (marker != null)
            {
                return(marker);
            }

            marker = FindMarkerById(map, map.KirjaPageMarker, MarkerType.KirjaPage, markerId);
            if (marker != null)
            {
                return(marker);
            }

            marker = FindMarkerById(map, map.MapChangeMarker, MarkerType.MapChange, markerId);
            if (marker != null)
            {
                return(marker);
            }

            marker = FindMarkerById(map, map.NoteMarker, MarkerType.Note, markerId);
            if (marker != null)
            {
                return(marker);
            }

            marker = FindMarkerById(map, map.NpcMarker, MarkerType.Npc, markerId);
            if (marker != null)
            {
                return(marker);
            }

            return(null);
        }
예제 #2
0
        /// <summary>
        /// Finds a marker by its id
        /// </summary>
        /// <param name="map">Map</param>
        /// <param name="markerList">Marker list to search</param>
        /// <param name="markerType">Marker type</param>
        /// <param name="markerId">Marker id</param>
        /// <typeparam name="T">Type of the markers</typeparam>
        /// <returns>Found marker result</returns>
        private KartaMapNamedMarkerQueryResult FindMarkerById <T>(KartaMap map, List <T> markerList, MarkerType markerType, string markerId) where T : MapMarker
        {
            MapMarker marker = markerList.FirstOrDefault(m => m.Id == markerId) as MapMarker;

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

            KartaMapNamedMarkerQueryResult result = new KartaMapNamedMarkerQueryResult();

            result.MapId      = map.Id;
            result.MapName    = map.Name;
            result.MarkerId   = marker.Id;
            result.MarkerName = marker.ExportName;
            result.MarkerType = markerType.ToString();
            return(result);
        }