示例#1
0
 public override bool Equals(object obj)
 {
     if (obj is ColliderPair)
     {
         ColliderPair other = (ColliderPair)obj;
         return(this.self == other.self && this.other == other.other);
     }
     return(false);
 }
示例#2
0
        public void Add(CollisionChild cc)
        {
            ColliderPair cp = new ColliderPair(cc.self, cc.other);

            if (childs.ContainsKey(cp))
            {
                childs [cp].Add(cc);
            }
            else
            {
                List <CollisionChild> ccs = new List <CollisionChild> ();
                childs [cp] = ccs;
                ccs.Add(cc);
            }
            cc.t = cc.self.t + (1 - cc.self.t) * cc.t;
        }
示例#3
0
 public void BuildAndBroadcast()
 {
     foreach (KeyValuePair <ColliderPair, List <CollisionChild> > kvp in childs)
     {
         ColliderPair          key = kvp.Key;
         List <CollisionChild> ccs = kvp.Value;
         //ccs.Sort ((a, b) => a.t.CompareTo (b.t));
         int       l   = ccs.Count;
         Collision col = new Collision(key.self, key.other,
                                       new Vector2[l], new Vector2[l], new Vector2[l], new float[l]);
         int i = 0;
         IEnumerator <CollisionChild> en = ccs.GetEnumerator();
         while (en.MoveNext())
         {
             CollisionChild cc = en.Current;
             col.contactPoints [i]  = cc.contactPoint;
             col.depenetrations [i] = cc.depenetration;
             col.normals [i]        = cc.normal;
             col.ts [i]             = cc.t;
             ++i;
         }
         key.self.AddCollision(col);
     }
 }