public DustFastEmitter(GameObject owner, RectangleFloat? exactHitSpot = null)
 {
     this.Owner = owner;
     ExactHitSpot = exactHitSpot;
     this.duration = TimeSpan.FromMilliseconds(100);
     this.frequency = 5;
 }
Beispiel #2
0
        //done
        public QuadTree(RectangleFloat bounds, QuadTree parent, int objectLimit = 2)
        {
            if (bounds.Width < 2 || bounds.Height < 2)
            {
                ObjectLimit = 100; //prevention of rounding issues ^_^
            }
            else
            {
                ObjectLimit = objectLimit;
            }

            heldObjects = new List<GameObject>();
            this.hardBounds = bounds;
            this.queryBounds = bounds;
            this.parent = parent;
        }
Beispiel #3
0
        //done
        private List<GameObject> Query(RectangleFloat query)
        {
            List<GameObject> objects = new List<GameObject>();

            if (!queryBounds.Intersects(query))
            {
                return objects;
            }

            if (isParent)
            {
                objects.AddRange(NW.Query(query));
                objects.AddRange(NE.Query(query));
                objects.AddRange(SW.Query(query));
                objects.AddRange(SE.Query(query));
                return objects;
            }
            else
            {
                foreach (GameObject obj in heldObjects)
                {
                    if (obj.PhysicsCollisionBox != query && query.Intersects(obj.PhysicsCollisionBox))
                    {
                        objects.Add(obj);
                    }
                }
                return objects;
            }
        }
Beispiel #4
0
        //done
        public override bool Remove(GameObject newObject)
        {
            var success = heldObjects.Remove(newObject);

            if (success)
            {
                queryBounds = hardBounds;
                foreach (var obj in heldObjects)
                {
                    InflateBoundry(obj);
                }
            }

            return success;
        }
Beispiel #5
0
 //done
 public override List<GameObject> MasterQuery(RectangleFloat queryBounds)
 {
     if (parent != null)
     {
         return parent.MasterQuery(queryBounds);
     }
     else
     {
         return Query(queryBounds);
     }
 }
 /// <summary>
 /// if it's the very top one, set parent as null
 /// </summary>
 /// <param name="bounds">collidable area</param>
 /// <param name="parent">parent of this node</param>
 public ElasticQuadTree(RectangleFloat bounds, ElasticQuadTree parent)
 {
     this.parent = parent;
     this.bounds = bounds;
     this.queryBounds = bounds;
 }
        /// <summary>
        /// gets all objects that collide with the queryrange
        /// </summary>
        /// <param name="queryBounds">the area to query</param>
        /// <returns>objects that collide with the query</returns>
        private List<GameObject> Query(RectangleFloat query)
        {
            var preparedObjects = new List<GameObject>();

            //if it's not here, return the empty one
            if (!queryBounds.Intersects(query))
            {
                return preparedObjects;
            }

            //if it's not a parent add and return
            if (!IsParent)
            {
                if (containedObject != null && containedObject.PhysicsCollisionBox.Intersects(query.ToRectangle()))
                {
                    preparedObjects.Add(containedObject);
                }
                return preparedObjects;
            }

            //get objects in children
            preparedObjects.AddRange(NW.Query(query));
            preparedObjects.AddRange(NE.Query(query));
            preparedObjects.AddRange(SW.Query(query));
            preparedObjects.AddRange(SE.Query(query));
            return preparedObjects;
        }
 /// <summary>
 /// removes a specified object from this node and 
 /// returns whether it was removed or not found
 /// </summary>
 /// <param name="newObject">Object to remove</param>
 /// <returns>if the object was removed/found</returns>
 public override bool Remove(GameObject newObject)
 {
     if (containedObject == newObject)
     {
         containedObject = null;
         queryBounds = bounds;
         return true;
     }
     return false;
 }
Beispiel #9
0
 public Particle(Texture2D texture = null)
 {
     IsAlive = true;
     Lifetime = TimeSpan.FromMilliseconds(500);
     width = 3;
     height = 3;
     drawRectangle = new RectangleFloat(this.Position.X, this.Position.Y, width, height);
     DrawColor = Color.White;
     Texture = texture != null ? texture : AssetRepository.Instance.PlainWhiteTexture;
     Transparency = 1f;
     Rotation = 0f;
 }
        public bool Intersects(RectangleFloat value)
        {
            //this left < other right
            //this right > other left
            //this top < other bottom
            //this bottom > other top

            return (Left < value.Right && Right > value.Left && Top < value.Bottom && Bottom > value.Top);
        }
Beispiel #11
0
 public abstract List<GameObject> MasterQuery(RectangleFloat query);