From 70641cea7f9d010382d2a63fa8854195eb58d9cc 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: Fri, 30 Sep 2022 16:37:59 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BA=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=82=D0=BD?= =?UTF-8?q?=D0=BE=D0=B3=D0=BE=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/DrawningObject.cs | 2 +- .../AirBomber/FormMapWithSetAirplanes.Designer.cs | 2 +- AirBomber/AirBomber/FormMapWithSetAirplanes.cs | 11 +++++++---- AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs | 4 ++-- AirBomber/AirBomber/SetAirplanesGeneric.cs | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/AirBomber/AirBomber/DrawningObject.cs b/AirBomber/AirBomber/DrawningObject.cs index d79a291..dca9b4d 100644 --- a/AirBomber/AirBomber/DrawningObject.cs +++ b/AirBomber/AirBomber/DrawningObject.cs @@ -34,7 +34,7 @@ namespace AirBomber void IDrawningObject.DrawningObject(Graphics g) { - _airplane.DrawTransport(g); + _airplane?.DrawTransport(g); } } } diff --git a/AirBomber/AirBomber/FormMapWithSetAirplanes.Designer.cs b/AirBomber/AirBomber/FormMapWithSetAirplanes.Designer.cs index ed972c8..8d581aa 100644 --- a/AirBomber/AirBomber/FormMapWithSetAirplanes.Designer.cs +++ b/AirBomber/AirBomber/FormMapWithSetAirplanes.Designer.cs @@ -162,7 +162,7 @@ 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(17, 32); this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; this.comboBoxSelectorMap.Size = new System.Drawing.Size(175, 23); diff --git a/AirBomber/AirBomber/FormMapWithSetAirplanes.cs b/AirBomber/AirBomber/FormMapWithSetAirplanes.cs index 9676d84..def5d4e 100644 --- a/AirBomber/AirBomber/FormMapWithSetAirplanes.cs +++ b/AirBomber/AirBomber/FormMapWithSetAirplanes.cs @@ -26,6 +26,9 @@ case "Простая карта": map = new SimpleMap(); break; + case "Карта со стенами": + map = new WallMap(); + break; } if (map != null) { @@ -52,14 +55,14 @@ if (form.ShowDialog() == DialogResult.OK) { DrawningObject airplane = new(form.SelectedAirplane); - if (_mapAirplanesCollectionGeneric + airplane) + if (form.SelectedAirplane == null || !(_mapAirplanesCollectionGeneric + airplane)) { - MessageBox.Show("Объект добавлен"); - pictureBox.Image = _mapAirplanesCollectionGeneric.ShowSet(); + MessageBox.Show("Не удалось добавить объект"); } else { - MessageBox.Show("Не удалось добавить объект"); + MessageBox.Show("Объект добавлен"); + pictureBox.Image = _mapAirplanesCollectionGeneric.ShowSet(); } } } diff --git a/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs b/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs index e54e7a8..63bb08f 100644 --- a/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs +++ b/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs @@ -78,7 +78,7 @@ namespace AirBomber Bitmap bmp = new(_pictureWidth, _pictureHeight); Graphics gr = Graphics.FromImage(bmp); DrawBackground(gr); - Drawairplanes(gr); + DrawAirplanes(gr); return bmp; } /// @@ -158,7 +158,7 @@ namespace AirBomber /// Метод прорисовки объектов /// /// - private void Drawairplanes(Graphics g) + private void DrawAirplanes(Graphics g) { for (int i = 0; i < _setAirplanes.Count; i++) { diff --git a/AirBomber/AirBomber/SetAirplanesGeneric.cs b/AirBomber/AirBomber/SetAirplanesGeneric.cs index 0848595..178d798 100644 --- a/AirBomber/AirBomber/SetAirplanesGeneric.cs +++ b/AirBomber/AirBomber/SetAirplanesGeneric.cs @@ -41,7 +41,7 @@ namespace AirBomber private bool isCorrectPosition(int position) { - return 0 < position && position <= Count; + return 0 <= position && position < Count; } /// /// Добавление объекта в набор на конкретную позицию