From 67fcdb81189028f5a7187acde4d5c3c5ff5e28e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Sat, 1 Oct 2022 04:30:10 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D0=B8=D0=BD=D0=B4=D0=B5=D0=BA=D1=81=D0=B0?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=B0=20=D0=BF=D0=BE=20=D0=BA=D0=B0=D1=80?= =?UTF-8?q?=D1=82=D0=B0=D0=BC=20=D0=B8=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA?= =?UTF-8?q?=D1=82=D0=B0=D0=BC=20=D0=BA=D0=B0=D1=80=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AirBomber/MapWithSetAirplanesGeneric.cs | 28 +++++++++---------- AirBomber/AirBomber/MapsCollection.cs | 9 ++++++ 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs b/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs index a039593..339ddbf 100644 --- a/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs +++ b/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs @@ -29,7 +29,7 @@ namespace AirBomber /// /// Набор объектов /// - private readonly SetAirplanesGeneric _setAirplanes; + public SetAirplanesGeneric SetAirplanes { get; private set; } /// /// Карта /// @@ -44,7 +44,7 @@ namespace AirBomber { int width = picWidth / _placeSizeWidth; int height = picHeight / _placeSizeHeight; - _setAirplanes = new SetAirplanesGeneric(width * height); + SetAirplanes = new SetAirplanesGeneric(width * height); _pictureWidth = picWidth; _pictureHeight = picHeight; _map = map; @@ -57,7 +57,7 @@ namespace AirBomber /// public static bool operator +(MapWithSetAirplanesGeneric map, T airplane) { - return map._setAirplanes.Insert(airplane); + return map.SetAirplanes.Insert(airplane); } /// /// Перегрузка оператора вычитания @@ -67,7 +67,7 @@ namespace AirBomber /// public static bool operator -(MapWithSetAirplanesGeneric map, int position) { - return map._setAirplanes.Remove(position); + return map.SetAirplanes.Remove(position); } /// /// Вывод всего набора объектов @@ -88,9 +88,9 @@ namespace AirBomber public Bitmap ShowOnMap() { Shaking(); - for (int i = 0; i < _setAirplanes.Count; i++) + for (int i = 0; i < SetAirplanes.Count; i++) { - var airplane = _setAirplanes[i]; + var airplane = SetAirplanes[i]; if (airplane != null) { return _map.CreateMap(_pictureWidth, _pictureHeight, airplane); @@ -116,18 +116,18 @@ namespace AirBomber /// private void Shaking() { - int j = _setAirplanes.Count - 1; - for (int i = 0; i < _setAirplanes.Count; i++) + int j = SetAirplanes.Count - 1; + for (int i = 0; i < SetAirplanes.Count; i++) { - if (_setAirplanes[i] == null) + if (SetAirplanes[i] == null) { for (; j > i; j--) { - var airplane = _setAirplanes[j]; + var airplane = SetAirplanes[j]; if (airplane != null) { - _setAirplanes.Insert(airplane, i); - _setAirplanes.Remove(j); + SetAirplanes.Insert(airplane, i); + SetAirplanes.Remove(j); break; } } @@ -172,9 +172,9 @@ namespace AirBomber { int countInLine = _pictureWidth / _placeSizeWidth; int maxLeft = (countInLine - 1) * _placeSizeWidth; - for (int i = 0; i < _setAirplanes.Count; i++) + for (int i = 0; i < SetAirplanes.Count; i++) { - var airplane = _setAirplanes[i]; + var airplane = SetAirplanes[i]; airplane?.SetObject(maxLeft - i % countInLine * _placeSizeWidth, i / countInLine * _placeSizeHeight + 3, _pictureWidth, _pictureHeight); airplane?.DrawningObject(g); } diff --git a/AirBomber/AirBomber/MapsCollection.cs b/AirBomber/AirBomber/MapsCollection.cs index f2e3362..523f035 100644 --- a/AirBomber/AirBomber/MapsCollection.cs +++ b/AirBomber/AirBomber/MapsCollection.cs @@ -71,5 +71,14 @@ namespace AirBomber return mapWithSetAirplanesGeneric; } } + + public DrawningObject this[string ind, int indDrawningObject] + { + get + { + _mapStorages.TryGetValue(ind, out var mapWithSetAirplanesGeneric); + return mapWithSetAirplanesGeneric?.SetAirplanes[indDrawningObject]; + } + } } }