/// <summary> /// Check if it is possible to move in the specified direction without colliding with anything. /// </summary> private bool CanMove(Vector2 velocity) { CircleCollider newCollider = (CircleCollider)Collider; newCollider.Position += velocity; if (Level.Collidables.Any(c => c != this && (c is Tank || c is Obstacle) && c.Collider.Intersects(newCollider))) { return(false); } var screenBounds = new Rectangle(0, 0, 1280, 720); if (!screenBounds.Contains(newCollider.GetRekt())) { return(false); } return(true); }
public bool Intersects(CircleCollider circle) { return(circle.Intersects(this)); }