From 80ef61aef39dde3ca61f4cf81c889082f54c4658 Mon Sep 17 00:00:00 2001 From: pnevmoslon1 Date: Tue, 23 Apr 2024 01:55:46 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BE=D1=82=D1=80=D0=B8=D1=81=D0=BE=D0=B2?= =?UTF-8?q?=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractCompany.cs | 2 +- .../CollectionGenericObjects/PortForShips.cs | 18 +++++++++++++++--- .../WarmlyShip/Drawnings/DrawningShip.cs | 18 +++++++++--------- .../WarmlyShip/Drawnings/DrawningWarmlyShip.cs | 4 ++-- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/WarmlyShip/WarmlyShip/CollectionGenericObjects/AbstractCompany.cs b/WarmlyShip/WarmlyShip/CollectionGenericObjects/AbstractCompany.cs index 0a04782..fc79304 100644 --- a/WarmlyShip/WarmlyShip/CollectionGenericObjects/AbstractCompany.cs +++ b/WarmlyShip/WarmlyShip/CollectionGenericObjects/AbstractCompany.cs @@ -9,7 +9,7 @@ public abstract class AbstractCompany protected readonly int _placeSizeWidth = 150; - protected readonly int _placeSizeHeight = 80; + protected readonly int _placeSizeHeight = 85; protected readonly int _pictureWidth; diff --git a/WarmlyShip/WarmlyShip/CollectionGenericObjects/PortForShips.cs b/WarmlyShip/WarmlyShip/CollectionGenericObjects/PortForShips.cs index 3da5b2b..8b87612 100644 --- a/WarmlyShip/WarmlyShip/CollectionGenericObjects/PortForShips.cs +++ b/WarmlyShip/WarmlyShip/CollectionGenericObjects/PortForShips.cs @@ -36,17 +36,29 @@ namespace WarmlyShip.CollectionGenericObjects protected override void SetObjectPosition() { - int countOfHorizontal = _pictureWidth / (_placeSizeWidth + _placeSizeWidth / 2) + 1; + int countOfHorizontal = _pictureWidth / (_placeSizeWidth + _placeSizeWidth / 2); int countOfVertical = _pictureHeight / _placeSizeHeight; + int countW = 0; + int countH = 0; + for (int i = 1; i < _collection.Count; i++) { + + if (countW == 4) + { + countW = 0; + countH++; + } if (_collection.Get(i) != null) { + _collection.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight); - _collection.Get(i)?.SetPosition((_placeSizeWidth + _placeSizeWidth / 2) * (i % countOfHorizontal - 1) + 5, - _placeSizeHeight * (i / countOfHorizontal - 1) + 5); + + _collection.Get(i)?.SetPosition((_placeSizeWidth + _placeSizeWidth / 2) * (countOfHorizontal - countW - 1) + 5, _placeSizeHeight * countH + 5); + } + countW++; } } } diff --git a/WarmlyShip/WarmlyShip/Drawnings/DrawningShip.cs b/WarmlyShip/WarmlyShip/Drawnings/DrawningShip.cs index 6aa4819..9b8c86b 100644 --- a/WarmlyShip/WarmlyShip/Drawnings/DrawningShip.cs +++ b/WarmlyShip/WarmlyShip/Drawnings/DrawningShip.cs @@ -159,23 +159,23 @@ public class DrawningShip Point[] points = new Point[] { - new Point(_startPosX.Value, _startPosY.Value+20), - new Point(_startPosX.Value + 150, _startPosY.Value+ 20), - new Point(_startPosX.Value + 120, _startPosY.Value + 50), - new Point(_startPosX.Value + 30, _startPosY.Value + 50) + new Point(_startPosX.Value, _startPosY.Value+50), + new Point(_startPosX.Value + 150, _startPosY.Value+ 50), + new Point(_startPosX.Value + 120, _startPosY.Value + 80), + new Point(_startPosX.Value + 30, _startPosY.Value + 80) }; g.FillPolygon(brMain, points); g.DrawPolygon(pen, points); //палуба - g.FillRectangle(brMain, _startPosX.Value + 25, _startPosY.Value, 100, 20); - g.DrawRectangle(pen, _startPosX.Value + 25, _startPosY.Value, 100, 20); + g.FillRectangle(brMain, _startPosX.Value + 25, _startPosY.Value + 30, 100, 20); + g.DrawRectangle(pen, _startPosX.Value + 25, _startPosY.Value + 30, 100, 20); //якорь - g.DrawLine(pen, _startPosX.Value + 30, _startPosY.Value + 23, _startPosX.Value + 30, _startPosY.Value + 40); - g.DrawLine(pen, _startPosX.Value + 23, _startPosY.Value + 40, _startPosX.Value + 37, _startPosY.Value + 40); - g.DrawLine(pen, _startPosX.Value + 23, _startPosY.Value + 30, _startPosX.Value + 37, _startPosY.Value + 30); + g.DrawLine(pen, _startPosX.Value + 30, _startPosY.Value + 53, _startPosX.Value + 30, _startPosY.Value + 70); + g.DrawLine(pen, _startPosX.Value + 23, _startPosY.Value + 70, _startPosX.Value + 37, _startPosY.Value + 70); + g.DrawLine(pen, _startPosX.Value + 23, _startPosY.Value + 60, _startPosX.Value + 37, _startPosY.Value + 60); diff --git a/WarmlyShip/WarmlyShip/Drawnings/DrawningWarmlyShip.cs b/WarmlyShip/WarmlyShip/Drawnings/DrawningWarmlyShip.cs index d60a0f0..260c1b7 100644 --- a/WarmlyShip/WarmlyShip/Drawnings/DrawningWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/Drawnings/DrawningWarmlyShip.cs @@ -23,9 +23,9 @@ namespace WarmlyShip.Drawnings return; } - _startPosY += 30; + base.DrawTransport(g); - _startPosY -= 30; +