Esempio n. 1
0
File: Box.cs Progetto: RastaCow/Nez
        public override bool collidesWithShape( Shape other, out CollisionResult result )
        {
            // special, high-performance cases. otherwise we fall back to Polygon.
            if( other is Box )
                return ShapeCollisions.boxToBox( this, other as Box, out result );

            // TODO: get Minkowski working for circle to box
            //if( other is Circle )

            // fallthrough to standard cases
            return base.collidesWithShape( other, out result );
        }
Esempio n. 2
0
File: Box.cs Progetto: RastaCow/Nez
        public override bool overlaps( Shape other )
        {
            // special, high-performance cases. otherwise we fall back to Polygon.
            if( other is Box )
                return bounds.intersects( ref ( other as Box ).bounds );

            if( other is Circle )
                return Collisions.rectToCircle( ref bounds, other.position, ( other as Circle ).radius );

            // fallthrough to standard cases
            return base.overlaps( other );
        }
Esempio n. 3
0
        public override bool collidesWithShape( Shape other, out CollisionResult result )
        {
            if( other is Box )
                return ShapeCollisions.circleToBox( this, other as Box, out result );

            if( other is Circle )
                return ShapeCollisions.circleToCircle( this, other as Circle, out result );

            if( other is Polygon )
                return ShapeCollisions.circleToPolygon( this, other as Polygon, out result );

            throw new NotImplementedException( string.Format( "Collisions of Circle to {0} are not supported", other ) );
        }
Esempio n. 4
0
		public override bool overlaps( Shape other )
		{
			CollisionResult result;

			// Box is only optimized for unrotated
			if( other is Box && ( other as Box ).isUnrotated )
				return Collisions.rectToCircle( ref other.bounds, position, radius );

			if( other is Circle )
				return Collisions.circleToCircle( position, radius, other.position, ( other as Circle ).radius );

			if( other is Polygon )
				return ShapeCollisions.circleToPolygon( this, other as Polygon, out result );

			throw new NotImplementedException( string.Format( "overlaps of Circle to {0} are not supported", other ) );
		}
Esempio n. 5
0
        public override bool collidesWithShape( Shape other, out CollisionResult result )
        {
            if( other is Polygon )
                return ShapeCollisions.polygonToPolygon( this, other as Polygon, out result );

            if( other is Circle )
            {
                if( ShapeCollisions.circleToPolygon( other as Circle, this, out result ) )
                {
                    result.invertResult();
                    return true;
                }
                return false;
            }

            throw new NotImplementedException( string.Format( "overlaps of Polygon to {0} are not supported", other ) );
        }
Esempio n. 6
0
 /// <summary>
 /// swept collision check
 /// </summary>
 /// <param name="first">First.</param>
 /// <param name="second">Second.</param>
 /// <param name="deltaMovement">Delta movement.</param>
 /// <param name="hit">Hit.</param>
 public static bool collide( Shape first, Shape second, Vector2 deltaMovement, out RaycastHit hit )
 {
     hit = new RaycastHit();
     throw new NotImplementedException( "this should probably be in each Shape class and it still needs to be implemented ;)" );
 }
Esempio n. 7
0
File: Shape.cs Progetto: prime31/Nez
		public abstract bool collidesWithShape( Shape other, out CollisionResult result );
Esempio n. 8
0
File: Shape.cs Progetto: prime31/Nez
		public abstract bool overlaps( Shape other );