исправил нерабочий кал

This commit is contained in:
Макс Бондаренко 2022-12-13 19:20:57 +04:00
parent 7932eac791
commit 1210667283
3 changed files with 9 additions and 2 deletions

View File

@ -69,6 +69,12 @@ namespace WarmlyShip
return false; return false;
} }
if ((ship is EntityMotorShip) && !(otherShipShip is EntityMotorShip)
|| !(ship is EntityMotorShip) && (otherShipShip is EntityMotorShip))
{
return false;
}
if (ship is EntityMotorShip motorShip && otherShipShip is EntityMotorShip otherMotorShip) if (ship is EntityMotorShip motorShip && otherShipShip is EntityMotorShip otherMotorShip)
{ {
if (motorShip.DopColor != otherMotorShip.DopColor) if (motorShip.DopColor != otherMotorShip.DopColor)

View File

@ -17,8 +17,8 @@ namespace WarmlyShip
public EntityWarmlyShip(int speed, float weight, Color bodyColor) public EntityWarmlyShip(int speed, float weight, Color bodyColor)
{ {
Random random = new Random(); Random random = new Random();
Speed = speed <= 0 ? random.Next(100, 300) : speed; Speed = speed <= 0 ? 100 : speed;
Weight = weight <= 0 ? random.Next(1000, 2000) : weight; Weight = weight <= 0 ? 1000 : weight;
BodyColor = bodyColor; BodyColor = bodyColor;
} }
} }

View File

@ -113,6 +113,7 @@ namespace WarmlyShip
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
_logger.LogInformation($"Добавлен объект: {ship} на карте: {listBoxMaps.SelectedItem}"); _logger.LogInformation($"Добавлен объект: {ship} на карте: {listBoxMaps.SelectedItem}");
} }
else MessageBox.Show("Объект не добавлен");
} }
catch (StorageOverflowException ex) catch (StorageOverflowException ex)
{ {