From aa926f45dd8d283da5cf454d62ba151bad77e605 Mon Sep 17 00:00:00 2001 From: VirBiuM Date: Mon, 11 Mar 2024 12:24:07 +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=B8=D0=B5=20=D1=80=D0=BE=D0=B4=D0=B8=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D0=B5=D0=B9=20=D0=B8=20=D0=B2=D0=B2=D0=BE=D0=B4=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BA=D1=82=D0=BE=D1=80=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{ => Drawnings}/DirectionType.cs | 2 +- .../Drawnings/DrawningAirFighter.cs | 65 ++++++++++ .../DrawningWarPlane.cs} | 114 ++++++++---------- .../{ => Entities}/EntityAirFighter.cs | 31 +---- .../Entities/EntityWarPlane.cs | 40 ++++++ .../FormAirFighter.Designer.cs | 19 ++- .../ProjectAirFighter/FormAirFighter.cs | 64 ++++++---- 7 files changed, 216 insertions(+), 119 deletions(-) rename ProjectAirFighter/ProjectAirFighter/{ => Drawnings}/DirectionType.cs (90%) create mode 100644 ProjectAirFighter/ProjectAirFighter/Drawnings/DrawningAirFighter.cs rename ProjectAirFighter/ProjectAirFighter/{DrawningAirFighter.cs => Drawnings/DrawningWarPlane.cs} (61%) rename ProjectAirFighter/ProjectAirFighter/{ => Entities}/EntityAirFighter.cs (63%) create mode 100644 ProjectAirFighter/ProjectAirFighter/Entities/EntityWarPlane.cs diff --git a/ProjectAirFighter/ProjectAirFighter/DirectionType.cs b/ProjectAirFighter/ProjectAirFighter/Drawnings/DirectionType.cs similarity index 90% rename from ProjectAirFighter/ProjectAirFighter/DirectionType.cs rename to ProjectAirFighter/ProjectAirFighter/Drawnings/DirectionType.cs index 66b140b..7db34d9 100644 --- a/ProjectAirFighter/ProjectAirFighter/DirectionType.cs +++ b/ProjectAirFighter/ProjectAirFighter/Drawnings/DirectionType.cs @@ -1,4 +1,4 @@ -namespace ProjectAirFighter; +namespace ProjectAirFighter.Drawnings; /// /// Направление перемещения diff --git a/ProjectAirFighter/ProjectAirFighter/Drawnings/DrawningAirFighter.cs b/ProjectAirFighter/ProjectAirFighter/Drawnings/DrawningAirFighter.cs new file mode 100644 index 0000000..6c772c8 --- /dev/null +++ b/ProjectAirFighter/ProjectAirFighter/Drawnings/DrawningAirFighter.cs @@ -0,0 +1,65 @@ +using ProjectAirFighter.Entities; + +namespace ProjectAirFighter.Drawnings; + +/// +/// Класс, отвечающий за прорисовку и перемещение объекта-сущности +/// +public class DrawningAirFighter : DrawningWarPlane +{ + /// + /// Конструктор + /// + /// Скорость + /// Вес истребителя + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия двигателей + /// Признак наличия дополнительных крыльев + /// Признак наличия ракет + public DrawningAirFighter(int speed, double weight, Color bodyColor, Color additionalColor, bool engines, bool extraWings, bool rockets) : base(150, 150) + { + EntityWarPlane = new EntityAirFighter(speed, weight, bodyColor, additionalColor, engines, extraWings, rockets); + } + + public override void DrawTransport(Graphics g) + { + if (EntityWarPlane == null || EntityWarPlane is not EntityAirFighter airFighter || !_startPosX.HasValue || !_startPosY.HasValue) + { + return; + } + base.DrawTransport(g); + + Pen additionalPen = new(airFighter.AdditionalColor); + Brush additionalBrush = new SolidBrush(airFighter.AdditionalColor); + + // отрисовка двигателей + if (airFighter.Engines) + { + g.FillEllipse(additionalBrush, _startPosX.Value + 35, _startPosY.Value + 30, 10, 10); + g.FillEllipse(additionalBrush, _startPosX.Value + 35, _startPosY.Value + 120, 10, 10); + } + + // отрисовка дополнительных крыльев + if (airFighter.ExtraWings) + { + g.DrawLine(additionalPen, _startPosX.Value + 65, _startPosY.Value + 70, _startPosX.Value + 90, _startPosY.Value + 20); + g.DrawLine(additionalPen, _startPosX.Value + 90, _startPosY.Value + 20, _startPosX.Value + 110, _startPosY.Value + 20); + g.DrawLine(additionalPen, _startPosX.Value + 110, _startPosY.Value + 20, _startPosX.Value + 85, _startPosY.Value + 70); + g.DrawLine(additionalPen, _startPosX.Value + 65, _startPosY.Value + 80, _startPosX.Value + 90, _startPosY.Value + 130); + g.DrawLine(additionalPen, _startPosX.Value + 90, _startPosY.Value + 130, _startPosX.Value + 110, _startPosY.Value + 130); + g.DrawLine(additionalPen, _startPosX.Value + 110, _startPosY.Value + 130, _startPosX.Value + 85, _startPosY.Value + 80); + } + + // отрисовка ракет + if (airFighter.Rockets) + { + g.FillRectangle(additionalBrush, _startPosX.Value + 32, _startPosY.Value + 4, 8, 6); + g.DrawLine(additionalPen, _startPosX.Value + 32, _startPosY.Value + 4, _startPosX.Value + 26, _startPosY.Value + 7); + g.DrawLine(additionalPen, _startPosX.Value + 26, _startPosY.Value + 7, _startPosX.Value + 32, _startPosY.Value + 10); + g.FillRectangle(additionalBrush, _startPosX.Value + 32, _startPosY.Value + 140, 8, 6); + g.DrawLine(additionalPen, _startPosX.Value + 32, _startPosY.Value + 146, _startPosX.Value + 26, _startPosY.Value + 143); + g.DrawLine(additionalPen, _startPosX.Value + 26, _startPosY.Value + 143, _startPosX.Value + 32, _startPosY.Value + 140); + } + } +} \ No newline at end of file diff --git a/ProjectAirFighter/ProjectAirFighter/DrawningAirFighter.cs b/ProjectAirFighter/ProjectAirFighter/Drawnings/DrawningWarPlane.cs similarity index 61% rename from ProjectAirFighter/ProjectAirFighter/DrawningAirFighter.cs rename to ProjectAirFighter/ProjectAirFighter/Drawnings/DrawningWarPlane.cs index da348b8..c782dd7 100644 --- a/ProjectAirFighter/ProjectAirFighter/DrawningAirFighter.cs +++ b/ProjectAirFighter/ProjectAirFighter/Drawnings/DrawningWarPlane.cs @@ -1,14 +1,13 @@ -namespace ProjectAirFighter; +using ProjectAirFighter.Entities; -/// -/// Класс, отвечающий за прорисовку и перемещение объекта-сущности -/// -public class DrawningAirFighter +namespace ProjectAirFighter.Drawnings; + +public class DrawningWarPlane { /// /// Класс-сущность /// - public EntityAirFighter? EntityAirFighter { get; private set; } + public EntityWarPlane? EntityWarPlane { get; protected set; } /// /// Ширина окна @@ -23,12 +22,12 @@ public class DrawningAirFighter /// /// Левая координата прорисовки истребителя /// - private int? _startPosX; + protected int? _startPosX; /// /// Верхняя кооридната прорисовки истребителя /// - private int? _startPosY; + protected int? _startPosY; /// /// Ширина прорисовки истребителя @@ -41,25 +40,38 @@ public class DrawningAirFighter private readonly int _drawningPlaneHeight = 150; /// - /// Инициализация полей объекта-класса истребителя - /// - /// Скорость - /// Вес истребителя - /// Основной цвет - /// Дополнительный цвет - /// Признак наличия двигателей - /// Признак наличия дополнительных крыльев - /// Признак наличия ракет - public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool engines, bool extraWings, bool rockets) + /// Пустой конструктор + /// + private DrawningWarPlane() { - EntityAirFighter = new EntityAirFighter(); - EntityAirFighter.Init(speed, weight, bodyColor, additionalColor, engines, extraWings, rockets); _pictureWidth = null; _pictureHeight = null; _startPosX = null; _startPosY = null; } + /// + /// Конструктор + /// + /// Скорость + /// Вес истребителя + /// Основной цвет + public DrawningWarPlane(int speed, double weight, Color bodyColor) : this() + { + EntityWarPlane = new EntityWarPlane(speed, weight, bodyColor); + } + + /// + /// Конструктор для наследников + /// + /// Ширина прорисовки истребителя + /// Высота прорисовки истребителя + protected DrawningWarPlane(int drawningPlaneWidth, int drawningPlaneHeight) : this() + { + _drawningPlaneWidth = drawningPlaneWidth; + _drawningPlaneHeight = drawningPlaneHeight; + } + /// /// Установка границ поля /// @@ -79,7 +91,7 @@ public class DrawningAirFighter if (_startPosY.Value + _drawningPlaneHeight > height) { _startPosY = height - _drawningPlaneHeight; } } _pictureWidth = width; - _pictureHeight = height; + _pictureHeight = height; return true; } @@ -125,7 +137,7 @@ public class DrawningAirFighter /// true - перемещене выполнено, false - перемещение невозможно public bool MoveTransport(DirectionType direction) { - if (EntityAirFighter == null || !_startPosX.HasValue || !_startPosY.HasValue) + if (EntityWarPlane == null || !_startPosX.HasValue || !_startPosY.HasValue) { return false; } @@ -134,30 +146,30 @@ public class DrawningAirFighter { //влево case DirectionType.Left: - if (_startPosX.Value - EntityAirFighter.Step > 0) + if (_startPosX.Value - EntityWarPlane.Step > 0) { - _startPosX -= (int)EntityAirFighter.Step; + _startPosX -= (int)EntityWarPlane.Step; } return true; //вверх case DirectionType.Up: - if (_startPosY.Value - EntityAirFighter.Step > 0) + if (_startPosY.Value - EntityWarPlane.Step > 0) { - _startPosY -= (int)EntityAirFighter.Step; + _startPosY -= (int)EntityWarPlane.Step; } return true; // вправо case DirectionType.Right: - if (_startPosX.Value + EntityAirFighter.Step + _drawningPlaneWidth < _pictureWidth) + if (_startPosX.Value + EntityWarPlane.Step + _drawningPlaneWidth < _pictureWidth) { - _startPosX += (int)EntityAirFighter.Step; + _startPosX += (int)EntityWarPlane.Step; } return true; //вниз case DirectionType.Down: - if (_startPosY.Value + EntityAirFighter.Step + _drawningPlaneHeight < _pictureHeight) + if (_startPosY.Value + EntityWarPlane.Step + _drawningPlaneHeight < _pictureHeight) { - _startPosY += (int)EntityAirFighter.Step; + _startPosY += (int)EntityWarPlane.Step; } return true; default: @@ -169,9 +181,9 @@ public class DrawningAirFighter /// Прорисовка объекта /// /// - public void DrawTransport(Graphics g) + public virtual void DrawTransport(Graphics g) { - if (EntityAirFighter == null || !_startPosX.HasValue || !_startPosY.HasValue) + if (EntityWarPlane == null || !_startPosX.HasValue || !_startPosY.HasValue) { return; } @@ -182,11 +194,11 @@ public class DrawningAirFighter Point point1 = new Point(_startPosX.Value, _startPosY.Value + 75); Point point2 = new Point(_startPosX.Value + 20, _startPosY.Value + 70); Point point3 = new Point(_startPosX.Value + 20, _startPosY.Value + 80); - Point[] triangle = {point1, point2, point3}; + Point[] triangle = { point1, point2, point3 }; g.FillPolygon(brBlack, triangle); - Pen br = new(EntityAirFighter.BodyColor); - Brush hd = new SolidBrush(EntityAirFighter.BodyColor); + Pen br = new(EntityWarPlane.BodyColor); + Brush hd = new SolidBrush(EntityWarPlane.BodyColor); // отрисовка корпуса истребителя g.FillRectangle(hd, _startPosX.Value + 20, _startPosY.Value + 70, 130, 10); @@ -205,37 +217,5 @@ public class DrawningAirFighter g.DrawLine(br, _startPosX.Value + 150, _startPosY.Value + 80, _startPosX.Value + 150, _startPosY.Value + 95); g.DrawLine(br, _startPosX.Value + 150, _startPosY.Value + 95, _startPosX.Value + 135, _startPosY.Value + 85); g.DrawLine(br, _startPosX.Value + 135, _startPosY.Value + 85, _startPosX.Value + 135, _startPosY.Value + 80); - - Pen additionalPen = new(EntityAirFighter.AdditionalColor); - Brush additionalBrush = new SolidBrush(EntityAirFighter.AdditionalColor); - - // отрисовка двигателей - if (EntityAirFighter.Engines) - { - g.FillEllipse(additionalBrush, _startPosX.Value + 35, _startPosY.Value + 30, 10, 10); - g.FillEllipse(additionalBrush, _startPosX.Value + 35, _startPosY.Value + 120, 10, 10); - } - - // отрисовка дополнительных крыльев - if (EntityAirFighter.ExtraWings) - { - g.DrawLine(additionalPen, _startPosX.Value + 65, _startPosY.Value + 70, _startPosX.Value + 90, _startPosY.Value + 20); - g.DrawLine(additionalPen, _startPosX.Value + 90, _startPosY.Value + 20, _startPosX.Value + 110, _startPosY.Value + 20); - g.DrawLine(additionalPen, _startPosX.Value + 110, _startPosY.Value + 20, _startPosX.Value + 85, _startPosY.Value + 70); - g.DrawLine(additionalPen, _startPosX.Value + 65, _startPosY.Value + 80, _startPosX.Value + 90, _startPosY.Value + 130); - g.DrawLine(additionalPen, _startPosX.Value + 90, _startPosY.Value + 130, _startPosX.Value + 110, _startPosY.Value + 130); - g.DrawLine(additionalPen, _startPosX.Value + 110, _startPosY.Value + 130, _startPosX.Value + 85, _startPosY.Value + 80); - } - - // отрисовка ракет - if (EntityAirFighter.Rockets) - { - g.FillRectangle(additionalBrush, _startPosX.Value + 32, _startPosY.Value + 4, 8, 6); - g.DrawLine(additionalPen, _startPosX.Value + 32, _startPosY.Value + 4, _startPosX.Value + 26, _startPosY.Value + 7); - g.DrawLine(additionalPen, _startPosX.Value + 26, _startPosY.Value + 7, _startPosX.Value + 32, _startPosY.Value + 10); - g.FillRectangle(additionalBrush, _startPosX.Value + 32, _startPosY.Value + 140, 8, 6); - g.DrawLine(additionalPen, _startPosX.Value + 32, _startPosY.Value + 146, _startPosX.Value + 26, _startPosY.Value + 143); - g.DrawLine(additionalPen, _startPosX.Value + 26, _startPosY.Value + 143, _startPosX.Value + 32, _startPosY.Value + 140); - } } } \ No newline at end of file diff --git a/ProjectAirFighter/ProjectAirFighter/EntityAirFighter.cs b/ProjectAirFighter/ProjectAirFighter/Entities/EntityAirFighter.cs similarity index 63% rename from ProjectAirFighter/ProjectAirFighter/EntityAirFighter.cs rename to ProjectAirFighter/ProjectAirFighter/Entities/EntityAirFighter.cs index d35ab17..8ce2ea3 100644 --- a/ProjectAirFighter/ProjectAirFighter/EntityAirFighter.cs +++ b/ProjectAirFighter/ProjectAirFighter/Entities/EntityAirFighter.cs @@ -1,25 +1,10 @@ -namespace ProjectAirFighter; +namespace ProjectAirFighter.Entities; /// /// Класс-сущность "Истребитель" /// -public class EntityAirFighter +public class EntityAirFighter : EntityWarPlane { - /// - /// Скорость - /// - public int Speed { get; private set; } - - /// - /// Вес - /// - public double Weight { get; private set; } - - /// - /// Основной цвет - /// - public Color BodyColor { get; private set; } - /// /// Дополнительный цвет (для опциональных элементов) /// @@ -41,12 +26,7 @@ public class EntityAirFighter public bool Rockets { get; private set; } /// - /// Шаг перемещения истребителя - /// - public double Step => Speed * 100 / Weight; - - /// - /// Инициализация полей объекта-класса истребителя + /// Конструктор /// /// Скорость /// Вес истребителя @@ -55,11 +35,8 @@ public class EntityAirFighter /// Признак наличия двигателей /// Признак наличия дополнительных крыльев /// Признак наличия ракет - public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool engines, bool extraWings, bool rockets) + public EntityAirFighter(int speed, double weight, Color bodyColor, Color additionalColor, bool engines, bool extraWings, bool rockets) : base(speed, weight, bodyColor) { - Speed = speed; - Weight = weight; - BodyColor = bodyColor; AdditionalColor = additionalColor; Engines = engines; ExtraWings = extraWings; diff --git a/ProjectAirFighter/ProjectAirFighter/Entities/EntityWarPlane.cs b/ProjectAirFighter/ProjectAirFighter/Entities/EntityWarPlane.cs new file mode 100644 index 0000000..506b6b4 --- /dev/null +++ b/ProjectAirFighter/ProjectAirFighter/Entities/EntityWarPlane.cs @@ -0,0 +1,40 @@ +namespace ProjectAirFighter.Entities; + +/// +/// Класс-сущность "Военный самолет" +/// +public class EntityWarPlane +{ + /// + /// Скорость + /// + public int Speed { get; private set; } + + /// + /// Вес + /// + public double Weight { get; private set; } + + /// + /// Основной цвет + /// + public Color BodyColor { get; private set; } + + /// + /// Шаг перемещения самолета + /// + public double Step => Speed * 100 / Weight; + + /// + /// Конструктор сущности + /// + /// Скорость + /// Вес самолета + /// Основной цвет + public EntityWarPlane(int speed, double weight, Color bodyColor) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + } +} \ No newline at end of file diff --git a/ProjectAirFighter/ProjectAirFighter/FormAirFighter.Designer.cs b/ProjectAirFighter/ProjectAirFighter/FormAirFighter.Designer.cs index df34b02..c19d18d 100644 --- a/ProjectAirFighter/ProjectAirFighter/FormAirFighter.Designer.cs +++ b/ProjectAirFighter/ProjectAirFighter/FormAirFighter.Designer.cs @@ -34,6 +34,7 @@ buttonUp = new Button(); buttonRight = new Button(); buttonDown = new Button(); + buttonCreateWarPlane = new Button(); ((System.ComponentModel.ISupportInitialize)pictureBoxAirFighter).BeginInit(); SuspendLayout(); // @@ -53,9 +54,9 @@ buttonCreateAirFighter.Location = new Point(14, 626); buttonCreateAirFighter.Margin = new Padding(3, 4, 3, 4); buttonCreateAirFighter.Name = "buttonCreateAirFighter"; - buttonCreateAirFighter.Size = new Size(86, 31); + buttonCreateAirFighter.Size = new Size(228, 31); buttonCreateAirFighter.TabIndex = 1; - buttonCreateAirFighter.Text = "Создать"; + buttonCreateAirFighter.Text = "Создать истребитель"; buttonCreateAirFighter.UseVisualStyleBackColor = true; buttonCreateAirFighter.Click += ButtonCreateAirFighter_Click; // @@ -111,11 +112,24 @@ buttonDown.UseVisualStyleBackColor = true; buttonDown.Click += ButtonMove_Click; // + // buttonCreateWarPlane + // + buttonCreateWarPlane.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCreateWarPlane.Location = new Point(248, 626); + buttonCreateWarPlane.Margin = new Padding(3, 4, 3, 4); + buttonCreateWarPlane.Name = "buttonCreateWarPlane"; + buttonCreateWarPlane.Size = new Size(228, 31); + buttonCreateWarPlane.TabIndex = 6; + buttonCreateWarPlane.Text = "Создать военный самолет"; + buttonCreateWarPlane.UseVisualStyleBackColor = true; + buttonCreateWarPlane.Click += ButtonCreateWarPlane_Click; + // // FormAirFighter // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(882, 673); + Controls.Add(buttonCreateWarPlane); Controls.Add(buttonDown); Controls.Add(buttonRight); Controls.Add(buttonUp); @@ -137,5 +151,6 @@ private Button buttonUp; private Button buttonRight; private Button buttonDown; + private Button buttonCreateWarPlane; } } \ No newline at end of file diff --git a/ProjectAirFighter/ProjectAirFighter/FormAirFighter.cs b/ProjectAirFighter/ProjectAirFighter/FormAirFighter.cs index e291708..0a2e039 100644 --- a/ProjectAirFighter/ProjectAirFighter/FormAirFighter.cs +++ b/ProjectAirFighter/ProjectAirFighter/FormAirFighter.cs @@ -1,4 +1,6 @@ -namespace ProjectAirFighter; +using ProjectAirFighter.Drawnings; + +namespace ProjectAirFighter; /// /// Форма работы с объектом "истребитель" @@ -8,7 +10,7 @@ public partial class FormAirFighter : Form /// /// Поле-объект для прорисовки объекта /// - private DrawningAirFighter? _drawningAirFighter; + private DrawningWarPlane? _drawningWarPlane; /// /// Конструктор формы @@ -23,35 +25,53 @@ public partial class FormAirFighter : Form /// private void Draw() { - if (_drawningAirFighter == null) + if (_drawningWarPlane == null) { return; } Bitmap bmp = new(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height); Graphics gr = Graphics.FromImage(bmp); - _drawningAirFighter.DrawTransport(gr); + _drawningWarPlane.DrawTransport(gr); pictureBoxAirFighter.Image = bmp; } + private void CreateObject(string type) + { + Random random = new(); + switch (type) + { + case nameof(DrawningWarPlane): + _drawningWarPlane = new DrawningWarPlane(random.Next(100, 300), random.Next(1000, 3000), + Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256))); + break; + case nameof(DrawningAirFighter): + _drawningWarPlane = new DrawningAirFighter(random.Next(100, 300), random.Next(1000, 3000), + Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), + Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), + Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); + break; + default: + return; + } + _drawningWarPlane.SetPictureSize(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height); + _drawningWarPlane.SetPosition(random.Next(10, 100), random.Next(10, 100)); + Draw(); + } + /// - /// Обработка нажатия кнопки "Создать" + /// Обработка нажатия кнопки "Создать истребитель" /// /// /// - private void ButtonCreateAirFighter_Click(object sender, EventArgs e) - { - Random random = new(); - _drawningAirFighter = new DrawningAirFighter(); - _drawningAirFighter.Init(random.Next(300, 600), random.Next(1000, 3000), - Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), - Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), - Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); - _drawningAirFighter.SetPictureSize(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height); - _drawningAirFighter.SetPosition(random.Next(10, 100), random.Next(10, 100)); + private void ButtonCreateAirFighter_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAirFighter)); - Draw(); - } + /// + /// Обработка нажатия кнопки "Создать военный самолет" + /// + /// + /// + private void ButtonCreateWarPlane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningWarPlane)); /// /// Перемещение объекта по форме (нажатие кнопок навигации) @@ -60,7 +80,7 @@ public partial class FormAirFighter : Form /// private void ButtonMove_Click(object sender, EventArgs e) { - if (_drawningAirFighter == null) + if (_drawningWarPlane == null) { return; } @@ -70,16 +90,16 @@ public partial class FormAirFighter : Form switch (name) { case "buttonUp": - result = _drawningAirFighter.MoveTransport(DirectionType.Up); + result = _drawningWarPlane.MoveTransport(DirectionType.Up); break; case "buttonDown": - result = _drawningAirFighter.MoveTransport(DirectionType.Down); + result = _drawningWarPlane.MoveTransport(DirectionType.Down); break; case "buttonLeft": - result = _drawningAirFighter.MoveTransport(DirectionType.Left); + result = _drawningWarPlane.MoveTransport(DirectionType.Left); break; case "buttonRight": - result = _drawningAirFighter.MoveTransport(DirectionType.Right); + result = _drawningWarPlane.MoveTransport(DirectionType.Right); break; }