Exemple #1
0
        /// <summary>
        /// When overridden in the derived class, handles drawing to the buffer.
        /// </summary>
        /// <param name="rt">The <see cref="RenderTarget"/> to draw to.</param>
        /// <param name="sb">The <see cref="ISpriteBatch"/> to use to draw to the <paramref name="rt"/>. The derived class
        /// is required to handle making Begin()/End() calls on it.</param>
        /// <param name="camera">The <see cref="ICamera2D"/> to use when drawing.</param>
        /// <returns>True if the drawing was successful; false if there were any errors while drawing.</returns>
        protected override bool HandleDrawBuffer(RenderTarget rt, ISpriteBatch sb, ICamera2D camera)
        {
            // Draw the lights
            sb.Begin(BlendMode.Add, camera);

            foreach (var light in this)
            {
                if (camera.InView(light))
                    light.Draw(sb);
            }

            sb.End();

            return true;
        }
Exemple #2
0
        /// <summary>
        /// When overridden in the derived class, handles drawing to the buffer.
        /// </summary>
        /// <param name="rt">The <see cref="RenderTarget"/> to draw to.</param>
        /// <param name="sb">The <see cref="ISpriteBatch"/> to use to draw to the <paramref name="rt"/>. The derived class
        /// is required to handle making Begin()/End() calls on it.</param>
        /// <param name="camera">The <see cref="ICamera2D"/> to use when drawing.</param>
        /// <returns>True if the drawing was successful; false if there were any errors while drawing.</returns>
        protected override bool HandleDrawBuffer(RenderTarget rt, ISpriteBatch sb, ICamera2D camera)
        {
            // Draw the lights
            sb.Begin(BlendMode.Add, camera);

            foreach (var light in this)
            {
                if (camera.InView(light))
                {
                    light.Draw(sb);
                }
            }

            sb.End();

            return(true);
        }
Exemple #3
0
        /// <summary>
        /// Checks if in the object is in view of the specified <paramref name="camera"/>.
        /// </summary>
        /// <param name="camera">The <see cref="ICamera2D"/> to check if this object is in view of.</param>
        /// <returns>True if the object is in view of the camera, else False.</returns>
        public bool InView(ICamera2D camera)
        {
            // Check if in view by using the _min/_maxParticlePosition

            // If both are equal to 0, then it probably has not been updated yet, so return true to be safe
            if (_minParticlePosition == Vector2.Zero && _maxParticlePosition == Vector2.Zero)
            {
                return(true);
            }

            // Create a rect of the world position covering the area
            Vector2   ownerPos = Owner.Position;
            Vector2   min      = _minParticlePosition + ownerPos;
            Vector2   max      = _maxParticlePosition + ownerPos;
            Vector2   size     = max - min;
            Rectangle rect     = new Rectangle(min.X, min.Y, size.X, size.Y);

            // Inflact the rect's size to cover more area, just to be safe
            rect.Inflate(96);

            return(camera.InView(rect));
        }
Exemple #4
0
 /// <summary>
 /// Checks if in the object is in view of the specified <paramref name="camera"/>.
 /// </summary>
 /// <param name="camera">The <see cref="ICamera2D"/> to check if this object is in view of.</param>
 /// <returns>
 /// True if the object is in view of the camera, else False.
 /// </returns>
 public bool InView(ICamera2D camera)
 {
     return camera.InView(this);
 }
Exemple #5
0
 /// <summary>
 /// Checks if in the object is in view of the specified <paramref name="camera"/>.
 /// </summary>
 /// <param name="camera">The <see cref="ICamera2D"/> to check if this object is in view of.</param>
 /// <returns>
 /// True if the object is in view of the camera, else False.
 /// </returns>
 public bool InView(ICamera2D camera)
 {
     return camera.InView(_grh, Position);
 }
        /// <summary>
        /// Checks if in the object is in view of the specified <paramref name="camera"/>.
        /// </summary>
        /// <param name="camera">The <see cref="ICamera2D"/> to check if this object is in view of.</param>
        /// <returns>True if the object is in view of the camera, else False.</returns>
        public bool InView(ICamera2D camera)
        {
            // Check if in view by using the _min/_maxParticlePosition
            
            // If both are equal to 0, then it probably has not been updated yet, so return true to be safe
            if (_minParticlePosition == Vector2.Zero && _maxParticlePosition == Vector2.Zero)
                return true;

            // Create a rect of the world position covering the area
            Vector2 ownerPos = Owner.Position;
            Vector2 min = _minParticlePosition + ownerPos;
            Vector2 max = _maxParticlePosition + ownerPos;
            Vector2 size = max - min;
            Rectangle rect = new Rectangle(min.X, min.Y, size.X, size.Y);

            // Inflact the rect's size to cover more area, just to be safe
            rect.Inflate(96);

            return camera.InView(rect);
        }
Exemple #7
0
 /// <summary>
 /// Checks if in the object is in view of the specified <paramref name="camera"/>.
 /// </summary>
 /// <param name="camera">The <see cref="ICamera2D"/> to check if this object is in view of.</param>
 /// <returns>
 /// True if the object is in view of the camera, else False.
 /// </returns>
 public bool InView(ICamera2D camera)
 {
     return(camera.InView(this));
 }
Exemple #8
0
 /// <summary>
 /// Checks if in the object is in view of the specified <paramref name="camera"/>.
 /// </summary>
 /// <param name="camera">The <see cref="ICamera2D"/> to check if this object is in view of.</param>
 /// <returns>
 /// True if the object is in view of the camera, else False.
 /// </returns>
 public bool InView(ICamera2D camera)
 {
     return(camera.InView(_grh, Position));
 }