Ejemplo n.º 1
0
        /// <summary>
        /// When overridden in the derived class, handles performing drawing before the GUI for a <see cref="IDrawableMap"/> has been draw.
        /// </summary>
        /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to use to draw.</param>
        /// <param name="imap">The <see cref="IDrawableMap"/> being drawn.</param>
        protected override void HandleBeforeDrawMapGUI(ISpriteBatch spriteBatch, IDrawableMap imap)
        {
            base.HandleBeforeDrawMapGUI(spriteBatch, imap);

            if (!IsEnabled)
            {
                return;
            }

            if (IsSelecting)
            {
                return;
            }

            if ((Control.ModifierKeys & _placeLightKey) != 0)
            {
                if (imap == _mouseOverMap)
                {
                    var lightSprite = SystemSprites.Lightblub;
                    var pos         = _mousePos - (lightSprite.Size / 2f);
                    pos = GridAligner.Instance.Align(pos);
                    lightSprite.Draw(spriteBatch, pos);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles drawing to the map after the given <see cref="MapRenderLayer"/> is drawn.
        /// </summary>
        /// <param name="map">The map the drawing is taking place on.</param>
        /// <param name="e">The <see cref="NetGore.Graphics.DrawableMapDrawLayerEventArgs"/> containing the drawing event arguments.</param>
        void IMapDrawingExtension.DrawAfterLayer(IDrawableMap map, DrawableMapDrawLayerEventArgs e)
        {
            if (!Enabled)
                return;

            if (map == null)
            {
                Debug.Fail("map is null.");
                return;
            }

            if (e.SpriteBatch == null)
            {
                Debug.Fail("spriteBatch is null.");
                return;
            }

            if (e.Camera == null)
            {
                Debug.Fail("camera is null.");
                return;
            }

            Debug.Assert(EnumHelper<MapRenderLayer>.IsDefined(e.Layer), "Invalid layer specified.");
            Debug.Assert(!e.SpriteBatch.IsDisposed, "spriteBatch is disposed.");

            HandleDrawAfterLayer(map, e);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles drawing to the map before any layers are drawn.
        /// </summary>
        /// <param name="map">The map the drawing is taking place on.</param>
        /// <param name="e">The <see cref="DrawableMapDrawEventArgs"/> containing the drawing event arguments.</param>
        void IMapDrawingExtension.DrawBeforeMap(IDrawableMap map, DrawableMapDrawEventArgs e)
        {
            if (!Enabled)
            {
                return;
            }

            if (map == null)
            {
                Debug.Fail("map is null.");
                return;
            }

            if (e.SpriteBatch == null)
            {
                Debug.Fail("spriteBatch is null.");
                return;
            }

            if (e.Camera == null)
            {
                Debug.Fail("camera is null.");
                return;
            }

            Debug.Assert(!e.SpriteBatch.IsDisposed, "spriteBatch is disposed.");

            HandleDrawBeforeMap(map, e.SpriteBatch, e.Camera);
        }
Ejemplo n.º 4
0
        public static void DrawSpawn(MapSpawnValues spawn, ISpriteBatch spriteBatch, IDrawableMap map, Font font)
        {
            var spawnArea = spawn.SpawnArea;

            // Only draw if it does not cover the whole map
            if (!spawnArea.X.HasValue && !spawnArea.Y.HasValue && !spawnArea.Width.HasValue && !spawnArea.Height.HasValue)
            {
                return;
            }

            // Draw spawn area
            Vector2   cameraOffset = map.Camera.Min;
            Rectangle rect         = spawnArea.ToRectangle(map);

            rect.X -= (int)cameraOffset.X;
            rect.Y -= (int)cameraOffset.Y;
            RenderRectangle.Draw(spriteBatch, rect, new Color(0, 255, 0, 75), new Color(0, 0, 0, 125), 2);

            // Draw name
            CharacterTemplate charTemp = CharacterTemplateManager.Instance[spawn.CharacterTemplateID];

            if (charTemp != null)
            {
                string text = string.Format("{0}x {1} [{2}]", spawn.SpawnAmount, charTemp.TemplateTable.Name, spawn.CharacterTemplateID);

                Vector2 textPos = new Vector2(rect.X, rect.Y);
                textPos -= new Vector2(0, font.MeasureString(text).Y);
                textPos  = textPos.Round();

                spriteBatch.DrawStringShaded(font, text, textPos, Color.White, Color.Black);
            }
        }
Ejemplo n.º 5
0
        public static void DrawSpawn(MapSpawnValues spawn, ISpriteBatch spriteBatch, IDrawableMap map, Font font)
        {
            var spawnArea = spawn.SpawnArea;

            // Only draw if it does not cover the whole map
            if (!spawnArea.X.HasValue && !spawnArea.Y.HasValue && !spawnArea.Width.HasValue && !spawnArea.Height.HasValue)
                return;

            // Draw spawn area
            Vector2 cameraOffset = map.Camera.Min;
            Rectangle rect = spawnArea.ToRectangle(map);
            rect.X -= (int)cameraOffset.X;
            rect.Y -= (int)cameraOffset.Y;
            RenderRectangle.Draw(spriteBatch, rect, new Color(0, 255, 0, 75), new Color(0, 0, 0, 125), 2);

            // Draw name
            CharacterTemplate charTemp = CharacterTemplateManager.Instance[spawn.CharacterTemplateID];
            if (charTemp != null)
            {
                string text = string.Format("{0}x {1} [{2}]", spawn.SpawnAmount, charTemp.TemplateTable.Name, spawn.CharacterTemplateID);

                Vector2 textPos = new Vector2(rect.X, rect.Y);
                textPos -= new Vector2(0, font.MeasureString(text).Y);
                textPos = textPos.Round();

                spriteBatch.DrawStringShaded(font, text, textPos, Color.White, Color.Black);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// When overridden in the derived class, handles performing drawing after the GUI for a <see cref="IDrawableMap"/> has been draw.
        /// </summary>
        /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to use to draw.</param>
        /// <param name="map">The <see cref="IDrawableMap"/> being drawn.</param>
        protected override void HandleAfterDrawMapGUI(ISpriteBatch spriteBatch, IDrawableMap map)
        {
            base.HandleAfterDrawMapGUI(spriteBatch, map);

            if (!IsEnabled)
            {
                return;
            }

            if (map != _mouseOverMap)
            {
                return;
            }

            var grh      = GlobalState.Instance.Map.GrhToPlace;
            var worldPos = map.Camera.ToWorld(_mousePos);
            var drawPos  = worldPos - map.Camera.Min;

            if (!Input.IsCtrlDown)
            {
                drawPos = GridAligner.Instance.Align(drawPos, true).Round();
            }

            if (Input.IsShiftDown)
            {
                // Display tooltip of what would be selected
                var grhToSelect = MapGrhPencilTool.GetGrhToSelect(map, worldPos);
                MapGrhPencilTool.DrawMapGrhTooltip(spriteBatch, map, grhToSelect, worldPos);
            }
            else
            {
                grh.Update(map.GetTime());
                grh.Draw(spriteBatch, drawPos, new Color(255, 255, 255, 180));
            }
        }
Ejemplo n.º 7
0
            /// <summary>
            /// When overridden in the derived class, handles drawing to the map after all of the map drawing finishes.
            /// </summary>
            /// <param name="map">The map the drawing is taking place on.</param>
            /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param>
            /// <param name="camera">The <see cref="ICamera2D"/> that describes the view of the map being drawn.</param>
            protected override void HandleDrawAfterMap(IDrawableMap map, ISpriteBatch spriteBatch, ICamera2D camera)
            {
                var msc = MapScreenControl.TryFindInstance(map);

                if (msc == null)
                {
                    return;
                }

                var dm = msc.DrawingManager;

                if (dm == null)
                {
                    return;
                }

                var lm = dm.LightManager;

                if (lm == null)
                {
                    return;
                }

                var lightSprite = SystemSprites.Lightblub;

                var offset = lightSprite.Size / 2f;

                foreach (var light in lm)
                {
                    lightSprite.Draw(spriteBatch, light.Center - offset);
                }
            }
Ejemplo n.º 8
0
        /// <summary>
        /// Handles drawing to the map after the given <see cref="MapRenderLayer"/> is drawn.
        /// </summary>
        /// <param name="map">The map the drawing is taking place on.</param>
        /// <param name="e">The <see cref="NetGore.Graphics.DrawableMapDrawLayerEventArgs"/> containing the drawing event arguments.</param>
        void IMapDrawingExtension.DrawAfterLayer(IDrawableMap map, DrawableMapDrawLayerEventArgs e)
        {
            if (!Enabled)
            {
                return;
            }

            if (map == null)
            {
                Debug.Fail("map is null.");
                return;
            }

            if (e.SpriteBatch == null)
            {
                Debug.Fail("spriteBatch is null.");
                return;
            }

            if (e.Camera == null)
            {
                Debug.Fail("camera is null.");
                return;
            }

            Debug.Assert(EnumHelper <MapRenderLayer> .IsDefined(e.Layer), "Invalid layer specified.");
            Debug.Assert(!e.SpriteBatch.IsDisposed, "spriteBatch is disposed.");

            HandleDrawAfterLayer(map, e);
        }
 /// <summary>
 /// When overridden in the derived class, handles drawing to the map after the given <see cref="MapRenderLayer"/> is drawn.
 /// </summary>
 /// <param name="map">The map the drawing is taking place on.</param>
 /// <param name="e">The <see cref="NetGore.Graphics.DrawableMapDrawLayerEventArgs"/> instance containing the event data.</param>
 protected override void HandleDrawAfterLayer(IDrawableMap map, DrawableMapDrawLayerEventArgs e)
 {
     if (e.Layer == MapRenderLayer.Chararacter)
     {
         _displayManager.Draw(e.SpriteBatch);
     }
 }
 /// <summary>
 /// When overridden in the derived class, handles drawing to the map after the given <see cref="MapRenderLayer"/> is drawn.
 /// </summary>
 /// <param name="map">The map the drawing is taking place on.</param>
 /// <param name="e">The <see cref="NetGore.Graphics.DrawableMapDrawLayerEventArgs"/> instance containing the event data.</param>
 protected override void HandleDrawAfterLayer(IDrawableMap map, DrawableMapDrawLayerEventArgs e)
 {
     // Draw emoticons after dynamic layer finishes
     if (e.Layer == MapRenderLayer.Dynamic)
     {
         _displayManager.Draw(e.SpriteBatch);
     }
 }
Ejemplo n.º 11
0
Archivo: Tool.cs Proyecto: wtfcolt/game
        /// <summary>
        /// Notifies the <see cref="Tool"/> before a <see cref="IDrawableMap"/>'s GUI was drawn.
        /// </summary>
        /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to use to draw.</param>
        /// <param name="map">The <see cref="IDrawableMap"/> being drawn.</param>
        internal void InvokeBeforeDrawMapGUI(ISpriteBatch spriteBatch, IDrawableMap map)
        {
            if (IsDisposed)
            {
                return;
            }

            HandleBeforeDrawMapGUI(spriteBatch, map);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Notifies the <see cref="Tool"/> after a <see cref="IDrawableMap"/>'s GUI was drawn.
        /// </summary>
        /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to use to draw.</param>
        /// <param name="map">The <see cref="IDrawableMap"/> being drawn.</param>
        internal void InvokeAfterDrawMapGUI(ISpriteBatch spriteBatch, IDrawableMap map)
        {
            if (!IsEnabled || IsDisposed)
            {
                return;
            }

            HandleAfterDrawMapGUI(spriteBatch, map);
        }
        /// <summary>
        /// Handles the <see cref="IDrawableMap.BeginDrawMap"/> event from the current map.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="NetGore.Graphics.DrawableMapDrawEventArgs"/> instance containing the event data.</param>
        void BeginDrawMapCallback(IDrawableMap sender, DrawableMapDrawEventArgs e)
        {
            Debug.Assert(Map == sender, "How did we get an event from the wrong map?");
            Debug.Assert(e.SpriteBatch != null && !e.SpriteBatch.IsDisposed);

            foreach (var extension in _extensions)
            {
                extension.DrawBeforeMap(sender, e);
            }
        }
        /// <summary>
        /// Handles the <see cref="IDrawableMap.EndDrawMapLayer"/> event from the current map.
        /// </summary>
        /// <param name="map">The map.</param>
        /// <param name="e">The <see cref="NetGore.Graphics.DrawableMapDrawLayerEventArgs"/> instance containing the event data.</param>
        void EndDrawMapLayerCallback(IDrawableMap map, DrawableMapDrawLayerEventArgs e)
        {
            Debug.Assert(Map == map, "How did we get an event from the wrong map?");
            Debug.Assert(e.SpriteBatch != null && !e.SpriteBatch.IsDisposed);

            foreach (var extension in _extensions)
            {
                extension.DrawAfterLayer(map, e);
            }
        }
Ejemplo n.º 15
0
            /// <summary>
            /// When overridden in the derived class, handles drawing to the map after all of the map drawing finishes.
            /// </summary>
            /// <param name="map">The map the drawing is taking place on.</param>
            /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param>
            /// <param name="camera">The <see cref="ICamera2D"/> that describes the view of the map being drawn.</param>
            protected override void HandleDrawAfterMap(IDrawableMap map, ISpriteBatch spriteBatch, ICamera2D camera)
            {
                var p = Parent;

                if (p == null)
                {
                    return;
                }

                // Ensure the map is valid
                var clientMap = map as EditorMap;

                if (clientMap == null)
                {
                    return;
                }

                var viewArea = camera.GetViewArea();

                // Draw the walls
                if (p.DrawWalls)
                {
                    var visibleWalls = map.Spatial.GetMany <WallEntityBase>(viewArea);
                    foreach (var wall in visibleWalls)
                    {
                        EntityDrawer.Draw(spriteBatch, camera, wall);
                    }
                }

                // Draw the MapGrh walls
                if (p.DrawMapGrhWalls)
                {
                    var mapGrhWalls = GlobalState.Instance.MapGrhWalls;
                    var toDraw      = clientMap.Spatial.GetMany <MapGrh>(viewArea);
                    var tmpWall     = new WallEntity(Vector2.Zero, Vector2.Zero);

                    foreach (var mg in toDraw)
                    {
                        var boundWalls = mapGrhWalls[mg.Grh.GrhData];
                        if (boundWalls == null)
                        {
                            continue;
                        }

                        foreach (var wall in boundWalls)
                        {
                            tmpWall.Size       = wall.Size != Vector2.Zero ? wall.Size * mg.Scale : mg.Size;
                            tmpWall.Position   = mg.Position + (wall.Position * mg.Scale);
                            tmpWall.IsPlatform = wall.IsPlatform;
                            EntityDrawer.Draw(spriteBatch, camera, tmpWall);
                        }
                    }
                }
            }
Ejemplo n.º 16
0
        /// <summary>
        /// When overridden in the derived class, handles drawing to the map after the given <see cref="MapRenderLayer"/> is drawn.
        /// </summary>
        /// <param name="map">The map the drawing is taking place on.</param>
        /// <param name="e">The <see cref="NetGore.Graphics.DrawableMapDrawLayerEventArgs"/> instance containing the event data.</param>
        protected override void HandleDrawAfterLayer(IDrawableMap map, DrawableMapDrawLayerEventArgs e)
        {
            if (e.Layer != MapRenderLayer.SpriteForeground)
                return;

            var visibleArea = e.Camera.GetViewArea();
            var visibleWalls = map.Spatial.GetMany<WallEntityBase>(visibleArea);
            foreach (var wall in visibleWalls)
            {
                EntityDrawer.Draw(e.SpriteBatch, e.Camera, wall);
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// When overridden in the derived class, handles performing drawing before the GUI for a <see cref="IDrawableMap"/> has been draw.
        /// </summary>
        /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to use to draw.</param>
        /// <param name="imap">The <see cref="IDrawableMap"/> being drawn.</param>
        protected override void HandleBeforeDrawMapGUI(ISpriteBatch spriteBatch, IDrawableMap imap)
        {
            base.HandleBeforeDrawMapGUI(spriteBatch, imap);

            if (!IsEnabled)
            {
                return;
            }

            var map = imap as EditorMap;

            if (map == null)
            {
                return;
            }

            var camera = map.Camera;

            if (camera == null)
            {
                return;
            }

            // Only draw for the map under the cursor
            if (map != _mouseOverMap)
            {
                return;
            }

            if (IsSelecting)
            {
                // Draw the selection area
                var a = camera.ToScreen(_selectionStart);
                var b = camera.ToScreen(_selectionEnd);

                if (a.QuickDistance(b) > _minSelectionAreaDrawSize)
                {
                    var rect = Rectangle.FromPoints(a, b);
                    RenderRectangle.Draw(spriteBatch, rect, _selectionAreaColorInner, _selectionAreaColorOuter);
                }
            }
            else
            {
                // Draw the tooltip
                var font = ToolTipFont;
                if (_toolTipObject != null && _toolTip != null && font != null)
                {
                    spriteBatch.DrawStringShaded(font, _toolTip, _toolTipPos, Color.White, Color.Black);
                }
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// When overridden in the derived class, handles drawing to the map after the given <see cref="MapRenderLayer"/> is drawn.
        /// </summary>
        /// <param name="map">The map the drawing is taking place on.</param>
        /// <param name="e">The <see cref="NetGore.Graphics.DrawableMapDrawLayerEventArgs"/> instance containing the event data.</param>
        protected override void HandleDrawAfterLayer(IDrawableMap map, DrawableMapDrawLayerEventArgs e)
        {
            if (e.Layer != MapRenderLayer.SpriteForeground)
                return;

            if (MapSpawns == null)
                return;

            foreach (var item in MapSpawns)
            {
                var rect = item.SpawnArea.ToRectangle(map);
                if (e.Camera.InView(rect))
                    RenderRectangle.Draw(e.SpriteBatch, rect, _drawColor);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// When overridden in the derived class, handles drawing to the map after the given <see cref="MapRenderLayer"/> is drawn.
        /// </summary>
        /// <param name="map">The map the drawing is taking place on.</param>
        /// <param name="e">The <see cref="NetGore.Graphics.DrawableMapDrawLayerEventArgs"/> instance containing the event data.</param>
        protected override void HandleDrawAfterLayer(IDrawableMap map, DrawableMapDrawLayerEventArgs e)
        {
            if (e.Layer != MapRenderLayer.SpriteForeground)
            {
                return;
            }

            var visibleArea  = e.Camera.GetViewArea();
            var visibleWalls = map.Spatial.GetMany <WallEntityBase>(visibleArea);

            foreach (var wall in visibleWalls)
            {
                EntityDrawer.Draw(e.SpriteBatch, e.Camera, wall);
            }
        }
Ejemplo n.º 20
0
            /// <summary>
            /// When overridden in the derived class, handles drawing to the map after all of the map drawing finishes.
            /// </summary>
            /// <param name="map">The map the drawing is taking place on.</param>
            /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param>
            /// <param name="camera">The <see cref="ICamera2D"/> that describes the view of the map being drawn.</param>
            protected override void HandleDrawAfterMap(IDrawableMap map, ISpriteBatch spriteBatch, ICamera2D camera)
            {
                var p = Parent;

                if (p == null)
                {
                    return;
                }

                // Ensure the map is valid
                var clientMap = map as EditorMap;

                if (clientMap == null)
                {
                    return;
                }

                var viewArea = camera.GetViewArea();

                // Draw the walls
                if (p.DrawWalls)
                {
                    var visibleWalls = map.Spatial.GetMany <WallEntityBase>(viewArea);
                    foreach (var wall in visibleWalls)
                    {
                        EntityDrawer.Draw(spriteBatch, camera, wall);
                    }
                }

                // Draw the MapGrh walls
                if (p.DrawMapGrhWalls)
                {
                    var toDraw = clientMap.Spatial.GetMany <MapGrh>(viewArea);
                    foreach (var mg in toDraw)
                    {
                        var boundWalls = GlobalState.Instance.MapGrhWalls[mg.Grh.GrhData];
                        if (boundWalls == null)
                        {
                            continue;
                        }

                        foreach (var wall in boundWalls)
                        {
                            EntityDrawer.Draw(spriteBatch, camera, wall, mg.Position);
                        }
                    }
                }
            }
Ejemplo n.º 21
0
        /// <summary>
        /// Notifies the <see cref="Tool"/>s in this <see cref="ToolManager"/> about the corresponding event.
        /// It is the responsibility of the application to make sure this method is called at the appropriate time.
        /// </summary>
        /// <param name="spriteBatch">The <see cref="ISpriteBatch"/>.</param>
        /// <param name="map">The <see cref="IDrawableMap"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="spriteBatch"/> is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="map"/> is null.</exception>
        public void InvokeBeforeDrawMapGUI(ISpriteBatch spriteBatch, IDrawableMap map)
        {
            if (spriteBatch == null)
            {
                throw new ArgumentNullException("spriteBatch");
            }
            if (map == null)
            {
                throw new ArgumentNullException("map");
            }

            foreach (var t in EnabledTools)
            {
                t.InvokeBeforeDrawMapGUI(spriteBatch, map);
            }
        }
Ejemplo n.º 22
0
        public static bool DrawMapGrhTooltip(ISpriteBatch spriteBatch, IDrawableMap map, MapGrh mapGrh, Vector2 worldPos)
        {
            if (mapGrh == null || mapGrh.Grh == null || mapGrh.Grh.GrhData == null)
            {
                return(false);
            }

            Vector2 drawPos = worldPos - map.Camera.Min;
            var     font    = GlobalState.Instance.DefaultRenderFont;
            string  txt     = mapGrh.Grh.GrhData.Categorization.ToString();
            Vector2 txtSize = font.MeasureString(txt);
            Vector2 txtPos  = drawPos.Max(Vector2.Zero).Min(map.Camera.Size - txtSize);

            spriteBatch.DrawStringShaded(font, txt, txtPos, Color.White, Color.Black);

            return(true);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// When overridden in the derived class, handles performing drawing after the GUI for a <see cref="IDrawableMap"/> has been draw.
        /// </summary>
        /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to use to draw.</param>
        /// <param name="map">The <see cref="IDrawableMap"/> being drawn.</param>
        protected override void HandleAfterDrawMapGUI(ISpriteBatch spriteBatch, IDrawableMap map)
        {
            base.HandleAfterDrawMapGUI(spriteBatch, map);

            if (_form == null || !_form.Visible)
                return;

            // Draw spawns
            var spawns = _form.GetMapSpawns();
            if (spawns != null)
            {
                var font = GlobalState.Instance.DefaultRenderFont;
                foreach (var spawn in spawns)
                {
                    EditorEntityDrawer.DrawSpawn(spawn, spriteBatch, map, font);
                }
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// When overridden in the derived class, handles performing drawing after the GUI for a <see cref="IDrawableMap"/> has been draw.
        /// </summary>
        /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to use to draw.</param>
        /// <param name="map">The <see cref="IDrawableMap"/> being drawn.</param>
        protected override void HandleAfterDrawMapGUI(ISpriteBatch spriteBatch, IDrawableMap map)
        {
            base.HandleAfterDrawMapGUI(spriteBatch, map);

            if (map != _mouseOverMap)
            {
                return;
            }

            if ((Control.ModifierKeys & _placeMapGrhKey) == 0)
            {
                return;
            }

            var grh = GlobalState.Instance.Map.GrhToPlace;

            grh.Draw(spriteBatch, GridAligner.Instance.Align(_mousePos, TileMode));
        }
Ejemplo n.º 25
0
        /// <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());
        }
Ejemplo n.º 26
0
        /// <summary>
        /// When overridden in the derived class, handles drawing to the map after the given <see cref="MapRenderLayer"/> is drawn.
        /// </summary>
        /// <param name="map">The map the drawing is taking place on.</param>
        /// <param name="e">The <see cref="NetGore.Graphics.DrawableMapDrawLayerEventArgs"/> instance containing the event data.</param>
        protected override void HandleDrawAfterLayer(IDrawableMap map, DrawableMapDrawLayerEventArgs e)
        {
            if (e.Layer != MapRenderLayer.SpriteForeground)
                return;

            // Get the visible area
            var visibleArea = e.Camera.GetViewArea();

            // Get and draw all entities, skipping those that we will never draw () and those that
            // we will always draw (_alwaysDrawTypes)
            var toDraw = map.Spatial.GetMany<Entity>(visibleArea, GetEntitiesToDrawFilter);

            // Add the entities we will always draw
            toDraw = toDraw.Concat(map.Spatial.GetMany<Entity>(GetEntitiesToAlwaysDrawFilter));

            // Draw
            foreach (var entity in toDraw)
            {
                EntityDrawer.Draw(e.SpriteBatch, e.Camera, entity);
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// When overridden in the derived class, handles drawing to the map after the given <see cref="MapRenderLayer"/> is drawn.
        /// </summary>
        /// <param name="map">The map the drawing is taking place on.</param>
        /// <param name="e">The <see cref="NetGore.Graphics.DrawableMapDrawLayerEventArgs"/> instance containing the event data.</param>
        protected override void HandleDrawAfterLayer(IDrawableMap map, DrawableMapDrawLayerEventArgs e)
        {
            if (e.Layer != MapRenderLayer.SpriteForeground)
            {
                return;
            }

            if (MapSpawns == null)
            {
                return;
            }

            foreach (var item in MapSpawns)
            {
                var rect = item.SpawnArea.ToRectangle(map);
                if (e.Camera.InView(rect))
                {
                    RenderRectangle.Draw(e.SpriteBatch, rect, _drawColor);
                }
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// When overridden in the derived class, handles performing drawing after the GUI for a <see cref="IDrawableMap"/> has been draw.
        /// </summary>
        /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to use to draw.</param>
        /// <param name="map">The <see cref="IDrawableMap"/> being drawn.</param>
        protected override void HandleAfterDrawMapGUI(ISpriteBatch spriteBatch, IDrawableMap map)
        {
            base.HandleAfterDrawMapGUI(spriteBatch, map);

            if (_form == null || !_form.Visible)
            {
                return;
            }

            // Draw spawns
            var spawns = _form.GetMapSpawns();

            if (spawns != null)
            {
                var font = GlobalState.Instance.DefaultRenderFont;
                foreach (var spawn in spawns)
                {
                    EditorEntityDrawer.DrawSpawn(spawn, spriteBatch, map, font);
                }
            }
        }
Ejemplo n.º 29
0
            /// <summary>
            /// When overridden in the derived class, handles drawing to the map after all of the map drawing finishes.
            /// </summary>
            /// <param name="map">The map the drawing is taking place on.</param>
            /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param>
            /// <param name="camera">The <see cref="ICamera2D"/> that describes the view of the map being drawn.</param>
            protected override void HandleDrawAfterMap(IDrawableMap map, ISpriteBatch spriteBatch, ICamera2D camera)
            {
                var msc = MapScreenControl.TryFindInstance(map);
                if (msc == null)
                    return;

                var dm = msc.DrawingManager;
                if (dm == null)
                    return;

                var lm = dm.LightManager;
                if (lm == null)
                    return;

                var lightSprite = SystemSprites.Lightblub;

                var offset = lightSprite.Size / 2f;
                foreach (var light in lm)
                {
                    lightSprite.Draw(spriteBatch, light.Center - offset);
                }
            }
Ejemplo n.º 30
0
        /// <summary>
        /// When overridden in the derived class, handles drawing to the map after the given <see cref="MapRenderLayer"/> is drawn.
        /// </summary>
        /// <param name="map">The map the drawing is taking place on.</param>
        /// <param name="e">The <see cref="NetGore.Graphics.DrawableMapDrawLayerEventArgs"/> instance containing the event data.</param>
        protected override void HandleDrawAfterLayer(IDrawableMap map, DrawableMapDrawLayerEventArgs e)
        {
            if (e.Layer != MapRenderLayer.SpriteForeground)
            {
                return;
            }

            // Get the visible area
            var visibleArea = e.Camera.GetViewArea();

            // Get and draw all entities, skipping those that we will never draw () and those that
            // we will always draw (_alwaysDrawTypes)
            var toDraw = map.Spatial.GetMany <Entity>(visibleArea, GetEntitiesToDrawFilter);

            // Add the entities we will always draw
            toDraw = toDraw.Concat(map.Spatial.GetMany <Entity>(GetEntitiesToAlwaysDrawFilter));

            // Draw
            foreach (var entity in toDraw)
            {
                EntityDrawer.Draw(e.SpriteBatch, e.Camera, entity);
            }
        }
Ejemplo n.º 31
0
 /// <summary>
 /// When overridden in the derived class, handles drawing to the map after all of the map drawing finishes.
 /// </summary>
 /// <param name="map">The map the drawing is taking place on.</param>
 /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param>
 /// <param name="camera">The <see cref="ICamera2D"/> that describes the view of the map being drawn.</param>
 protected override void HandleDrawAfterMap(IDrawableMap map, ISpriteBatch spriteBatch, ICamera2D camera)
 {
     _grid.Size = EditorSettings.Default.GridSize;
     _grid.Draw(spriteBatch, camera);
 }
Ejemplo n.º 32
0
 /// <summary>
 /// When overridden in the derived class, handles drawing to the map before any of the map drawing starts.
 /// </summary>
 /// <param name="map">The map the drawing is taking place on.</param>
 /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param>
 /// <param name="camera">The <see cref="ICamera2D"/> that describes the view of the map being drawn.</param>
 protected virtual void HandleDrawBeforeMap(IDrawableMap map, ISpriteBatch spriteBatch, ICamera2D camera)
 {
 }
Ejemplo n.º 33
0
Archivo: Tool.cs Proyecto: wtfcolt/game
 /// <summary>
 /// When overridden in the derived class, handles performing drawing before the GUI for a <see cref="IDrawableMap"/> has been draw.
 /// </summary>
 /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to use to draw.</param>
 /// <param name="map">The <see cref="IDrawableMap"/> being drawn.</param>
 protected virtual void HandleBeforeDrawMapGUI(ISpriteBatch spriteBatch, IDrawableMap map)
 {
 }
Ejemplo n.º 34
0
        /// <summary>
        /// Handles drawing to the map before any layers are drawn.
        /// </summary>
        /// <param name="map">The map the drawing is taking place on.</param>
        /// <param name="e">The <see cref="DrawableMapDrawEventArgs"/> containing the drawing event arguments.</param>
        void IMapDrawingExtension.DrawBeforeMap(IDrawableMap map, DrawableMapDrawEventArgs e)
        {
            if (!Enabled)
                return;

            if (map == null)
            {
                Debug.Fail("map is null.");
                return;
            }

            if (e.SpriteBatch == null)
            {
                Debug.Fail("spriteBatch is null.");
                return;
            }

            if (e.Camera == null)
            {
                Debug.Fail("camera is null.");
                return;
            }

            Debug.Assert(!e.SpriteBatch.IsDisposed, "spriteBatch is disposed.");

            HandleDrawBeforeMap(map, e.SpriteBatch, e.Camera);
        }
Ejemplo n.º 35
0
 /// <summary>
 /// When overridden in the derived class, handles drawing to the map before the given <see cref="MapRenderLayer"/> is drawn.
 /// </summary>
 /// <param name="map">The map the drawing is taking place on.</param>
 /// <param name="e">The <see cref="NetGore.Graphics.DrawableMapDrawLayerEventArgs"/> instance containing the event data.</param>
 protected virtual void HandleDrawBeforeLayer(IDrawableMap map, DrawableMapDrawLayerEventArgs e)
 {
 }
Ejemplo n.º 36
0
        /// <summary>
        /// When overridden in the derived class, handles performing drawing after the GUI for a <see cref="IDrawableMap"/> has been draw.
        /// </summary>
        /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to use to draw.</param>
        /// <param name="map">The <see cref="IDrawableMap"/> being drawn.</param>
        protected override void HandleAfterDrawMapGUI(ISpriteBatch spriteBatch, IDrawableMap map)
        {
            base.HandleAfterDrawMapGUI(spriteBatch, map);

            if (!IsEnabled)
                return;

            if (map != _mouseOverMap)
                return;

            var grh = GlobalState.Instance.Map.GrhToPlace;
			var worldPos = map.Camera.ToWorld(_mousePos);
            var drawPos = worldPos - map.Camera.Min;
            if (!Input.IsCtrlDown)
                drawPos = GridAligner.Instance.Align(drawPos, true).Round();

            if (Input.IsShiftDown)
            {
                // Display tooltip of what would be selected
                var grhToSelect = MapGrhPencilTool.GetGrhToSelect(map, worldPos);
                MapGrhPencilTool.DrawMapGrhTooltip(spriteBatch, map, grhToSelect, worldPos);
            }
            else
            {
                grh.Update(map.GetTime());
                grh.Draw(spriteBatch, drawPos, new Color(255, 255, 255, 180));
            }
        }
        /// <summary>
        /// When overridden in the derived class, handles drawing to the map after the given <see cref="MapRenderLayer"/> is drawn.
        /// </summary>
        /// <param name="map">The map the drawing is taking place on.</param>
        /// <param name="e">The <see cref="NetGore.Graphics.DrawableMapDrawLayerEventArgs"/> instance containing the event data.</param>
        protected override void HandleDrawAfterLayer(IDrawableMap map, DrawableMapDrawLayerEventArgs e)
        {
            // Draw after dynamic layer finishes
            if (e.Layer != MapRenderLayer.Dynamic)
            {
                return;
            }

            // Update the valid sprites
            var currentTime = map.GetTime();

            if (QuestStartedIndicator != null)
            {
                QuestStartedIndicator.Update(currentTime);
            }

            if (QuestTurnInIndicator != null)
            {
                QuestTurnInIndicator.Update(currentTime);
            }

            if (QuestAvailableCannotStartIndicator != null)
            {
                QuestAvailableCannotStartIndicator.Update(currentTime);
            }

            if (QuestAvailableCanStartIndicator != null)
            {
                QuestAvailableCanStartIndicator.Update(currentTime);
            }

            // Get all the quest providers in the area of interest (visible area)
            foreach (var c in _getQuestProviders(map))
            {
                // Get the provided quests we have not completed or if it's repeatable
                var incomplete = _getQuests(c).Where(x => !QuestInfo.CompletedQuests.Contains(x) ||
                                                     QuestInfo.RepeatableQuests.Contains(x)).ToImmutable();

                // If they don't have any quests, continue
                if (incomplete.IsEmpty())
                {
                    continue;
                }

                // For each of the four indicators, start at the "highest priority" one and stop when we find
                // the first valid status that we can use
                if (CheckStatusTurnIn(incomplete))
                {
                    IndicatorDrawer(QuestTurnInIndicator, c, e.SpriteBatch);
                    continue;
                }
                else if (CheckStatusCanStart(incomplete))
                {
                    IndicatorDrawer(QuestAvailableCanStartIndicator, c, e.SpriteBatch);
                    continue;
                }
                else if (CheckStatusStarted(incomplete))
                {
                    IndicatorDrawer(QuestStartedIndicator, c, e.SpriteBatch);
                    continue;
                }
                else if (CheckStatusCannotStart(incomplete))
                {
                    IndicatorDrawer(QuestAvailableCannotStartIndicator, c, e.SpriteBatch);
                    continue;
                }
            }
        }
Ejemplo n.º 38
0
        /// <summary>
        /// Notifies the <see cref="Tool"/> before a <see cref="IDrawableMap"/>'s GUI was drawn.
        /// </summary>
        /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to use to draw.</param>
        /// <param name="map">The <see cref="IDrawableMap"/> being drawn.</param>
        internal void InvokeBeforeDrawMapGUI(ISpriteBatch spriteBatch, IDrawableMap map)
        {
            if (!IsEnabled || IsDisposed)
                return;

            HandleBeforeDrawMapGUI(spriteBatch, map);
        }
Ejemplo n.º 39
0
        /// <summary>
        /// When overridden in the derived class, handles performing drawing before the GUI for a <see cref="IDrawableMap"/> has been draw.
        /// </summary>
        /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to use to draw.</param>
        /// <param name="imap">The <see cref="IDrawableMap"/> being drawn.</param>
        protected override void HandleBeforeDrawMapGUI(ISpriteBatch spriteBatch, IDrawableMap imap)
        {
            base.HandleBeforeDrawMapGUI(spriteBatch, imap);

            var map = imap as EditorMap;
            if (map == null)
                return;

            var camera = map.Camera;
            if (camera == null)
                return;

            // Only draw for the map under the cursor
            if (map != _mouseOverMap)
                return;

            if (IsSelecting)
            {
                // Draw the selection area
                var a = camera.ToScreen(_selectionStart);
                var b = camera.ToScreen(_selectionEnd);

                if (a.QuickDistance(b) > _minSelectionAreaDrawSize)
                {
                    var rect = Rectangle.FromPoints(a, b);
                    RenderRectangle.Draw(spriteBatch, rect, _selectionAreaColorInner, _selectionAreaColorOuter);
                }
            }
            else
            {
                // Draw the tooltip
                var font = ToolTipFont;
                if (_toolTipObject != null && _toolTip != null && font != null)
                    spriteBatch.DrawStringShaded(font, _toolTip, _toolTipPos, Color.White, Color.Black);
            }
        }
Ejemplo n.º 40
0
        public static bool DrawMapGrhTooltip(ISpriteBatch spriteBatch, IDrawableMap map, MapGrh mapGrh, Vector2 worldPos)
        {
            if (mapGrh == null || mapGrh.Grh == null || mapGrh.Grh.GrhData == null)
                return false;

            Vector2 drawPos = worldPos - map.Camera.Min;
            var font = GlobalState.Instance.DefaultRenderFont;
            string txt = mapGrh.Grh.GrhData.Categorization.ToString();
            Vector2 txtSize = font.MeasureString(txt);
            Vector2 txtPos = drawPos.Max(Vector2.Zero).Min(map.Camera.Size - txtSize);
            spriteBatch.DrawStringShaded(font, txt, txtPos, Color.White, Color.Black);

            return true;
        }
Ejemplo n.º 41
0
            /// <summary>
            /// When overridden in the derived class, handles drawing to the map after all of the map drawing finishes.
            /// </summary>
            /// <param name="map">The map the drawing is taking place on.</param>
            /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param>
            /// <param name="camera">The <see cref="ICamera2D"/> that describes the view of the map being drawn.</param>
            protected override void HandleDrawAfterMap(IDrawableMap map, ISpriteBatch spriteBatch, ICamera2D camera)
            {
                var p = Parent;
                if (p == null)
                    return;

                // Ensure the map is valid
                var clientMap = map as EditorMap;
                if (clientMap == null)
                    return;

                var viewArea = camera.GetViewArea();

                // Draw the walls
                if (p.DrawWalls)
                {
                    var visibleWalls = map.Spatial.GetMany<WallEntityBase>(viewArea);
                    foreach (var wall in visibleWalls)
                    {
                        EntityDrawer.Draw(spriteBatch, camera, wall);
                    }
                }

                // Draw the MapGrh walls
                if (p.DrawMapGrhWalls)
                {
                    var mapGrhWalls = GlobalState.Instance.MapGrhWalls;
                    var toDraw = clientMap.Spatial.GetMany<MapGrh>(viewArea);
                    var tmpWall = new WallEntity(Vector2.Zero, Vector2.Zero);

                    foreach (var mg in toDraw)
                    {
                        var boundWalls = mapGrhWalls[mg.Grh.GrhData];
                        if (boundWalls == null)
                            continue;

                        foreach (var wall in boundWalls)
                        {
                            tmpWall.Size = wall.Size != Vector2.Zero ? wall.Size * mg.Scale : mg.Size;
                            tmpWall.Position = mg.Position + (wall.Position * mg.Scale);
                            tmpWall.IsPlatform = wall.IsPlatform;
                            EntityDrawer.Draw(spriteBatch, camera, tmpWall);
                        }
                    }
                }
            }
Ejemplo n.º 42
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TimeDelayedMapEventBase"/> class.
 /// </summary>
 /// <param name="map">The <see cref="IDrawableMap"/> to add the <paramref name="mapGrhEffect"/> to.</param>
 /// <param name="mapGrhEffect">The <see cref="MapGrhEffect"/> to add when the time elapses.</param>
 /// <param name="delay">The delay in milliseconds before the <paramref name="mapGrhEffect"/> is added to the map.</param>
 public TimeDelayedMapGrhEffect(IDrawableMap map, MapGrhEffect mapGrhEffect, int delay) : base(delay)
 {
     _map    = map;
     _effect = mapGrhEffect;
 }
Ejemplo n.º 43
0
        /// <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();
        }
Ejemplo n.º 44
0
            /// <summary>
            /// When overridden in the derived class, handles drawing to the map after all of the map drawing finishes.
            /// </summary>
            /// <param name="map">The map the drawing is taking place on.</param>
            /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param>
            /// <param name="camera">The <see cref="ICamera2D"/> that describes the view of the map being drawn.</param>
            protected override void HandleDrawAfterMap(IDrawableMap map, ISpriteBatch spriteBatch, ICamera2D camera)
            {
                var p = Parent;
                if (p == null)
                    return;

                // Ensure the map is valid
                var clientMap = map as EditorMap;
                if (clientMap == null)
                    return;

                var viewArea = camera.GetViewArea();

                // Draw the walls
                if (p.DrawWalls)
                {
                    var visibleWalls = map.Spatial.GetMany<WallEntityBase>(viewArea);
                    foreach (var wall in visibleWalls)
                    {
                        EntityDrawer.Draw(spriteBatch, camera, wall);
                    }
                }

                // Draw the MapGrh walls
                if (p.DrawMapGrhWalls)
                {
                    var toDraw = clientMap.Spatial.GetMany<MapGrh>(viewArea);
                    foreach (var mg in toDraw)
                    {
                        var boundWalls = GlobalState.Instance.MapGrhWalls[mg.Grh.GrhData];
                        if (boundWalls == null)
                            continue;

                        foreach (var wall in boundWalls)
                        {
                            EntityDrawer.Draw(spriteBatch, camera, wall, mg.Position);
                        }
                    }
                }
            }
Ejemplo n.º 45
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TimeDelayedMapEventBase"/> class.
 /// </summary>
 /// <param name="map">The <see cref="IDrawableMap"/> to add the <paramref name="mapGrhEffect"/> to.</param>
 /// <param name="mapGrhEffect">The <see cref="MapGrhEffect"/> to add when the time elapses.</param>
 /// <param name="delay">The delay in milliseconds before the <paramref name="mapGrhEffect"/> is added to the map.</param>
 public TimeDelayedMapGrhEffect(IDrawableMap map, MapGrhEffect mapGrhEffect, int delay) : base(delay)
 {
     _map = map;
     _effect = mapGrhEffect;
 }
Ejemplo n.º 46
0
 /// <summary>
 /// When overridden in the derived class, handles drawing to the map after all of the map drawing finishes.
 /// </summary>
 /// <param name="map">The map the drawing is taking place on.</param>
 /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param>
 /// <param name="camera">The <see cref="ICamera2D"/> that describes the view of the map being drawn.</param>
 protected override void HandleDrawAfterMap(IDrawableMap map, ISpriteBatch spriteBatch, ICamera2D camera)
 {
     _grid.Size = EditorSettings.Default.GridSize;
     _grid.Draw(spriteBatch, camera);
 }
Ejemplo n.º 47
0
 /// <summary>
 /// When overridden in the derived class, handles drawing to the map after all of the map drawing finishes.
 /// </summary>
 /// <param name="map">The map the drawing is taking place on.</param>
 /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param>
 /// <param name="camera">The <see cref="ICamera2D"/> that describes the view of the map being drawn.</param>
 protected override void HandleDrawAfterMap(IDrawableMap map, ISpriteBatch spriteBatch, ICamera2D camera)
 {
     _border.Draw(spriteBatch, map, camera);
 }
Ejemplo n.º 48
0
 /// <summary>
 /// When overridden in the derived class, handles drawing to the map before any of the map drawing starts.
 /// </summary>
 /// <param name="map">The map the drawing is taking place on.</param>
 /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param>
 /// <param name="camera">The <see cref="ICamera2D"/> that describes the view of the map being drawn.</param>
 protected virtual void HandleDrawBeforeMap(IDrawableMap map, ISpriteBatch spriteBatch, ICamera2D camera)
 {
 }
Ejemplo n.º 49
0
        /// <summary>
        /// When overridden in the derived class, handles performing drawing after the GUI for a <see cref="IDrawableMap"/> has been draw.
        /// </summary>
        /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to use to draw.</param>
        /// <param name="map">The <see cref="IDrawableMap"/> being drawn.</param>
        protected override void HandleAfterDrawMapGUI(ISpriteBatch spriteBatch, IDrawableMap map)
        {
            base.HandleAfterDrawMapGUI(spriteBatch, map);

            if (map != _mouseOverMap)
                return;

            if ((Control.ModifierKeys & _placeMapGrhKey) == 0)
                return;

            var grh = GlobalState.Instance.Map.GrhToPlace;
            grh.Draw(spriteBatch, GridAligner.Instance.Align(_mousePos, TileMode));
        }
Ejemplo n.º 50
0
 /// <summary>
 /// When overridden in the derived class, handles drawing to the map after all of the map drawing finishes.
 /// </summary>
 /// <param name="map">The map the drawing is taking place on.</param>
 /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param>
 /// <param name="camera">The <see cref="ICamera2D"/> that describes the view of the map being drawn.</param>
 protected override void HandleDrawAfterMap(IDrawableMap map, ISpriteBatch spriteBatch, ICamera2D camera)
 {
     _border.Draw(spriteBatch, map, camera);
 }
Ejemplo n.º 51
0
        /// <summary>
        /// When overridden in the derived class, handles performing drawing before the GUI for a <see cref="IDrawableMap"/> has been draw.
        /// </summary>
        /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to use to draw.</param>
        /// <param name="imap">The <see cref="IDrawableMap"/> being drawn.</param>
        protected override void HandleBeforeDrawMapGUI(ISpriteBatch spriteBatch, IDrawableMap imap)
        {
            base.HandleBeforeDrawMapGUI(spriteBatch, imap);

            if (IsSelecting)
                return;

            if ((Control.ModifierKeys & _placeLightKey) != 0)
            {
                if (imap == _mouseOverMap)
                {
                    var lightSprite = SystemSprites.Lightblub;
                    var pos = _mousePos - (lightSprite.Size / 2f);
                    pos = GridAligner.Instance.Align(pos);
                    lightSprite.Draw(spriteBatch, pos);
                }
            }
        }
Ejemplo n.º 52
0
 /// <summary>
 /// Handles setting up the <see cref="SpriteBatch"/> and drawing the <paramref name="map"/>. This is where
 /// all the actual drawing to the preview map is done.
 /// </summary>
 /// <param name="sb">The <see cref="ISpriteBatch"/> to use for drawing.</param>
 /// <param name="map">The <see cref="IDrawableMap"/> to draw.</param>
 protected virtual void DrawMap(ISpriteBatch sb, IDrawableMap map)
 {
     sb.Begin(BlendMode.Alpha, map.Camera);
     map.Draw(sb);
     sb.End();
 }
Ejemplo n.º 53
0
 /// <summary>
 /// When overridden in the derived class, handles performing drawing before the GUI for a <see cref="IDrawableMap"/> has been draw.
 /// </summary>
 /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to use to draw.</param>
 /// <param name="map">The <see cref="IDrawableMap"/> being drawn.</param>
 protected virtual void HandleBeforeDrawMapGUI(ISpriteBatch spriteBatch, IDrawableMap map)
 {
 }
Ejemplo n.º 54
0
        /// <summary>
        /// Notifies the <see cref="Tool"/> after a <see cref="IDrawableMap"/>'s GUI was drawn.
        /// </summary>
        /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to use to draw.</param>
        /// <param name="map">The <see cref="IDrawableMap"/> being drawn.</param>
        internal void InvokeAfterDrawMapGUI(ISpriteBatch spriteBatch, IDrawableMap map)
        {
            if (IsDisposed)
                return;

            HandleAfterDrawMapGUI(spriteBatch, map);
        }