diff --git a/AirBomber/AirBomber/DrawningAirBomber.cs b/AirBomber/AirBomber/DrawningAirBomber.cs
new file mode 100644
index 0000000..2f5da52
--- /dev/null
+++ b/AirBomber/AirBomber/DrawningAirBomber.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AirBomber
+{
+ internal class DrawningAirBomber : DrawningAirplane
+ {
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес самолета
+ /// Цвет обшивки
+ /// Дополнительный цвет
+ /// Признак наличия бомб
+ /// Признак наличия топливных баков
+ public DrawningAirBomber(int speed, float weight, Color bodyColor, Color dopColor, bool hasBombs, bool hasFuelTanks)
+ : base(speed, weight, bodyColor, 115, 155)
+ {
+ Airplane = new EntityAirBomber(speed, weight, bodyColor, dopColor, hasBombs, hasFuelTanks);
+ }
+
+ public override void DrawTransport(Graphics g)
+ {
+ if (Airplane is not EntityAirBomber airBomber)
+ {
+ return;
+ }
+
+ var x = _startPosX;
+ var y = _startPosY;
+ var w = _airplaneWidth;
+ var h = _airplaneHeight;
+ Brush brush = new SolidBrush(airBomber.DopColor);
+
+ if (airBomber.HasBombs) // Бомбы снизу рисуются сначала
+ {
+ DrawBomb(g, airBomber.DopColor, new RectangleF(x + w / 2 - 15, y + h / 2 - 19, 23, 10));
+ DrawBomb(g, airBomber.DopColor, new RectangleF(x + w / 2 - 15, y + h / 2 + 9, 23, 10));
+ }
+
+ base.DrawTransport(g);
+
+ if (airBomber.HasFuelTanks)
+ {
+ g.FillEllipse(brush, new RectangleF(x + w / 4, y + h / 2 - 6, w / 2.5f, 12));
+ }
+ }
+
+ private void DrawBomb(Graphics g, Color colorBomb, RectangleF r)
+ {
+ Pen pen = new(colorBomb);
+ pen.Width = r.Height / 3;
+ var widthTail = r.Width / 6;
+ g.FillEllipse(new SolidBrush(colorBomb), r.X, r.Y, r.Width - widthTail, r.Height); // Основание бомбы
+ // Хвост бомбы
+ var baseTail = new PointF(r.Right - widthTail, r.Y + r.Height / 2);
+ g.DrawLine(pen, baseTail, new PointF(r.Right, r.Top));
+ g.DrawLine(pen, baseTail, new PointF(r.Right, r.Bottom));
+ }
+ }
+}
diff --git a/AirBomber/AirBomber/DrawningAirplane.cs b/AirBomber/AirBomber/DrawningAirplane.cs
index b86cee0..3a11e7c 100644
--- a/AirBomber/AirBomber/DrawningAirplane.cs
+++ b/AirBomber/AirBomber/DrawningAirplane.cs
@@ -8,31 +8,31 @@
///
/// Класс-сущность
///
- public EntityAirplane Airplane { get; private set; }
+ public EntityAirplane Airplane { get; protected set; }
///
/// Левая координата отрисовки автомобиля
///
- private float _startPosX;
+ protected float _startPosX;
///
/// Верхняя кооридната отрисовки автомобиля
///
- private float _startPosY;
+ protected float _startPosY;
///
/// Ширина окна отрисовки
///
- private int? _pictureWidth = null;
+ protected int? _pictureWidth = null;
///
/// Высота окна отрисовки
///
- private int? _pictureHeight = null;
+ protected int? _pictureHeight = null;
///
/// Ширина отрисовки автомобиля
///
- private readonly int _airplaneWidth = 110;
+ protected readonly int _airplaneWidth = 110;
///
/// Высота отрисовки автомобиля
///
- private readonly int _airplaneHeight = 140;
+ protected readonly int _airplaneHeight = 140;
///
/// Инициализация свойств
///
@@ -43,6 +43,21 @@
{
Airplane = new EntityAirplane(speed, weight, bodyColor);
}
+
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес самолета
+ /// Цвет обшивки
+ /// Ширина отрисовки самолета
+ /// Высота отрисовки самолета
+ protected DrawningAirplane(int speed, float weight, Color bodyColor, int airplaneWidth, int airplaneHeight) :
+ this(speed, weight, bodyColor)
+ {
+ _airplaneWidth = airplaneWidth;
+ _airplaneHeight = airplaneHeight;
+ }
///
/// Установка позиции самолета
///
@@ -111,7 +126,7 @@
/// Отрисовка самолета
///
///
- public void DrawTransport(Graphics g)
+ public virtual void DrawTransport(Graphics g)
{
if (_startPosX < 0 || _startPosY < 0
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
diff --git a/AirBomber/AirBomber/EntityAirBomber.cs b/AirBomber/AirBomber/EntityAirBomber.cs
new file mode 100644
index 0000000..8e5ace5
--- /dev/null
+++ b/AirBomber/AirBomber/EntityAirBomber.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AirBomber
+{
+ internal class EntityAirBomber : EntityAirplane
+ {
+ ///
+ /// Дополнительный цвет
+ ///
+ public Color DopColor { get; private set; }
+ ///
+ /// Признак наличия бомб
+ ///
+ public bool HasBombs { get; private set; }
+ ///
+ /// Признак наличия топливных баков
+ ///
+ public bool HasFuelTanks { get; private set; }
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес автомобиля
+ /// Цвет кузова
+ /// Дополнительный цвет
+ /// Признак наличия бомб
+ /// Признак наличия топливных баков
+ public EntityAirBomber(int speed, float weight, Color bodyColor, Color dopColor, bool hasBombs, bool hasFuelTanks) :
+ base(speed, weight, bodyColor)
+ {
+ DopColor = dopColor;
+ HasBombs = hasBombs;
+ HasFuelTanks = hasFuelTanks;
+ }
+ }
+}
diff --git a/AirBomber/AirBomber/FormAirBomber.cs b/AirBomber/AirBomber/FormAirBomber.cs
index 2ceac78..363aa00 100644
--- a/AirBomber/AirBomber/FormAirBomber.cs
+++ b/AirBomber/AirBomber/FormAirBomber.cs
@@ -26,8 +26,9 @@ namespace AirBomber
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
- _airplane = new DrawningAirplane();
- _airplane.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
+ _airplane = new DrawningAirBomber(rnd.Next(100, 300), rnd.Next(1000, 2000),
+ Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
+ Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), true, false);
_airplane.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxCar.Width, pictureBoxCar.Height);
toolStripStatusLabelSpeed.Text = $": {_airplane.Airplane.Speed}";
toolStripStatusLabelWeight.Text = $": {_airplane.Airplane.Weight}";