From 0dc69f5f7d9e442906dbaa71256fde5fd8839e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=20=D0=91=D0=BE=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Sat, 29 Oct 2022 22:29:16 +0400 Subject: [PATCH] =?UTF-8?q?1=20=D1=8D=D1=82=D0=B0=D0=BF)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WarmlyShip/MapWithSetShipGeneric.cs | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/WarmlyShip/WarmlyShip/MapWithSetShipGeneric.cs b/WarmlyShip/WarmlyShip/MapWithSetShipGeneric.cs index 1de68b7..655f208 100644 --- a/WarmlyShip/WarmlyShip/MapWithSetShipGeneric.cs +++ b/WarmlyShip/WarmlyShip/MapWithSetShipGeneric.cs @@ -49,13 +49,9 @@ namespace WarmlyShip public Bitmap ShowOnMap() { Shaking(); - for (int i = 0; i < _setShips.Count; i++) + foreach (var car in _setShips.GetShips()) { - var ship = _setShips[i]; - if (ship != null) - { - return _map.CreateMap(_pictureWidth, _pictureHeight, ship); - } + return _map.CreateMap(_pictureWidth, _pictureHeight, car); } return new(_pictureWidth, _pictureHeight); } @@ -111,7 +107,7 @@ namespace WarmlyShip private void DrawShips(Graphics g) { - for (int i = 0; i < _setShips.Count; ++i) + /*for (int i = 0; i < _setShips.Count; ++i) { if (_setShips[i] != null ) { @@ -120,6 +116,19 @@ namespace WarmlyShip _setShips[i].SetObject((_pictureWidth / _placeSizeWidth - (i % (_pictureWidth / _placeSizeWidth)) - 1) * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight + temp, _pictureWidth, _pictureHeight); _setShips[i].DrawningObject(g); } + }*/ + + int i = 0; + foreach (var ship in _setShips.GetShips()) + { + if (ship != null) + { + int temp = 0; + if (ship.GetCurrentPosition().Bottom - ship.GetCurrentPosition().Top < 75) temp = (int)(ship.GetCurrentPosition().Bottom - ship.GetCurrentPosition().Top); + ship.SetObject((_pictureWidth / _placeSizeWidth - (i % (_pictureWidth / _placeSizeWidth)) - 1) * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight + temp, _pictureWidth, _pictureHeight); + ship.DrawningObject(g); + } + ++i; } }