/// <summary> /// Determines if there is an intersection between the current object and a triangle. /// </summary> /// <param name="vertex1">The first vertex of the triangle to test.</param> /// <param name="vertex2">The second vertex of the triangle to test.</param> /// <param name="vertex3">The third vertex of the triangle to test.</param> /// <param name="distance">When the method completes, contains the distance of the intersection, /// or 0 if there was no intersection.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3, out float distance) { return(CollisionHelper.RayIntersectsTriangle(ref this, ref vertex1, ref vertex2, ref vertex3, out distance)); }
/// <summary> /// Determines if there is an intersection between the current object and a <see cref="SiliconStudio.Core.Mathematics.BoundingBox"/>. /// </summary> /// <param name="box">The box to test.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref BoundingBox box) { float distance; return(CollisionHelper.RayIntersectsBox(ref this, ref box, out distance)); }
/// <summary> /// Determines whether the current objects contains a <see cref="SiliconStudio.Core.Mathematics.BoundingSphere"/>. /// </summary> /// <param name="sphere">The sphere to test.</param> /// <returns>The type of containment the two objects have.</returns> public ContainmentType Contains(ref BoundingSphere sphere) { return(CollisionHelper.SphereContainsSphere(ref this, ref sphere)); }
/// <summary> /// Determines if there is an intersection between the current object and a <see cref="SiliconStudio.Core.Mathematics.Plane"/>. /// </summary> /// <param name="plane">The plane to test.</param> /// <param name="distance">When the method completes, contains the distance of the intersection, /// or 0 if there was no intersection.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref Plane plane, out float distance) { return(CollisionHelper.RayIntersectsPlane(ref this, ref plane, out distance)); }
/// <summary> /// Determines if there is an intersection between the current object and a <see cref="SiliconStudio.Core.Mathematics.BoundingSphere"/>. /// </summary> /// <param name="sphere">The sphere to test.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref BoundingSphere sphere) { return(CollisionHelper.SphereIntersectsSphere(ref this, ref sphere)); }
/// <summary> /// Determines whether the current objects contains a triangle. /// </summary> /// <param name="vertex1">The first vertex of the triangle to test.</param> /// <param name="vertex2">The second vertex of the triagnle to test.</param> /// <param name="vertex3">The third vertex of the triangle to test.</param> /// <returns>The type of containment the two objects have.</returns> public ContainmentType Contains(ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3) { return(CollisionHelper.SphereContainsTriangle(ref this, ref vertex1, ref vertex2, ref vertex3)); }
/// <summary> /// Determines if there is an intersection between the current object and a point. /// </summary> /// <param name="point">The point to test.</param> /// <returns>Whether the two objects intersected.</returns> public PlaneIntersectionType Intersects(ref Vector3 point) { return(CollisionHelper.PlaneIntersectsPoint(ref this, ref point)); }
/// <summary> /// Determines if there is an intersection between the current object and a triangle. /// </summary> /// <param name="vertex1">The first vertex of the triangle to test.</param> /// <param name="vertex2">The second vertex of the triagnle to test.</param> /// <param name="vertex3">The third vertex of the triangle to test.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3) { return(CollisionHelper.SphereIntersectsTriangle(ref this, ref vertex1, ref vertex2, ref vertex3)); }
/// <summary> /// Determines if there is an intersection between the current object and a <see cref="Stride.Core.Mathematics.Ray"/>. /// </summary> /// <param name="ray">The ray to test.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref Ray ray) { Vector3 point; return(CollisionHelper.RayIntersectsRay(ref this, ref ray, out point)); }
public bool Contains(ref BoundingBoxExt boundingBoxExt) { return(CollisionHelper.FrustumContainsBox(ref this, ref boundingBoxExt)); }
/// <summary> /// Determines if there is an intersection between the current object and a point. /// </summary> /// <param name="point">The point to test.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref Vector3 point) { return(CollisionHelper.RayIntersectsPoint(ref this, ref point)); }
/// <summary> /// Determines if there is an intersection between the current object and a <see cref="Stride.Core.Mathematics.BoundingSphere"/>. /// </summary> /// <param name="sphere">The sphere to test.</param> /// <param name="point">When the method completes, contains the point of intersection, /// or <see cref="Stride.Core.Mathematics.Vector3.Zero"/> if there was no intersection.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref BoundingSphere sphere, out Vector3 point) { return(CollisionHelper.RayIntersectsSphere(ref this, ref sphere, out point)); }
/// <summary> /// Determines if there is an intersection between the current object and a <see cref="Stride.Core.Mathematics.BoundingSphere"/>. /// </summary> /// <param name="sphere">The sphere to test.</param> /// <param name="distance">When the method completes, contains the distance of the intersection, /// or 0 if there was no intersection.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref BoundingSphere sphere, out float distance) { return(CollisionHelper.RayIntersectsSphere(ref this, ref sphere, out distance)); }
/// <summary> /// Determines if there is an intersection between the current object and a <see cref="Stride.Core.Mathematics.BoundingBox"/>. /// </summary> /// <param name="box">The box to test.</param> /// <param name="point">When the method completes, contains the point of intersection, /// or <see cref="Stride.Core.Mathematics.Vector3.Zero"/> if there was no intersection.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref BoundingBox box, out Vector3 point) { return(CollisionHelper.RayIntersectsBox(ref this, ref box, out point)); }
/// <summary> /// Determines if there is an intersection between the current object and a <see cref="Stride.Core.Mathematics.Plane"/>. /// </summary> /// <param name="plane">The plane to test.</param> /// <param name="line">When the method completes, contains the line of intersection /// as a <see cref="Stride.Core.Mathematics.Ray"/>, or a zero ray if there was no intersection.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref Plane plane, out Ray line) { return(CollisionHelper.PlaneIntersectsPlane(ref this, ref plane, out line)); }
/// <summary> /// Determines if there is an intersection between the current object and a <see cref="SiliconStudio.Core.Mathematics.Plane"/>. /// </summary> /// <param name="plane">The plane to test.</param> /// <returns>Whether the two objects intersected.</returns> public PlaneIntersectionType Intersects(ref Plane plane) { return(CollisionHelper.PlaneIntersectsSphere(ref plane, ref this)); }
/// <summary> /// Determines if there is an intersection between the current object and a triangle. /// </summary> /// <param name="vertex1">The first vertex of the triangle to test.</param> /// <param name="vertex2">The second vertex of the triagnle to test.</param> /// <param name="vertex3">The third vertex of the triangle to test.</param> /// <returns>Whether the two objects intersected.</returns> public PlaneIntersectionType Intersects(ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3) { return(CollisionHelper.PlaneIntersectsTriangle(ref this, ref vertex1, ref vertex2, ref vertex3)); }
/// <summary> /// Determines if there is an intersection between the current object and a <see cref="SiliconStudio.Core.Mathematics.BoundingBox"/>. /// </summary> /// <param name="box">The box to test.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref BoundingBox box) { return(CollisionHelper.BoxIntersectsSphere(ref box, ref this)); }
/// <summary> /// Determines if there is an intersection between the current object and a <see cref="Stride.Core.Mathematics.BoundingBox"/>. /// </summary> /// <param name="box">The box to test.</param> /// <returns>Whether the two objects intersected.</returns> public PlaneIntersectionType Intersects(ref BoundingBox box) { return(CollisionHelper.PlaneIntersectsBox(ref this, ref box)); }
/// <summary> /// Determines whether the current objects contains a point. /// </summary> /// <param name="point">The point to test.</param> /// <returns>The type of containment the two objects have.</returns> public ContainmentType Contains(ref Vector3 point) { return(CollisionHelper.SphereContainsPoint(ref this, ref point)); }
/// <summary> /// Determines if there is an intersection between the current object and a <see cref="Stride.Core.Mathematics.BoundingSphere"/>. /// </summary> /// <param name="sphere">The sphere to test.</param> /// <returns>Whether the two objects intersected.</returns> public PlaneIntersectionType Intersects(ref BoundingSphere sphere) { return(CollisionHelper.PlaneIntersectsSphere(ref this, ref sphere)); }
/// <summary> /// Determines whether the current objects contains a <see cref="SiliconStudio.Core.Mathematics.BoundingBox"/>. /// </summary> /// <param name="box">The box to test.</param> /// <returns>The type of containment the two objects have.</returns> public ContainmentType Contains(ref BoundingBox box) { return(CollisionHelper.SphereContainsBox(ref this, ref box)); }
public override void Update(GameTime gameTime) { playerCollisions.X = (int)Position.X; playerCollisions.Y = (int)Position.Y; if (_MovementType == MovementType.FLY) { Direction = new Vector2((_Player.Position.X + (_Player.PositionCenter.X)) - (Position.X + (PositionCenter.X)), (_Player.Position.Y + (_Player.PositionCenter.Y)) - (Position.Y + (PositionCenter.Y))); } else if (_MovementType == MovementType.HORIZONTAL || _MovementType == MovementType.BOUNCE || _MovementType == MovementType.BOSSBOUNCE) { Direction.X = (_Player.Position.X + (_Player.PositionCenter.X)) - (Position.X + (PositionCenter.X)); } else { Direction = Vector2.Zero; } if (_MovementType != MovementType.BOSSHEAD && CollisionHelper.Magnitude(Direction) <= 200) { if (_MovementType != MovementType.FLY) { Direction.X = CollisionHelper.UnitVector(Direction).X; } else { Direction = CollisionHelper.UnitVector(Direction); } if (_Player.Position.X == Position.X) { if (_MovementType == MovementType.FLY) { Direction = new Vector2(0, 0); } else { Direction.X = 0; } } if (_MovementType != MovementType.BOUNCE || _MovementType != MovementType.BOSSBOUNCE) { SetAnimation("CHASE"); } Position += Direction; if (_MovementType == MovementType.FLY) { Rotation += 0.05f; } } else { if (_MovementType != MovementType.BOUNCE || _MovementType != MovementType.BOSSBOUNCE) { SetAnimation("IDLE"); } } if (_MovementType != MovementType.BOSSBOUNCE) { foreach (Projectile p in _Player.ProjectileList) { if (playerCollisions.TouchLeftOf(p.projectileRectangle) || playerCollisions.TouchTopOf(p.projectileRectangle) || playerCollisions.TouchRightOf(p.projectileRectangle) || playerCollisions.TouchBottomOf(p.projectileRectangle)) { DeleteMe = true; } } } else if (_MovementType == MovementType.BOSSHEAD) { foreach (Projectile p in _Player.ProjectileList) { if (playerCollisions.TouchLeftOf(p.projectileRectangle) || playerCollisions.TouchTopOf(p.projectileRectangle) || playerCollisions.TouchRightOf(p.projectileRectangle) || playerCollisions.TouchBottomOf(p.projectileRectangle)) { } } } if (_MovementType == MovementType.BOSSHEAD) { if (Lives <= 27 && Lives > 18) { SetAnimation("IDLE1"); } else if (Lives <= 18 && Lives > 9) { SetAnimation("IDLE2"); } else if (Lives <= 9) { SetAnimation("IDLE3"); } } if (Lives <= 0) { Dead = true; } foreach (Rectangle r in MapTiles) { CheckCollision(playerCollisions, r); } foreach (Rectangle r in MapSides) { CheckCollision(playerCollisions, r); } if (_MovementType == MovementType.BOUNCE || _MovementType == MovementType.BOSSBOUNCE) { if (!isJumping && !canFall) { isJumping = true; position.Y -= GravityForce * 1.03f; SetAnimation("CHASE"); } if (canFall) { SetAnimation("FALLING"); } } if (_MovementType != MovementType.FLY) { position.Y += Direction.Y; } UpdateGravity(); LastFrameTime += gameTime.ElapsedGameTime.Milliseconds; if (LastFrameTime >= CurrentAnimation.framesPerMillisecond) { CurrentFrame.X++; if (CurrentFrame.X >= CurrentAnimation.sheetSize.X) { CurrentFrame.Y++; if (_MovementType != MovementType.BOUNCE) { CurrentFrame.X = 0; } else { CurrentFrame.X = CurrentAnimation.sheetSize.X; } if (CurrentFrame.Y >= CurrentAnimation.sheetSize.Y) { CurrentFrame.Y = 0; } } LastFrameTime = 0; } PositionCenter = new Vector2((CurrentAnimation.frameSize.X / 2), (CurrentAnimation.frameSize.Y / 2)); }
/// <summary> /// Determines if there is an intersection between the current object and a <see cref="SiliconStudio.Core.Mathematics.Ray"/>. /// </summary> /// <param name="ray">The ray to test.</param> /// <param name="distance">When the method completes, contains the distance of the intersection, /// or 0 if there was no intersection.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref Ray ray, out float distance) { return(CollisionHelper.RayIntersectsSphere(ref ray, ref this, out distance)); }
/// <summary> /// Determines if there is an intersection between the current object and a <see cref="SiliconStudio.Core.Mathematics.Ray"/>. /// </summary> /// <param name="ray">The ray to test.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref Ray ray) { float distance; return(CollisionHelper.RayIntersectsBox(ref ray, ref this, out distance)); }
/// <summary> /// Determines if there is an intersection between the current object and a <see cref="SiliconStudio.Core.Mathematics.Plane"/>. /// </summary> /// <param name="plane">The plane to test.</param> /// <param name="point">When the method completes, contains the point of intersection, /// or <see cref="SiliconStudio.Core.Mathematics.Vector3.Zero"/> if there was no intersection.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref Plane plane, out Vector3 point) { return(CollisionHelper.RayIntersectsPlane(ref this, ref plane, out point)); }
/* This implentation is wrong * /// <summary> * /// Determines if there is an intersection between the current object and a triangle. * /// </summary> * /// <param name="vertex1">The first vertex of the triangle to test.</param> * /// <param name="vertex2">The second vertex of the triagnle to test.</param> * /// <param name="vertex3">The third vertex of the triangle to test.</param> * /// <returns>Whether the two objects intersected.</returns> * public bool Intersects(ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3) * { * return Collision.BoxIntersectsTriangle(ref this, ref vertex1, ref vertex2, ref vertex3); * } */ /// <summary> /// Determines if there is an intersection between the current object and a <see cref="SiliconStudio.Core.Mathematics.BoundingBox"/>. /// </summary> /// <param name="box">The box to test.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref BoundingBox box) { return(CollisionHelper.BoxIntersectsBox(ref this, ref box)); }
/// <summary> /// Determines if there is an intersection between the current object and a triangle. /// </summary> /// <param name="vertex1">The first vertex of the triangle to test.</param> /// <param name="vertex2">The second vertex of the triangle to test.</param> /// <param name="vertex3">The third vertex of the triangle to test.</param> /// <param name="point">When the method completes, contains the point of intersection, /// or <see cref="SiliconStudio.Core.Mathematics.Vector3.Zero"/> if there was no intersection.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3, out Vector3 point) { return(CollisionHelper.RayIntersectsTriangle(ref this, ref vertex1, ref vertex2, ref vertex3, out point)); }
/// <summary> /// Determines if there is an intersection between the current object and a <see cref="SiliconStudio.Core.Mathematics.Ray"/>. /// </summary> /// <param name="ray">The ray to test.</param> /// <param name="point">When the method completes, contains the point of intersection, /// or <see cref="SiliconStudio.Core.Mathematics.Vector3.Zero"/> if there was no intersection.</param> /// <returns>Whether the two objects intersected.</returns> public bool Intersects(ref Ray ray, out Vector3 point) { return(CollisionHelper.RayIntersectsSphere(ref ray, ref this, out point)); }
/// <summary> /// Allows the game component to perform any initialization it needs to before starting /// to run. This is where it can query for any required services and load content. /// </summary> public override void Initialize() { spriteBatch = new SpriteBatch(Game.GraphicsDevice); levelBuilder = new LevelBuilder(); _collisionHelper = new CollisionHelper(); buffer = 0; base.Initialize(); }
public void RectangleCollision_True() { var col1 = CollisionHelper.RectangleCollision(new Rectangle(0, 0, 4, 4), new Rectangle(0, 0, 2, 2)); col1.Should().BeTrue(); }