Добавления, изменения

This commit is contained in:
the 2022-10-11 08:47:14 +04:00
parent 1bb6a06e74
commit d9bd7fc54d
4 changed files with 7 additions and 6 deletions

View File

@ -56,17 +56,14 @@ namespace Ship
private bool ObjectIntersects()
{
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 j = 0; j < _map.GetLength(1); j++)
{
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;
}
}

View File

@ -165,7 +165,8 @@
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxSelectorMap.FormattingEnabled = true;
this.comboBoxSelectorMap.Items.AddRange(new object[] {
"Простая карта"});
"Простая карта",
"Водная карта"});
this.comboBoxSelectorMap.Location = new System.Drawing.Point(19, 22);
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
this.comboBoxSelectorMap.Size = new System.Drawing.Size(169, 23);

View File

@ -37,6 +37,9 @@ namespace Ship
case "Простая карта":
map = new SimpleMap();
break;
case "Водная карта":
map = new WaterMap();
break;
}
if (map != null)
{

View File

@ -33,8 +33,8 @@ namespace Ship
}
while (counter < 10)
{
int x = _random.Next(2, 49);
int y = _random.Next(3, 50);
int x = _random.Next(2, 48);
int y = _random.Next(3, 48);
var points = new int[] { _map[x, y], _map[x, y + 1], _map[x - 1, y + 1], _map[x + 1, y + 1] };
var forComparison = new int[] { _freeRoad, _freeRoad, _freeRoad, _freeRoad };
if (points.SequenceEqual(forComparison))