예제 #1
0
 public static bool Intersects(SpriteShell a, Sprite b)
 {
     if (isBSPCollision(a.sectorNumber, b.POSITIONINFO.SECTORNUMBER))
     {
         if (Collision.Intersects(a.bounds, b.POSITIONINFO.BOUNDS))
         {
             return true;
         }
     }
     return false;
 }
예제 #2
0
        //Only rectangle collision?
        private bool intersectsAnyBlock(SpriteShell rectangleToCheck)
        {
            List<Block> collidables = SpriteManager.GAME.COLLIDABLES;
            List<Block> solidCollidables = SpriteManager.GAME.SOLIDCOLLIDABLES;
            List<Block> destructables = SpriteManager.GAME.DESTRUCTABLE;
            //System.Diagnostics.Debug.WriteLine(walkingLine.start + " : " + walkingLine.end);
            for (int i = 0; i < collidables.Count; i++)
            {
                if (peakHeight + POSITIONINFO.BOUNDSHEIGHT < collidables[i].POSITIONINFO.BOUNDS.Top)
                {
                    if (Collision.Intersects(rectangleToCheck.bounds, Line.getTopLine(collidables[i].POSITIONINFO.BOUNDS)))
                        return true;
                }
            }

            for (int i = 0; i < destructables.Count; i++)
            {

                if (Collision.Intersects(rectangleToCheck, destructables[i]))
                    return true;

            }

            //if you leave out the peak high stuff, it just performs a rectangle collision.
            //the thing passed in is a SpriteShell (with a bsp sector # etc) so we cover BSP aswel.
            for (int i = 0; i < solidCollidables.Count; i++)
            {
                if(Collision.Intersects(rectangleToCheck, solidCollidables[i]))
                    return true;
            }

            return false;
        }