예제 #1
0
 public DustFastEmitter(GameObject owner, RectangleFloat? exactHitSpot = null)
 {
     this.Owner = owner;
     ExactHitSpot = exactHitSpot;
     this.duration = TimeSpan.FromMilliseconds(100);
     this.frequency = 5;
 }
예제 #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;
        }
예제 #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;
            }
        }
예제 #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;
        }
예제 #5
0
 //done
 public override List<GameObject> MasterQuery(RectangleFloat queryBounds)
 {
     if (parent != null)
     {
         return parent.MasterQuery(queryBounds);
     }
     else
     {
         return Query(queryBounds);
     }
 }
예제 #6
0
 /// <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;
 }
예제 #7
0
        /// <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;
        }
예제 #8
0
 /// <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;
 }
예제 #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;
 }
예제 #10
0
        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);
        }
예제 #11
0
 public abstract List<GameObject> MasterQuery(RectangleFloat query);