Пример #1
0
 private void CheckChildCollisions(PairList <ICollidable> CollisionList)
 {
     if (Children != null)
     {
         for (int i = 0; i < Children.Length; i++)
         {
             Children[i].CheckChildCollisions(CollisionList);
         }
     }
     else
     {
         Collisions.Clear();
         if (Objects.Count >= 2)
         {
             for (int i = 0; i < Objects.Count - 1; i++)
             {
                 for (int j = i + 1; j < Objects.Count; j++)
                 {
                     if (Objects[i].Shape.Intersects(Objects[j].Shape))
                     {
                         CollisionList.Add(Objects[i], Objects[j]);
                         Collisions.Add(Objects[i], Objects[j]);
                     }
                 }
             }
         }
     }
 }
Пример #2
0
 private QuadTree(float x, float y, float w, float h, QuadTree Root)
     : base(x, y, w, h)
 {
     Objects    = new List <ICollidable>();
     Collisions = new PairList <ICollidable>();
     Offset     = new Vector2D();
     this.Root  = Root;
 }
Пример #3
0
 public QuadTree(float x, float y, float w, float h)
     : base(x, y, w, h)
 {
     Objects    = new List <ICollidable>();
     Collisions = new PairList <ICollidable>();
     Offset     = new Vector2D();
     Root       = this;
 }
Пример #4
0
 private QuadTree(double x, double y, double w, double h, QuadTree Root)
     : base(x, y, w, h)
 {
     Objects    = new List <ICollidable>();
     Collisions = new PairList <ICollidable>();
     Offset     = new Vector2D();
     this.Root  = Root;
 }
Пример #5
0
 public QuadTree(double x, double y, double w, double h)
     : base(x, y, w, h)
 {
     Objects    = new List <ICollidable>();
     Collisions = new PairList <ICollidable>();
     Offset     = new Vector2D();
     Root       = this;
 }
Пример #6
0
        private void CheckCollisions(double ElapsedTime, List <ICollidable> Objects)
        {
            QTree.Clear();
            for (int i = 0; i < Objects.Count; i++)
            {
                QTree.Add(Objects[i]);
            }
            QTree.CheckCollisions();

            PairList <ICollidable> Collisions = QTree.GetCollisions();

            for (int i = 0; i < Collisions.Count; i++)
            {
                Collisions.Get(i).Get(0).Collide(Collisions.Get(i).Get(1));
                Collisions.Get(i).Get(1).Collide(Collisions.Get(i).Get(0));
            }
        }