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); }