Example #1
0
 private DropItem AddAll(DropItem to, int x, int y)
 {
     if (x > 0 && y > 0 && x < xc && y < yc)
     {
         var items = matrix[x][y];
         while (items.Next != null)
         {
             items = items.Next;
             to.Next = new DropItem(items.Dropdata);
             to = to.Next;
         }
     }
     return to;
 }
Example #2
0
        private bool Collision_Sample(CanvasDrawingSession context, Drop drop, DropItem collisions)
        {
            DropItem item = collisions;
            Drop drop2 = null;
            while (item != null)
            {
                Drop p = item.Dropdata;

                if (Math.Sqrt(Math.Pow(drop.X - p.X, 2) + Math.Pow(drop.Y - p.Y, 2)) < (drop.R + p.R))
                {
                    drop2 = p;

                    break;
                }
                item = item.Next;
            }
            if (drop2 == null)
            {
                return false;
            }

            // rename so that we're dealing with low/high drops
            Drop higher, lower;
            if (drop.Y > drop2.Y)
            {
                higher = drop;
                lower = drop2;
            }
            else
            {
                higher = drop2;
                lower = drop;
            }
            // force stopping the second drop
            ClearDrop(context, lower);
            ClearDrop(context, higher, true);
            matrix.Remove(higher);
            lower.Draw(this, context);
            lower.Colliding = higher;
            lower.Collided = true;
            return true;
        }
Example #3
0
 public DropItem(Drop drop)
 {
     dropdata = drop;
     next = null;
 }
Example #4
0
        public DropItem Collisions(Drop drop)
        {
            var item = new DropItem(null);
            var first = item;

            item = AddAll(item, drop.Gmx - 1, drop.Gmy + 1);
            item = AddAll(item, drop.Gmx, drop.Gmy + 1);
            item = AddAll(item, drop.Gmx + 1, drop.Gmy + 1);

            return first;
        }