Esempio n. 1
0
        private List <PositionedNode> GetNodesThatCollideWithShapeCollection(ShapeCollection sc, Dictionary <int, Dictionary <int, PositionedNode> > allNodes)
        {
            var returnValue = new List <PositionedNode>();

            if (sc != null && sc.Polygons != null)
            {
                foreach (Polygon polygon in sc.Polygons)
                {
                    polygon.ForceUpdateDependencies();
                }

                foreach (var xpair in allNodes)
                {
                    foreach (var ypair in xpair.Value)
                    {
                        PositionedNode node      = ypair.Value;
                        var            rectangle = new AxisAlignedRectangle {
                            Position = node.Position, ScaleX = 1, ScaleY = 1
                        };

                        if (sc.CollideAgainst(rectangle))
                        {
                            returnValue.Add(node);
                        }
                    }
                }
            }
            return(returnValue);
        }
 public bool CollideAgainst(AxisAlignedRectangle rectangle)
 {
     return(mShapes.CollideAgainst(rectangle, true, mSortAxis));
 }
 /// <summary>
 /// Returns whether this instance collides against the argument ShapeCollection.
 /// </summary>
 /// <param name="shapeCollection">The ShapeCollection to test collision against.</param>
 /// <returns>Whether collision has occurred.</returns>
 public bool CollideAgainst(ShapeCollection shapeCollection)
 {
     return(shapeCollection.CollideAgainst(this));
 }