static string GetComboBoxTextFromLayer(MapRenderLayer layer) { switch (layer) { case MapRenderLayer.SpriteBackground: return("Background"); case MapRenderLayer.Dynamic: return("Dynamic"); case MapRenderLayer.SpriteForeground: return("Foreground"); default: throw new InvalidEnumArgumentException("layer", (int)layer, typeof(MapRenderLayer)); } }
/// <summary> /// Initializes a new instance of the <see cref="DrawableMapDrawLayerEventArgs"/> class. /// </summary> /// <param name="layer">The layer that the drawing event is related to.</param> /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> that was used to do the drawing.</param> /// <param name="camera">The <see cref="ICamera2D"/> that describes the view of the map being drawn.</param> public DrawableMapDrawLayerEventArgs(MapRenderLayer layer, ISpriteBatch spriteBatch, ICamera2D camera) { _layer = layer; _spriteBatch = spriteBatch; _camera = camera; }
/// <summary> /// Gets the MapGrh to select at the given position. /// </summary> /// <param name="map">The map.</param> /// <param name="worldPos">The world position.</param> /// <param name="mustBeOnLayer">If not null, then only return a MapGrh on the specified layer.</param> /// <returns>The best MapGrh to be selected, or null if none found.</returns> public static MapGrh GetGrhToSelect(IDrawableMap map, Vector2 worldPos, MapRenderLayer? mustBeOnLayer = null) { // Get all MapGrhs as the position var mapGrhs = map.Spatial.GetMany<MapGrh>(worldPos); // Filter layer if (mustBeOnLayer.HasValue) mapGrhs = mapGrhs.Where(x => x.MapRenderLayer == mustBeOnLayer.Value); // Prioritize by draw order & distance from origin, then take the first mapGrhs = mapGrhs .OrderByDescending(x => (int)x.MapRenderLayer) .ThenByDescending(x => x.LayerDepth) .ThenBy(x => worldPos.QuickDistance(x.Position)); return mapGrhs.FirstOrDefault(); }
static string GetComboBoxTextFromLayer(MapRenderLayer layer) { switch (layer) { case MapRenderLayer.SpriteBackground: return "Background"; case MapRenderLayer.Dynamic: return "Dynamic"; case MapRenderLayer.SpriteForeground: return "Foreground"; default: throw new InvalidEnumArgumentException("layer", (int)layer, typeof(MapRenderLayer)); } }