From 19eeb2b95052758b86f013213d93bfd86e044972 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: Tue, 4 Oct 2022 03:00:30 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=8C=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D1=89?= =?UTF-8?q?=D0=B0=D1=82=D1=8C=20=D1=81=D0=B0=D0=BC=D0=BE=D0=BB=D0=B5=D1=82?= =?UTF-8?q?=20=D0=BF=D0=BE=20=D0=BA=D0=B0=D1=80=D1=82=D0=B5,=20=D0=B8=20?= =?UTF-8?q?=D0=BD=D0=B5=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D1=89=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=20=D0=B2=20=D1=85=D1=80=D0=B0=D0=BD=D0=B8=D0=BB?= =?UTF-8?q?=D0=B8=D1=89=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/AbstractMap.cs | 2 ++ AirBomber/AirBomber/FormMapWithSetAirplanes.Designer.cs | 7 ++++++- AirBomber/AirBomber/FormMapWithSetAirplanes.cs | 2 +- AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs | 9 ++++++--- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/AirBomber/AirBomber/AbstractMap.cs b/AirBomber/AirBomber/AbstractMap.cs index 8cc655f..62dbec5 100644 --- a/AirBomber/AirBomber/AbstractMap.cs +++ b/AirBomber/AirBomber/AbstractMap.cs @@ -34,6 +34,8 @@ namespace AirBomber return DrawMapWithObject(); } + public bool HasMap => _map != null; + /// Проверяет наличие непроходимых участков в заданной области /// Заданная область /// i-ый индекс первого барьера, который был найден в области diff --git a/AirBomber/AirBomber/FormMapWithSetAirplanes.Designer.cs b/AirBomber/AirBomber/FormMapWithSetAirplanes.Designer.cs index 8d581aa..7d612bd 100644 --- a/AirBomber/AirBomber/FormMapWithSetAirplanes.Designer.cs +++ b/AirBomber/AirBomber/FormMapWithSetAirplanes.Designer.cs @@ -103,6 +103,7 @@ this.buttonDown.Size = new System.Drawing.Size(30, 30); this.buttonDown.TabIndex = 10; this.buttonDown.UseVisualStyleBackColor = true; + this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click); // // buttonRight // @@ -114,6 +115,7 @@ this.buttonRight.Size = new System.Drawing.Size(30, 30); this.buttonRight.TabIndex = 9; this.buttonRight.UseVisualStyleBackColor = true; + this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); // // buttonLeft // @@ -125,6 +127,7 @@ this.buttonLeft.Size = new System.Drawing.Size(30, 30); this.buttonLeft.TabIndex = 8; this.buttonLeft.UseVisualStyleBackColor = true; + this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click); // // buttonUp // @@ -136,6 +139,7 @@ this.buttonUp.Size = new System.Drawing.Size(30, 30); this.buttonUp.TabIndex = 7; this.buttonUp.UseVisualStyleBackColor = true; + this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click); // // buttonShowOnMap // @@ -162,7 +166,8 @@ 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 def5d4e..1b88ac8 100644 --- a/AirBomber/AirBomber/FormMapWithSetAirplanes.cs +++ b/AirBomber/AirBomber/FormMapWithSetAirplanes.cs @@ -125,7 +125,7 @@ /// private void ButtonMove_Click(object sender, EventArgs e) { - if (_mapAirplanesCollectionGeneric == null) + if (_mapAirplanesCollectionGeneric == null || !_mapAirplanesCollectionGeneric.Map.HasMap) { return; } diff --git a/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs b/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs index 775f1f7..efe2f6c 100644 --- a/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs +++ b/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs @@ -34,6 +34,9 @@ namespace AirBomber /// Карта /// private readonly U _map; + + public U Map => _map; + /// /// Конструктор /// @@ -93,7 +96,7 @@ namespace AirBomber var airplane = _setAirplanes.Get(i); if (airplane != null) { - return _map.CreateMap(_pictureWidth, _pictureHeight, airplane); + return Map.CreateMap(_pictureWidth, _pictureHeight, airplane); } } return new(_pictureWidth, _pictureHeight); @@ -105,9 +108,9 @@ namespace AirBomber /// public Bitmap MoveObject(Direction direction) { - if (_map != null) + if (Map != null) { - return _map.MoveObject(direction); + return Map.MoveObject(direction); } return new(_pictureWidth, _pictureHeight); }