This commit is contained in:
the 2022-11-21 16:50:22 +04:00
parent 3e84127331
commit fd9a9ed114

View File

@ -56,17 +56,13 @@ namespace Ship
private bool ObjectIntersects() private bool ObjectIntersects()
{ {
var location = _drawingObject.GetCurrentPosition(); var location = _drawingObject.GetCurrentPosition();
Debug.WriteLine(location.Left + " " + location.Right + " " + location.Top + " " + location.Bottom);
for (int i = 0; i < _map.GetLength(0); i++) for (int i = 0; i < _map.GetLength(0); i++)
{ {
for (int j = 0; j < _map.GetLength(1); j++) for (int j = 0; j < _map.GetLength(1); j++)
{ {
if (_map[i, j] == _barrier) if (_map[i, j] == _barrier)
{ {
Debug.WriteLine("Barrier found " + i * _size_x + " " + (i + 1) * _size_x + " " + j * _size_y + " " + (j+1)*_size_y + " " + (i * _size_x >= location.Left) + " " + ((i + 1) * _size_x <= location.Right) + " " + (j * _size_y >= location.Top) + " " + ((j + 1) * _size_y <= location.Bottom));
if (i * _size_x >= location.Left && (i + 1) * _size_x <= location.Right && j * _size_y >= location.Top && (j + 1) * _size_y <= location.Bottom)
{ {
Debug.WriteLine("True");
return true; return true;
} }
} }