/// <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);
     }
 }
Esempio n. 3
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);
            }
        }
Esempio n. 4
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);
                }
            }
        }
        /// <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);
            }
        }
Esempio n. 6
0
        public void Draw(ISpriteBatch sb)
        {
            var cam = Camera;

            if (cam == null)
            {
                const string errmsg = "The camera on map `{0}` was null - cannot draw map.";
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat(errmsg, this);
                }
                Debug.Fail(string.Format(errmsg, this));
                return;
            }

            // Find the drawable objects that are in view and pass the filter (if one is provided)
            var viewArea = cam.GetViewArea();

            IEnumerable <IDrawable> drawableInView;
            IEnumerable <IDrawable> bgInView;

            if (DrawFilter != null)
            {
                drawableInView = Spatial.GetMany <IDrawable>(viewArea, x => DrawFilter(x));
                bgInView       = _backgroundImages.Cast <IDrawable>().Where(x => DrawFilter(x) && x.InView(cam));
            }
            else
            {
                drawableInView = Spatial.GetMany <IDrawable>(viewArea);
                bgInView       = _backgroundImages.Cast <IDrawable>().Where(x => x.InView(cam));
            }

            // Concat the background images (to the start of the list) since they aren't in any spatials
            drawableInView = bgInView.Concat(drawableInView);

            if (BeginDrawMap != null)
            {
                BeginDrawMap.Raise(this, new DrawableMapDrawEventArgs(sb, cam));
            }

            // Sort all the items, then start drawing them layer-by-layer, item-by-item
            foreach (var tmpLayer in _drawableSorter.GetSorted(drawableInView))
            {
                var layer = tmpLayer;

                var layerEventArgs = new DrawableMapDrawLayerEventArgs(layer.Key, sb, cam);

                // Notify the layer has started drawing
                if (BeginDrawMapLayer != null)
                {
                    BeginDrawMapLayer.Raise(this, layerEventArgs);
                }

                // Draw the normal map objects
                foreach (var drawable in layer.Value)
                {
                    drawable.Draw(sb);
                }

                // Get the effects to draw, then draw them (if possible)
                foreach (var mapEffect in _mapEffects)
                {
                    if (mapEffect.MapRenderLayer == layer.Key && mapEffect.InView(cam))
                    {
                        mapEffect.Draw(sb);
                    }
                }

                // Notify the layer has finished drawing
                if (EndDrawMapLayer != null)
                {
                    EndDrawMapLayer.Raise(this, layerEventArgs);
                }
            }

            // Draw the particle effects
            if (DrawParticles)
            {
                foreach (var pe in ParticleEffects)
                {
                    if (pe.InView(cam))
                    {
                        pe.Draw(sb);
                    }
                }
            }

            if (EndDrawMap != null)
            {
                EndDrawMap.Raise(this, new DrawableMapDrawEventArgs(sb, cam));
            }
        }
        /// <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;
                }
            }
        }