From 5c1444b66c6b141004e47164cae2773198fe7b10 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: Wed, 14 Sep 2022 15:15:12 +0400 Subject: [PATCH 01/15] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D1=84=D0=B5=D0=B9?= =?UTF-8?q?=D1=81=D0=B0,=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D1=8F?= =?UTF-8?q?=D1=8E=D1=89=D0=B5=D0=B3=D0=BE=20=D0=BE=D1=82=D1=80=D0=B8=D1=81?= =?UTF-8?q?=D0=BE=D0=B2=D0=BA=D1=83=20=D0=BD=D0=B0=20=D1=84=D0=BE=D0=BD?= =?UTF-8?q?=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/IDrawningObject.cs | 43 ++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 AirBomber/AirBomber/IDrawningObject.cs diff --git a/AirBomber/AirBomber/IDrawningObject.cs b/AirBomber/AirBomber/IDrawningObject.cs new file mode 100644 index 0000000..2b2330c --- /dev/null +++ b/AirBomber/AirBomber/IDrawningObject.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AirBomber +{ + /// + /// Интерфейс для работы с объектом, прорисовываемым на форме + /// + internal interface IDrawningObject + { + /// + /// Шаг перемещения объекта + /// + public float Step { get; } + /// + /// Установка позиции объекта + /// + /// Координата X + /// Координата Y + /// Ширина полотна + /// Высота полотна + void SetObject(int x, int y, int width, int height); + /// + /// Изменение направления пермещения объекта + /// + /// Направление + /// + void MoveObject(Direction direction); + /// + /// Отрисовка объекта + /// + /// + void DrawningObject(Graphics g); + /// + /// Получение текущей позиции объекта + /// + /// + (float Left, float Right, float Top, float Bottom) GetCurrentPosition(); + } +} -- 2.25.1 From f5cb1bfbe2dd08fb483e6dba60d2977ab19ca594 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: Wed, 14 Sep 2022 15:17:29 +0400 Subject: [PATCH 02/15] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=BD=D1=81=D1=82=D1=80?= =?UTF-8?q?=D1=83=D0=BA=D1=82=D1=83=D1=80=D0=BE=D0=B2=20=D0=B2=D0=BC=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D0=BE=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=BE=D0=B2?= =?UTF-8?q?=20Init?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/DrawningAirplane.cs | 5 ++--- AirBomber/AirBomber/EntityAirplane.cs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/AirBomber/AirBomber/DrawningAirplane.cs b/AirBomber/AirBomber/DrawningAirplane.cs index 9d73ff9..b86cee0 100644 --- a/AirBomber/AirBomber/DrawningAirplane.cs +++ b/AirBomber/AirBomber/DrawningAirplane.cs @@ -39,10 +39,9 @@ /// Скорость /// Вес самолета /// Цвет обшивки - public void Init(int speed, float weight, Color bodyColor) + public DrawningAirplane(int speed, float weight, Color bodyColor) { - Airplane = new EntityAirplane(); - Airplane.Init(speed, weight, bodyColor); + Airplane = new EntityAirplane(speed, weight, bodyColor); } /// /// Установка позиции самолета diff --git a/AirBomber/AirBomber/EntityAirplane.cs b/AirBomber/AirBomber/EntityAirplane.cs index bd6810f..2869683 100644 --- a/AirBomber/AirBomber/EntityAirplane.cs +++ b/AirBomber/AirBomber/EntityAirplane.cs @@ -28,7 +28,7 @@ /// /// /// - public void Init(int speed, float weight, Color bodyColor) + public EntityAirplane(int speed, float weight, Color bodyColor) { Random rnd = new(); Speed = speed <= 0 ? rnd.Next(50, 150) : speed; -- 2.25.1 From 7f2ffe217c39c0c903ef6a8493e5bc620d2091b2 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: Wed, 14 Sep 2022 19:07:38 +0400 Subject: [PATCH 03/15] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B1=D0=BE=D0=BC=D0=B1=D0=B0=D1=80?= =?UTF-8?q?=D0=B4=D0=B8=D1=80=D0=BE=D0=B2=D1=89=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/DrawningAirBomber.cs | 67 ++++++++++++++++++++++++ AirBomber/AirBomber/DrawningAirplane.cs | 31 ++++++++--- AirBomber/AirBomber/EntityAirBomber.cs | 40 ++++++++++++++ AirBomber/AirBomber/FormAirBomber.cs | 5 +- 4 files changed, 133 insertions(+), 10 deletions(-) create mode 100644 AirBomber/AirBomber/DrawningAirBomber.cs create mode 100644 AirBomber/AirBomber/EntityAirBomber.cs 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}"; -- 2.25.1 From 7b58ed1f0184b2365afc0c485b7211a0dbf592d6 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: Wed, 14 Sep 2022 19:50:08 +0400 Subject: [PATCH 04/15] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BA=D0=B0=D1=80=D1=82=D0=B0=20=D0=B8=20?= =?UTF-8?q?=D1=84=D0=BE=D1=80=D0=BC=D0=B0=20=D0=B4=D0=BB=D1=8F=20=D0=BD?= =?UTF-8?q?=D0=B5=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/AbstractMap.cs | 84 +++++++ AirBomber/AirBomber/Direction.cs | 1 + AirBomber/AirBomber/DrawningAirplane.cs | 9 + AirBomber/AirBomber/DrawningObject.cs | 40 ++++ AirBomber/AirBomber/FormAirBomber.Designer.cs | 14 ++ AirBomber/AirBomber/FormAirBomber.cs | 35 ++- AirBomber/AirBomber/FormMap.Designer.cs | 206 ++++++++++++++++++ AirBomber/AirBomber/FormMap.cs | 93 ++++++++ AirBomber/AirBomber/FormMap.resx | 120 ++++++++++ AirBomber/AirBomber/Program.cs | 2 +- AirBomber/AirBomber/SimpleMap.cs | 50 +++++ 11 files changed, 646 insertions(+), 8 deletions(-) create mode 100644 AirBomber/AirBomber/AbstractMap.cs create mode 100644 AirBomber/AirBomber/DrawningObject.cs create mode 100644 AirBomber/AirBomber/FormMap.Designer.cs create mode 100644 AirBomber/AirBomber/FormMap.cs create mode 100644 AirBomber/AirBomber/FormMap.resx create mode 100644 AirBomber/AirBomber/SimpleMap.cs diff --git a/AirBomber/AirBomber/AbstractMap.cs b/AirBomber/AirBomber/AbstractMap.cs new file mode 100644 index 0000000..450c122 --- /dev/null +++ b/AirBomber/AirBomber/AbstractMap.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AirBomber +{ + internal abstract class AbstractMap + { + private IDrawningObject _drawningObject = null; + protected int[,] _map = null; + protected int _width; + protected int _height; + protected float _size_x; + protected float _size_y; + protected readonly Random _random = new(); + protected readonly int _freeRoad = 0; + protected readonly int _barrier = 1; + + public Bitmap CreateMap(int width, int height, IDrawningObject drawningObject) + { + _width = width; + _height = height; + _drawningObject = drawningObject; + GenerateMap(); + while (!SetObjectOnMap()) + { + GenerateMap(); + } + return DrawMapWithObject(); + } + public Bitmap MoveObject(Direction direction) + { + // TODO проверка, что объект может переместится в требуемом направлении + if (true) + { + _drawningObject.MoveObject(direction); + } + return DrawMapWithObject(); + } + private bool SetObjectOnMap() + { + if (_drawningObject == null || _map == null) + { + return false; + } + int x = _random.Next(0, 10); + int y = _random.Next(0, 10); + _drawningObject.SetObject(x, y, _width, _height); + // TODO првоерка, что объект не "накладывается" на закрытые участки + return true; + } + private Bitmap DrawMapWithObject() + { + Bitmap bmp = new(_width, _height); + if (_drawningObject == null || _map == null) + { + return bmp; + } + Graphics gr = Graphics.FromImage(bmp); + for (int i = 0; i < _map.GetLength(0); ++i) + { + for (int j = 0; j < _map.GetLength(1); ++j) + { + if (_map[i, j] == _freeRoad) + { + DrawRoadPart(gr, i, j); + } + else if (_map[i, j] == _barrier) + { + DrawBarrierPart(gr, i, j); + } + } + } + _drawningObject.DrawningObject(gr); + return bmp; + } + + protected abstract void GenerateMap(); + protected abstract void DrawRoadPart(Graphics g, int i, int j); + protected abstract void DrawBarrierPart(Graphics g, int i, int j); + } +} \ No newline at end of file diff --git a/AirBomber/AirBomber/Direction.cs b/AirBomber/AirBomber/Direction.cs index 950a2d3..808d3d0 100644 --- a/AirBomber/AirBomber/Direction.cs +++ b/AirBomber/AirBomber/Direction.cs @@ -5,6 +5,7 @@ /// internal enum Direction { + None = 0, Up = 1, Down = 2, Left = 3, diff --git a/AirBomber/AirBomber/DrawningAirplane.cs b/AirBomber/AirBomber/DrawningAirplane.cs index 3a11e7c..2c2e221 100644 --- a/AirBomber/AirBomber/DrawningAirplane.cs +++ b/AirBomber/AirBomber/DrawningAirplane.cs @@ -206,5 +206,14 @@ _startPosY = _pictureHeight.Value - _airplaneHeight; } } + + /// + /// Получение текущей позиции объекта + /// + /// + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return (_startPosX, _startPosY, _startPosX + _airplaneWidth, _startPosY + _airplaneHeight); + } } } \ No newline at end of file diff --git a/AirBomber/AirBomber/DrawningObject.cs b/AirBomber/AirBomber/DrawningObject.cs new file mode 100644 index 0000000..af617fb --- /dev/null +++ b/AirBomber/AirBomber/DrawningObject.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 DrawningObject : IDrawningObject + { + private DrawningAirplane _airplane = null; + + public DrawningObject(DrawningAirplane airplane) + { + _airplane = airplane; + } + + public float Step => _airplane?.Airplane?.Step ?? 0; + + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return _airplane.GetCurrentPosition(); + } + + public void MoveObject(Direction direction) + { + _airplane?.MoveTransport(direction); + } + + public void SetObject(int x, int y, int width, int height) + { + _airplane.SetPosition(x, y, width, height); + } + + void IDrawningObject.DrawningObject(Graphics g) + { + _airplane.DrawTransport(g); + } + } +} diff --git a/AirBomber/AirBomber/FormAirBomber.Designer.cs b/AirBomber/AirBomber/FormAirBomber.Designer.cs index 910628c..294d009 100644 --- a/AirBomber/AirBomber/FormAirBomber.Designer.cs +++ b/AirBomber/AirBomber/FormAirBomber.Designer.cs @@ -38,6 +38,7 @@ this.buttonLeft = new System.Windows.Forms.Button(); this.buttonRight = new System.Windows.Forms.Button(); this.buttonDown = new System.Windows.Forms.Button(); + this.buttonCreateModif = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).BeginInit(); this.statusStrip.SuspendLayout(); this.SuspendLayout(); @@ -141,11 +142,23 @@ this.buttonDown.UseVisualStyleBackColor = true; this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click); // + // buttonCreateModif + // + this.buttonCreateModif.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonCreateModif.Location = new System.Drawing.Point(93, 390); + this.buttonCreateModif.Name = "buttonCreateModif"; + this.buttonCreateModif.Size = new System.Drawing.Size(108, 23); + this.buttonCreateModif.TabIndex = 8; + this.buttonCreateModif.Text = "Модификация"; + this.buttonCreateModif.UseVisualStyleBackColor = true; + this.buttonCreateModif.Click += new System.EventHandler(this.buttonCreateModif_Click); + // // FormAirBomber // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.buttonCreateModif); this.Controls.Add(this.buttonDown); this.Controls.Add(this.buttonRight); this.Controls.Add(this.buttonLeft); @@ -175,5 +188,6 @@ private Button buttonLeft; private Button buttonRight; private Button buttonDown; + private Button buttonCreateModif; } } \ No newline at end of file diff --git a/AirBomber/AirBomber/FormAirBomber.cs b/AirBomber/AirBomber/FormAirBomber.cs index 363aa00..4ef6eb4 100644 --- a/AirBomber/AirBomber/FormAirBomber.cs +++ b/AirBomber/AirBomber/FormAirBomber.cs @@ -19,6 +19,17 @@ namespace AirBomber pictureBoxCar.Image = bmp; } /// + /// + /// + private void SetData() + { + Random rnd = new(); + _airplane.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxCar.Width, pictureBoxCar.Height); + toolStripStatusLabelSpeed.Text = $": {_airplane.Airplane.Speed}"; + toolStripStatusLabelWeight.Text = $": {_airplane.Airplane.Weight}"; + toolStripStatusLabelBodyColor.Text = $": {_airplane.Airplane.BodyColor.Name}"; + } + /// /// "" /// /// @@ -26,13 +37,8 @@ namespace AirBomber private void ButtonCreate_Click(object sender, EventArgs e) { Random rnd = new(); - _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}"; - toolStripStatusLabelBodyColor.Text = $": {_airplane.Airplane.BodyColor.Name}"; + _airplane = new DrawningAirplane(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + SetData(); Draw(); } /// @@ -71,5 +77,20 @@ namespace AirBomber _airplane?.ChangeBorders(pictureBoxCar.Width, pictureBoxCar.Height); Draw(); } + /// + /// "" + /// + /// + /// + private void buttonCreateModif_Click(object sender, EventArgs e) + { + Random rnd = new(); + _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)), + Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2))); + SetData(); + Draw(); + } } } \ No newline at end of file diff --git a/AirBomber/AirBomber/FormMap.Designer.cs b/AirBomber/AirBomber/FormMap.Designer.cs new file mode 100644 index 0000000..c7b8330 --- /dev/null +++ b/AirBomber/AirBomber/FormMap.Designer.cs @@ -0,0 +1,206 @@ +namespace AirBomber +{ + partial class FormMap + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.pictureBoxCar = new System.Windows.Forms.PictureBox(); + this.statusStrip = new System.Windows.Forms.StatusStrip(); + this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel(); + this.buttonCreate = new System.Windows.Forms.Button(); + this.buttonUp = new System.Windows.Forms.Button(); + this.buttonLeft = new System.Windows.Forms.Button(); + this.buttonRight = new System.Windows.Forms.Button(); + this.buttonDown = new System.Windows.Forms.Button(); + this.buttonCreateModif = new System.Windows.Forms.Button(); + this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).BeginInit(); + this.statusStrip.SuspendLayout(); + this.SuspendLayout(); + // + // pictureBoxCar + // + this.pictureBoxCar.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBoxCar.Location = new System.Drawing.Point(0, 0); + this.pictureBoxCar.Name = "pictureBoxCar"; + this.pictureBoxCar.Size = new System.Drawing.Size(800, 428); + this.pictureBoxCar.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.pictureBoxCar.TabIndex = 0; + this.pictureBoxCar.TabStop = false; + // + // statusStrip + // + this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripStatusLabelSpeed, + this.toolStripStatusLabelWeight, + this.toolStripStatusLabelBodyColor}); + this.statusStrip.Location = new System.Drawing.Point(0, 428); + this.statusStrip.Name = "statusStrip"; + this.statusStrip.Size = new System.Drawing.Size(800, 22); + this.statusStrip.TabIndex = 1; + // + // toolStripStatusLabelSpeed + // + this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed"; + this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(62, 17); + this.toolStripStatusLabelSpeed.Text = "Скорость:"; + // + // toolStripStatusLabelWeight + // + this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight"; + this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(29, 17); + this.toolStripStatusLabelWeight.Text = "Вес:"; + // + // toolStripStatusLabelBodyColor + // + this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor"; + this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(36, 17); + this.toolStripStatusLabelBodyColor.Text = "Цвет:"; + // + // buttonCreate + // + this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonCreate.Location = new System.Drawing.Point(12, 390); + this.buttonCreate.Name = "buttonCreate"; + this.buttonCreate.Size = new System.Drawing.Size(75, 23); + this.buttonCreate.TabIndex = 2; + this.buttonCreate.Text = "Создать"; + this.buttonCreate.UseVisualStyleBackColor = true; + this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click); + // + // buttonUp + // + this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonUp.BackgroundImage = global::AirBomber.Properties.Resources.arrowUp; + this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonUp.Location = new System.Drawing.Point(722, 350); + this.buttonUp.Name = "buttonUp"; + this.buttonUp.Size = new System.Drawing.Size(30, 30); + this.buttonUp.TabIndex = 3; + this.buttonUp.UseVisualStyleBackColor = true; + this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonLeft + // + this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonLeft.BackgroundImage = global::AirBomber.Properties.Resources.arrowLeft; + this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonLeft.Location = new System.Drawing.Point(686, 386); + this.buttonLeft.Name = "buttonLeft"; + this.buttonLeft.Size = new System.Drawing.Size(30, 30); + this.buttonLeft.TabIndex = 4; + this.buttonLeft.UseVisualStyleBackColor = true; + this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonRight + // + this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonRight.BackgroundImage = global::AirBomber.Properties.Resources.arrowRight; + this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonRight.Location = new System.Drawing.Point(758, 386); + this.buttonRight.Name = "buttonRight"; + this.buttonRight.Size = new System.Drawing.Size(30, 30); + this.buttonRight.TabIndex = 5; + this.buttonRight.UseVisualStyleBackColor = true; + this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonDown + // + this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonDown.BackgroundImage = global::AirBomber.Properties.Resources.arrowDown; + this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonDown.Location = new System.Drawing.Point(722, 386); + this.buttonDown.Name = "buttonDown"; + this.buttonDown.Size = new System.Drawing.Size(30, 30); + this.buttonDown.TabIndex = 6; + this.buttonDown.UseVisualStyleBackColor = true; + this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonCreateModif + // + this.buttonCreateModif.Location = new System.Drawing.Point(104, 390); + this.buttonCreateModif.Name = "buttonCreateModif"; + this.buttonCreateModif.Size = new System.Drawing.Size(110, 23); + this.buttonCreateModif.TabIndex = 7; + this.buttonCreateModif.Text = "Модификация"; + this.buttonCreateModif.UseVisualStyleBackColor = true; + this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click); + // + // comboBoxSelectorMap + // + 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(12, 12); + this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; + this.comboBoxSelectorMap.Size = new System.Drawing.Size(121, 23); + this.comboBoxSelectorMap.TabIndex = 8; + this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged); + // + // FormMap + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.comboBoxSelectorMap); + this.Controls.Add(this.buttonCreateModif); + this.Controls.Add(this.buttonDown); + this.Controls.Add(this.buttonRight); + this.Controls.Add(this.buttonLeft); + this.Controls.Add(this.buttonUp); + this.Controls.Add(this.buttonCreate); + this.Controls.Add(this.pictureBoxCar); + this.Controls.Add(this.statusStrip); + this.Name = "FormMap"; + this.Text = "Карта"; + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).EndInit(); + this.statusStrip.ResumeLayout(false); + this.statusStrip.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private PictureBox pictureBoxCar; + private StatusStrip statusStrip; + private ToolStripStatusLabel toolStripStatusLabelSpeed; + private ToolStripStatusLabel toolStripStatusLabelWeight; + private ToolStripStatusLabel toolStripStatusLabelBodyColor; + private Button buttonCreate; + private Button buttonUp; + private Button buttonLeft; + private Button buttonRight; + private Button buttonDown; + private Button buttonCreateModif; + private ComboBox comboBoxSelectorMap; + } +} \ No newline at end of file diff --git a/AirBomber/AirBomber/FormMap.cs b/AirBomber/AirBomber/FormMap.cs new file mode 100644 index 0000000..159d4c6 --- /dev/null +++ b/AirBomber/AirBomber/FormMap.cs @@ -0,0 +1,93 @@ +using AirBomber; + +namespace AirBomber +{ + public partial class FormMap : Form + { + private AbstractMap _abstractMap; + + public FormMap() + { + InitializeComponent(); + _abstractMap = new SimpleMap(); + } + /// + /// Заполнение информации по объекту + /// + /// + private void SetData(DrawningAirplane car) + { + toolStripStatusLabelSpeed.Text = $"Скорость: {car.Airplane.Speed}"; + toolStripStatusLabelWeight.Text = $"Вес: {car.Airplane.Weight}"; + toolStripStatusLabelBodyColor.Text = $"Цвет: {car.Airplane.BodyColor.Name}"; + pictureBoxCar.Image = _abstractMap.CreateMap(pictureBoxCar.Width, pictureBoxCar.Height, + new DrawningObject(car)); + } + /// + /// Обработка нажатия кнопки "Создать" + /// + /// + /// + private void ButtonCreate_Click(object sender, EventArgs e) + { + Random rnd = new(); + var car = new DrawningAirplane(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + SetData(car); + } + /// + /// Изменение размеров формы + /// + /// + /// + private void ButtonMove_Click(object sender, EventArgs e) + { + //получаем имя кнопки + string name = ((Button)sender)?.Name ?? string.Empty; + Direction dir = Direction.None; + switch (name) + { + case "buttonUp": + dir = Direction.Up; + break; + case "buttonDown": + dir = Direction.Down; + break; + case "buttonLeft": + dir = Direction.Left; + break; + case "buttonRight": + dir = Direction.Right; + break; + } + pictureBoxCar.Image = _abstractMap?.MoveObject(dir); + } + /// + /// Обработка нажатия кнопки "Модификация" + /// + /// + /// + private void ButtonCreateModif_Click(object sender, EventArgs e) + { + Random rnd = new(); + var car = 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)), + Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2))); + SetData(car); + } + /// + /// Смена карты + /// + /// + /// + private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e) + { + switch (comboBoxSelectorMap.Text) + { + case "Простая карта": + _abstractMap = new SimpleMap(); + break; + } + } + } +} diff --git a/AirBomber/AirBomber/FormMap.resx b/AirBomber/AirBomber/FormMap.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/AirBomber/AirBomber/FormMap.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/AirBomber/AirBomber/Program.cs b/AirBomber/AirBomber/Program.cs index 76b85fe..e462fb5 100644 --- a/AirBomber/AirBomber/Program.cs +++ b/AirBomber/AirBomber/Program.cs @@ -11,7 +11,7 @@ namespace AirBomber // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormAirBomber()); + Application.Run(new FormMap()); } } } \ No newline at end of file diff --git a/AirBomber/AirBomber/SimpleMap.cs b/AirBomber/AirBomber/SimpleMap.cs new file mode 100644 index 0000000..63bb878 --- /dev/null +++ b/AirBomber/AirBomber/SimpleMap.cs @@ -0,0 +1,50 @@ +namespace AirBomber +{ + /// + /// Простая реализация абсрактного класса AbstractMap + /// + internal class SimpleMap : AbstractMap + { + /// + /// Цвет участка закрытого + /// + private readonly Brush barrierColor = new SolidBrush(Color.Black); + /// + /// Цвет участка открытого + /// + private readonly Brush roadColor = new SolidBrush(Color.Gray); + + protected override void DrawBarrierPart(Graphics g, int i, int j) + { + g.FillRectangle(barrierColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1)); + } + protected override void DrawRoadPart(Graphics g, int i, int j) + { + g.FillRectangle(roadColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1)); + } + protected override void GenerateMap() + { + _map = new int[100, 100]; + _size_x = (float)_width / _map.GetLength(0); + _size_y = (float)_height / _map.GetLength(1); + int counter = 0; + for (int i = 0; i < _map.GetLength(0); ++i) + { + for (int j = 0; j < _map.GetLength(1); ++j) + { + _map[i, j] = _freeRoad; + } + } + while (counter < 50) + { + int x = _random.Next(0, 100); + int y = _random.Next(0, 100); + if (_map[x, y] == _freeRoad) + { + _map[x, y] = _barrier; + counter++; + } + } + } + } +} \ No newline at end of file -- 2.25.1 From 20b682b2efb464f808574165dadba5f5734d8bf7 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: Thu, 15 Sep 2022 16:54:13 +0400 Subject: [PATCH 05/15] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D0=B0=20=D0=BA=D0=B0=D1=80=D1=82=D1=8B=20=D0=B8=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B7=D1=80=D0=B5=D1=88=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BB=D0=BB=D0=B8=D0=B7=D0=B8=D0=B9=20=D1=81=20?= =?UTF-8?q?=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA=D1=82=D0=B0=D0=BC=D0=B8=20=D0=BA?= =?UTF-8?q?=D0=B0=D1=80=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/AbstractMap.cs | 105 +++++++++++++++++++++--- AirBomber/AirBomber/DrawningAirplane.cs | 4 +- AirBomber/AirBomber/DrawningObject.cs | 2 +- AirBomber/AirBomber/FormMap.Designer.cs | 1 + AirBomber/AirBomber/FormMap.resx | 65 +-------------- AirBomber/AirBomber/IDrawningObject.cs | 2 +- 6 files changed, 103 insertions(+), 76 deletions(-) diff --git a/AirBomber/AirBomber/AbstractMap.cs b/AirBomber/AirBomber/AbstractMap.cs index 450c122..ca27fbb 100644 --- a/AirBomber/AirBomber/AbstractMap.cs +++ b/AirBomber/AirBomber/AbstractMap.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -9,6 +10,7 @@ namespace AirBomber internal abstract class AbstractMap { private IDrawningObject _drawningObject = null; + private Bitmap? _staticBitMap; protected int[,] _map = null; protected int _width; protected int _height; @@ -20,6 +22,7 @@ namespace AirBomber public Bitmap CreateMap(int width, int height, IDrawningObject drawningObject) { + _staticBitMap = null; _width = width; _height = height; _drawningObject = drawningObject; @@ -30,10 +33,56 @@ namespace AirBomber } return DrawMapWithObject(); } + + /// Проверяет наличие непроходимых участков в заданной области + /// Заданная область + /// i-ый индекс первого барьера, который был найден в области + /// j-ый индекс первого барьера, который был найден в области + /// Есть ли барьеры + protected bool BarriersInArea(RectangleF area, ref int iBarrier, ref int jBarrier) + { + if (!(0 < area.Left && area.Right < _width && 0 < area.Top && area.Bottom < _height)) + { + return true; // Если область попала за карту, считаем что она столкнулась с барьером + } + int rightArea = (int)Math.Ceiling(area.Right / _size_x); + int bottomArea = (int)Math.Ceiling(area.Bottom / _size_y); + for (int i = (int)(area.Left / _size_x); i < rightArea; i++) + { + for (int j = (int)(area.Top / _size_y); j < bottomArea; j++) + { + if (_map[i, j] == _barrier) + { + iBarrier = i; + jBarrier = j; + return true; + } + } + } + return false; + } + protected bool BarriersInArea(RectangleF area) + { + int a = 0, b = 0; + return BarriersInArea(area, ref a, ref b); + } + + public Bitmap MoveObject(Direction direction) { - // TODO проверка, что объект может переместится в требуемом направлении - if (true) + var rect = _drawningObject.GetCurrentPosition(); + var step = _drawningObject.Step; + // Вычисляем области смещения объекта + RectangleF? area = null; + if (direction == Direction.Left) + area = new(rect.Left - step, rect.Top, step, rect.Height); + else if (direction == Direction.Right) + area = new(rect.Right, rect.Top, step, rect.Height); + else if (direction == Direction.Up) + area = new(rect.Left, rect.Top - step, rect.Width, step); + else if (direction == Direction.Down) + area = new(rect.Left, rect.Bottom, rect.Width, step); + if (area.HasValue && !BarriersInArea(area.Value)) { _drawningObject.MoveObject(direction); } @@ -48,17 +97,37 @@ namespace AirBomber int x = _random.Next(0, 10); int y = _random.Next(0, 10); _drawningObject.SetObject(x, y, _width, _height); - // TODO првоерка, что объект не "накладывается" на закрытые участки - return true; - } - private Bitmap DrawMapWithObject() - { - Bitmap bmp = new(_width, _height); - if (_drawningObject == null || _map == null) + + // Если натыкаемся на барьер помещаем левый верхний угол чуть ниже этого барьера + // если при этом выходим за карту, пермещаем правый нижный угол чуть выше этого барьера + // если объект выходит за карту, генирируем новые координаты рандомно + int currI = 0, currJ = 0; + var areaObject = _drawningObject.GetCurrentPosition(); + int cntOut = 10000; // Количество итераций до выхода из цикла + while (BarriersInArea(areaObject, ref currI, ref currJ) && --cntOut >= 0) { - return bmp; + if ((currJ + 1) * _size_y + areaObject.Height <= _height) + { + areaObject.Location = new PointF((currI + 1) * _size_x, (currJ + 1) * _size_y); + } + else if ((currI - 1) * _size_x - areaObject.Width >= 0) + { + areaObject = new((currI - 1) * _size_x - areaObject.Width, (currJ - 1) * _size_y - areaObject.Height, areaObject.Width, areaObject.Height); + } + else + { + areaObject.Location = new PointF(_random.Next(0, _width - (int)areaObject.Width), + _random.Next(0, _height - (int)areaObject.Height)); + } } - Graphics gr = Graphics.FromImage(bmp); + _drawningObject.SetObject((int)areaObject.X, (int)areaObject.Y, _width, _height); + return cntOut >= 0; + } + private void DrawMap() + { + if (_staticBitMap != null) return; + _staticBitMap = new(_width, _height); + Graphics gr = Graphics.FromImage(_staticBitMap); for (int i = 0; i < _map.GetLength(0); ++i) { for (int j = 0; j < _map.GetLength(1); ++j) @@ -73,6 +142,20 @@ namespace AirBomber } } } + } + + private Bitmap DrawMapWithObject() + { + Bitmap bmp = new(_width, _height); + if (_drawningObject == null || _map == null) + { + return bmp; + } + Graphics gr = Graphics.FromImage(bmp); + if (_staticBitMap == null) + DrawMap(); + if (_staticBitMap != null) + gr.DrawImage(_staticBitMap, 0, 0); _drawningObject.DrawningObject(gr); return bmp; } diff --git a/AirBomber/AirBomber/DrawningAirplane.cs b/AirBomber/AirBomber/DrawningAirplane.cs index 2c2e221..811956e 100644 --- a/AirBomber/AirBomber/DrawningAirplane.cs +++ b/AirBomber/AirBomber/DrawningAirplane.cs @@ -211,9 +211,9 @@ /// Получение текущей позиции объекта /// /// - public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + public RectangleF GetCurrentPosition() { - return (_startPosX, _startPosY, _startPosX + _airplaneWidth, _startPosY + _airplaneHeight); + return new(_startPosX, _startPosY, _airplaneWidth, _airplaneHeight); } } } \ No newline at end of file diff --git a/AirBomber/AirBomber/DrawningObject.cs b/AirBomber/AirBomber/DrawningObject.cs index af617fb..d79a291 100644 --- a/AirBomber/AirBomber/DrawningObject.cs +++ b/AirBomber/AirBomber/DrawningObject.cs @@ -17,7 +17,7 @@ namespace AirBomber public float Step => _airplane?.Airplane?.Step ?? 0; - public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + public RectangleF GetCurrentPosition() { return _airplane.GetCurrentPosition(); } diff --git a/AirBomber/AirBomber/FormMap.Designer.cs b/AirBomber/AirBomber/FormMap.Designer.cs index c7b8330..61a199a 100644 --- a/AirBomber/AirBomber/FormMap.Designer.cs +++ b/AirBomber/AirBomber/FormMap.Designer.cs @@ -144,6 +144,7 @@ // // buttonCreateModif // + this.buttonCreateModif.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.buttonCreateModif.Location = new System.Drawing.Point(104, 390); this.buttonCreateModif.Name = "buttonCreateModif"; this.buttonCreateModif.Size = new System.Drawing.Size(110, 23); diff --git a/AirBomber/AirBomber/FormMap.resx b/AirBomber/AirBomber/FormMap.resx index 1af7de1..2c0949d 100644 --- a/AirBomber/AirBomber/FormMap.resx +++ b/AirBomber/AirBomber/FormMap.resx @@ -1,64 +1,4 @@ - - - + @@ -117,4 +57,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file diff --git a/AirBomber/AirBomber/IDrawningObject.cs b/AirBomber/AirBomber/IDrawningObject.cs index 2b2330c..6077012 100644 --- a/AirBomber/AirBomber/IDrawningObject.cs +++ b/AirBomber/AirBomber/IDrawningObject.cs @@ -38,6 +38,6 @@ namespace AirBomber /// Получение текущей позиции объекта /// /// - (float Left, float Right, float Top, float Bottom) GetCurrentPosition(); + RectangleF GetCurrentPosition(); } } -- 2.25.1 From 7edfd49847078da9a52e40ed8af0a7bf6de9ffd1 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: Thu, 15 Sep 2022 18:01:28 +0400 Subject: [PATCH 06/15] =?UTF-8?q?=D0=A3=D0=BC=D0=B5=D0=BD=D1=8C=D1=88?= =?UTF-8?q?=D0=B5=D0=BD=20=D1=81=D1=82=D0=B0=D0=BD=D0=B4=D0=B0=D1=80=D1=82?= =?UTF-8?q?=D0=BD=D1=8B=D0=B9=20=D1=81=D0=B0=D0=BC=D0=BE=D0=BB=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/DrawningAirplane.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AirBomber/AirBomber/DrawningAirplane.cs b/AirBomber/AirBomber/DrawningAirplane.cs index 811956e..9b0e1ce 100644 --- a/AirBomber/AirBomber/DrawningAirplane.cs +++ b/AirBomber/AirBomber/DrawningAirplane.cs @@ -28,11 +28,11 @@ /// /// Ширина отрисовки автомобиля /// - protected readonly int _airplaneWidth = 110; + protected readonly int _airplaneWidth = 80; /// /// Высота отрисовки автомобиля /// - protected readonly int _airplaneHeight = 140; + protected readonly int _airplaneHeight = 90; /// /// Инициализация свойств /// -- 2.25.1 From 020c73c4d1d08587f16ee0af2c63228b4341797b 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: Thu, 15 Sep 2022 18:01:48 +0400 Subject: [PATCH 07/15] =?UTF-8?q?=D0=9A=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=B0=D1=80=D0=B8=D0=B9=20=D0=BA=20=D0=B3=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=D1=80=D0=B0=D1=86=D0=B8=D0=B8=20=D0=BA=D0=B0=D1=80=D1=82?= =?UTF-8?q?=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/AbstractMap.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AirBomber/AirBomber/AbstractMap.cs b/AirBomber/AirBomber/AbstractMap.cs index ca27fbb..260ad22 100644 --- a/AirBomber/AirBomber/AbstractMap.cs +++ b/AirBomber/AirBomber/AbstractMap.cs @@ -160,6 +160,9 @@ namespace AirBomber return bmp; } + /// + /// Генерация карты. При перегрузки определить поля _map, _size_x, _size_y + /// protected abstract void GenerateMap(); protected abstract void DrawRoadPart(Graphics g, int i, int j); protected abstract void DrawBarrierPart(Graphics g, int i, int j); -- 2.25.1 From 7df4ed00cef3c01fca3ed13ad8270f162989f866 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: Thu, 15 Sep 2022 18:02:00 +0400 Subject: [PATCH 08/15] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BD=D0=BE=D0=B2=D0=B0=D1=8F=20=D0=BA?= =?UTF-8?q?=D0=B0=D1=80=D1=82=D0=B0=20=D1=81=D0=BE=20=D1=81=D1=82=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/FormMap.Designer.cs | 3 +- AirBomber/AirBomber/FormMap.cs | 3 ++ AirBomber/AirBomber/WallMap.cs | 65 +++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 AirBomber/AirBomber/WallMap.cs diff --git a/AirBomber/AirBomber/FormMap.Designer.cs b/AirBomber/AirBomber/FormMap.Designer.cs index 61a199a..54ebe8b 100644 --- a/AirBomber/AirBomber/FormMap.Designer.cs +++ b/AirBomber/AirBomber/FormMap.Designer.cs @@ -158,7 +158,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(12, 12); this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; this.comboBoxSelectorMap.Size = new System.Drawing.Size(121, 23); diff --git a/AirBomber/AirBomber/FormMap.cs b/AirBomber/AirBomber/FormMap.cs index 159d4c6..c311927 100644 --- a/AirBomber/AirBomber/FormMap.cs +++ b/AirBomber/AirBomber/FormMap.cs @@ -87,6 +87,9 @@ namespace AirBomber case "Простая карта": _abstractMap = new SimpleMap(); break; + case "Карта со стенами": + _abstractMap = new WallMap(); + break; } } } diff --git a/AirBomber/AirBomber/WallMap.cs b/AirBomber/AirBomber/WallMap.cs new file mode 100644 index 0000000..8cb7989 --- /dev/null +++ b/AirBomber/AirBomber/WallMap.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AirBomber +{ + internal class WallMap : AbstractMap + { + /// + /// Цвет участка закрытого + /// + private readonly Brush barrierColor = new SolidBrush(Color.Brown); + /// + /// Цвет участка открытого + /// + private readonly Brush roadColor = new SolidBrush(Color.LightPink); + protected override void DrawBarrierPart(Graphics g, int i, int j) + { + g.FillPolygon(barrierColor, new PointF[] + { + new PointF(i * _size_x, j * _size_y), + new PointF((i + 1) * _size_x, j * _size_y), + new PointF((i + 1) * _size_x - _size_x / 4, (j + 1) * _size_y - _size_y / 2), + new PointF((i + 1) * _size_x, (j + 1) * _size_y), + new PointF(i * _size_x, (j + 1) * _size_y), + new PointF(i * _size_x + _size_x / 4, (j + 1) * _size_y - _size_y / 2), + }); + } + + protected override void DrawRoadPart(Graphics g, int i, int j) + { + g.FillRectangle(roadColor, i * _size_x, j * _size_y, (i + 1) * _size_x, (j + 1) * _size_y); + } + + protected override void GenerateMap() + { + _map = new int[120, 120]; + var minSize = Math.Min(_map.GetLength(0), _map.GetLength(1)); + _size_x = (float)_width / _map.GetLength(0); + _size_y = (float)_height / _map.GetLength(1); + for (int i = 0; i < _map.GetLength(0); ++i) + { + for (int j = 0; j < _map.GetLength(1); ++j) + { + _map[i, j] = _freeRoad; + } + } + for (var i = 0; i < 10; i++) + { + var lengthWall = _random.Next(3, minSize / 2); + var incX = _random.Next(0, 2); + var incY = 1 - incX; + var left = _random.Next(0, _map.GetLength(0) - lengthWall); + var top = _random.Next(0, _map.GetLength(1) - lengthWall); + for (var j = 0; j < lengthWall; j++) + { + _map[left + incX * j, top + incY * j] = _barrier; + } + } + + } + } +} -- 2.25.1 From 78c0f3880fbb45ddeb289fcb2229667d14e29987 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: Thu, 22 Sep 2022 05:07:35 +0400 Subject: [PATCH 09/15] =?UTF-8?q?=D0=97=D0=B0=D0=BC=D0=B5=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=B2=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D1=8F=D1=85=20=D0=B0=D0=B2=D1=82=D0=BE=D0=BC=D0=BE=D0=B1?= =?UTF-8?q?=D0=B8=D0=BB=D1=8F=20=D0=BD=D0=B0=20=D1=81=D0=B0=D0=BC=D0=BE?= =?UTF-8?q?=D0=BB=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/DrawningAirplane.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/AirBomber/AirBomber/DrawningAirplane.cs b/AirBomber/AirBomber/DrawningAirplane.cs index 9b0e1ce..c9cf1dc 100644 --- a/AirBomber/AirBomber/DrawningAirplane.cs +++ b/AirBomber/AirBomber/DrawningAirplane.cs @@ -10,11 +10,11 @@ /// public EntityAirplane Airplane { get; protected set; } /// - /// Левая координата отрисовки автомобиля + /// Левая координата отрисовки самолета /// protected float _startPosX; /// - /// Верхняя кооридната отрисовки автомобиля + /// Верхняя кооридната отрисовки самолета /// protected float _startPosY; /// @@ -26,11 +26,11 @@ /// protected int? _pictureHeight = null; /// - /// Ширина отрисовки автомобиля + /// Ширина отрисовки самолета /// protected readonly int _airplaneWidth = 80; /// - /// Высота отрисовки автомобиля + /// Высота отрисовки самолета /// protected readonly int _airplaneHeight = 90; /// -- 2.25.1 From c2c005c942752bff1f80413d51be9a61fcaf4be8 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, 23 Sep 2022 11:50:35 +0400 Subject: [PATCH 10/15] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D1=8E=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=B8=20=D0=B8=D0=B7=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D1=8B=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=B0=D1=80=D0=B8=D0=B8=20=D0=B2=20=D0=BA=D0=BE=D0=B4?= =?UTF-8?q?=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/AbstractMap.cs | 6 ++++++ AirBomber/AirBomber/EntityAirBomber.cs | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/AirBomber/AirBomber/AbstractMap.cs b/AirBomber/AirBomber/AbstractMap.cs index 260ad22..78425d8 100644 --- a/AirBomber/AirBomber/AbstractMap.cs +++ b/AirBomber/AirBomber/AbstractMap.cs @@ -61,6 +61,9 @@ namespace AirBomber } return false; } + /// Проверяет наличие непроходимых участков в заданной области + /// Заданная область + /// Есть ли барьеры protected bool BarriersInArea(RectangleF area) { int a = 0, b = 0; @@ -123,6 +126,9 @@ namespace AirBomber _drawningObject.SetObject((int)areaObject.X, (int)areaObject.Y, _width, _height); return cntOut >= 0; } + /// + /// Заполняет BitMap для отрисовки статичных объектов. Выполняется один раз при создании карты + /// private void DrawMap() { if (_staticBitMap != null) return; diff --git a/AirBomber/AirBomber/EntityAirBomber.cs b/AirBomber/AirBomber/EntityAirBomber.cs index 8e5ace5..6d5b03f 100644 --- a/AirBomber/AirBomber/EntityAirBomber.cs +++ b/AirBomber/AirBomber/EntityAirBomber.cs @@ -24,8 +24,8 @@ namespace AirBomber /// Инициализация свойств /// /// Скорость - /// Вес автомобиля - /// Цвет кузова + /// Вес самолета + /// Цвет обшивки самолета /// Дополнительный цвет /// Признак наличия бомб /// Признак наличия топливных баков -- 2.25.1 From 2f87fa46bdcdc4eed2eff652967f0d4a087eb11f 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, 23 Sep 2022 11:10:20 +0400 Subject: [PATCH 11/15] =?UTF-8?q?=D0=97=D0=B0=D0=BC=D0=B5=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D1=80=D0=B8?= =?UTF-8?q?=D0=B5=D0=B2=20=D1=81=20=D0=BD=D0=B5=D0=BA=D0=BE=D1=80=D1=80?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=BD=D0=BE=D0=B9=20=D0=BA=D0=BE=D0=B4=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=BA=D0=BE=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/FormAirBomber.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/AirBomber/AirBomber/FormAirBomber.cs b/AirBomber/AirBomber/FormAirBomber.cs index 4ef6eb4..f177f21 100644 --- a/AirBomber/AirBomber/FormAirBomber.cs +++ b/AirBomber/AirBomber/FormAirBomber.cs @@ -9,8 +9,8 @@ namespace AirBomber InitializeComponent(); } /// - /// - /// + /// + /// private void Draw() { Bitmap bmp = new(pictureBoxCar.Width, pictureBoxCar.Height); @@ -42,7 +42,7 @@ namespace AirBomber Draw(); } /// - /// + /// /// /// /// @@ -68,7 +68,7 @@ namespace AirBomber Draw(); } /// - /// + /// /// /// /// -- 2.25.1 From 97fda24a733ee8c3e5bf930e622e8da0bf63db6d 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: Thu, 29 Sep 2022 21:55:54 +0400 Subject: [PATCH 12/15] =?UTF-8?q?=D0=97=D0=B0=D0=BC=D0=B5=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=B0=D0=B2=D1=82=D0=BE=D0=BC=D0=BE=D0=B1=D0=B8=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=81=D0=B0=D0=BC=D0=BE=D0=BB=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/FormAirBomber.Designer.cs | 26 +++++++++---------- AirBomber/AirBomber/FormAirBomber.cs | 10 +++---- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/AirBomber/AirBomber/FormAirBomber.Designer.cs b/AirBomber/AirBomber/FormAirBomber.Designer.cs index 294d009..8419495 100644 --- a/AirBomber/AirBomber/FormAirBomber.Designer.cs +++ b/AirBomber/AirBomber/FormAirBomber.Designer.cs @@ -28,7 +28,7 @@ /// private void InitializeComponent() { - this.pictureBoxCar = new System.Windows.Forms.PictureBox(); + this.pictureBoxAirplane = new System.Windows.Forms.PictureBox(); this.statusStrip = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel(); @@ -43,16 +43,16 @@ this.statusStrip.SuspendLayout(); this.SuspendLayout(); // - // pictureBoxCar + // pictureBoxAirplane // - this.pictureBoxCar.Dock = System.Windows.Forms.DockStyle.Fill; - this.pictureBoxCar.Location = new System.Drawing.Point(0, 0); - this.pictureBoxCar.Name = "pictureBoxCar"; - this.pictureBoxCar.Size = new System.Drawing.Size(800, 428); - this.pictureBoxCar.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; - this.pictureBoxCar.TabIndex = 0; - this.pictureBoxCar.TabStop = false; - this.pictureBoxCar.Resize += new System.EventHandler(this.PictureBoxCar_Resize); + this.pictureBoxAirplane.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBoxAirplane.Location = new System.Drawing.Point(0, 0); + this.pictureBoxAirplane.Name = "pictureBoxAirplane"; + this.pictureBoxAirplane.Size = new System.Drawing.Size(800, 428); + this.pictureBoxAirplane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.pictureBoxAirplane.TabIndex = 0; + this.pictureBoxAirplane.TabStop = false; + this.pictureBoxAirplane.Resize += new System.EventHandler(this.PictureBoxAirplane_Resize); // // statusStrip // @@ -164,11 +164,11 @@ this.Controls.Add(this.buttonLeft); this.Controls.Add(this.buttonUp); this.Controls.Add(this.buttonCreate); - this.Controls.Add(this.pictureBoxCar); + this.Controls.Add(this.pictureBoxAirplane); this.Controls.Add(this.statusStrip); this.Name = "FormAirBomber"; this.Text = "Самолет"; - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).EndInit(); this.statusStrip.ResumeLayout(false); this.statusStrip.PerformLayout(); this.ResumeLayout(false); @@ -178,7 +178,7 @@ #endregion - private PictureBox pictureBoxCar; + private PictureBox pictureBoxAirplane; private StatusStrip statusStrip; private ToolStripStatusLabel toolStripStatusLabelSpeed; private ToolStripStatusLabel toolStripStatusLabelWeight; diff --git a/AirBomber/AirBomber/FormAirBomber.cs b/AirBomber/AirBomber/FormAirBomber.cs index f177f21..4949853 100644 --- a/AirBomber/AirBomber/FormAirBomber.cs +++ b/AirBomber/AirBomber/FormAirBomber.cs @@ -9,14 +9,14 @@ namespace AirBomber InitializeComponent(); } /// - /// + /// /// private void Draw() { - Bitmap bmp = new(pictureBoxCar.Width, pictureBoxCar.Height); + Bitmap bmp = new(pictureBoxAirplane.Width, pictureBoxAirplane.Height); Graphics gr = Graphics.FromImage(bmp); _airplane?.DrawTransport(gr); - pictureBoxCar.Image = bmp; + pictureBoxAirplane.Image = bmp; } /// /// @@ -72,9 +72,9 @@ namespace AirBomber /// /// /// - private void PictureBoxCar_Resize(object sender, EventArgs e) + private void PictureBoxAirplane_Resize(object sender, EventArgs e) { - _airplane?.ChangeBorders(pictureBoxCar.Width, pictureBoxCar.Height); + _airplane?.ChangeBorders(pictureBoxAirplane.Width, pictureBoxAirplane.Height); Draw(); } /// -- 2.25.1 From 32b7c9ecf754597f84c92d644928cba0f6d79fc2 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: Thu, 29 Sep 2022 22:04:14 +0400 Subject: [PATCH 13/15] =?UTF-8?q?=D0=97=D0=B0=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=B0=D0=B2=D1=82=D0=BE=D0=BC=D0=BE=D0=B1=D0=B8=D0=BB?= =?UTF-8?q?=D1=8C=20=D0=BD=D0=B0=20=D1=81=D0=B0=D0=BC=D0=BE=D0=BB=D0=B5?= =?UTF-8?q?=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/FormAirBomber.Designer.cs | 2 +- AirBomber/AirBomber/FormMap.Designer.cs | 26 +++++++++---------- AirBomber/AirBomber/FormMap.cs | 4 +-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/AirBomber/AirBomber/FormAirBomber.Designer.cs b/AirBomber/AirBomber/FormAirBomber.Designer.cs index 8419495..013e662 100644 --- a/AirBomber/AirBomber/FormAirBomber.Designer.cs +++ b/AirBomber/AirBomber/FormAirBomber.Designer.cs @@ -39,7 +39,7 @@ this.buttonRight = new System.Windows.Forms.Button(); this.buttonDown = new System.Windows.Forms.Button(); this.buttonCreateModif = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).BeginInit(); this.statusStrip.SuspendLayout(); this.SuspendLayout(); // diff --git a/AirBomber/AirBomber/FormMap.Designer.cs b/AirBomber/AirBomber/FormMap.Designer.cs index 54ebe8b..6781998 100644 --- a/AirBomber/AirBomber/FormMap.Designer.cs +++ b/AirBomber/AirBomber/FormMap.Designer.cs @@ -28,7 +28,7 @@ /// private void InitializeComponent() { - this.pictureBoxCar = new System.Windows.Forms.PictureBox(); + this.pictureBoxAirplane = new System.Windows.Forms.PictureBox(); this.statusStrip = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel(); @@ -40,19 +40,19 @@ this.buttonDown = new System.Windows.Forms.Button(); this.buttonCreateModif = new System.Windows.Forms.Button(); this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).BeginInit(); this.statusStrip.SuspendLayout(); this.SuspendLayout(); // - // pictureBoxCar + // pictureBoxAirplane // - this.pictureBoxCar.Dock = System.Windows.Forms.DockStyle.Fill; - this.pictureBoxCar.Location = new System.Drawing.Point(0, 0); - this.pictureBoxCar.Name = "pictureBoxCar"; - this.pictureBoxCar.Size = new System.Drawing.Size(800, 428); - this.pictureBoxCar.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; - this.pictureBoxCar.TabIndex = 0; - this.pictureBoxCar.TabStop = false; + this.pictureBoxAirplane.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBoxAirplane.Location = new System.Drawing.Point(0, 0); + this.pictureBoxAirplane.Name = "pictureBoxAirplane"; + this.pictureBoxAirplane.Size = new System.Drawing.Size(800, 428); + this.pictureBoxAirplane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.pictureBoxAirplane.TabIndex = 0; + this.pictureBoxAirplane.TabStop = false; // // statusStrip // @@ -178,11 +178,11 @@ this.Controls.Add(this.buttonLeft); this.Controls.Add(this.buttonUp); this.Controls.Add(this.buttonCreate); - this.Controls.Add(this.pictureBoxCar); + this.Controls.Add(this.pictureBoxAirplane); this.Controls.Add(this.statusStrip); this.Name = "FormMap"; this.Text = "Карта"; - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).EndInit(); this.statusStrip.ResumeLayout(false); this.statusStrip.PerformLayout(); this.ResumeLayout(false); @@ -192,7 +192,7 @@ #endregion - private PictureBox pictureBoxCar; + private PictureBox pictureBoxAirplane; private StatusStrip statusStrip; private ToolStripStatusLabel toolStripStatusLabelSpeed; private ToolStripStatusLabel toolStripStatusLabelWeight; diff --git a/AirBomber/AirBomber/FormMap.cs b/AirBomber/AirBomber/FormMap.cs index c311927..6843933 100644 --- a/AirBomber/AirBomber/FormMap.cs +++ b/AirBomber/AirBomber/FormMap.cs @@ -20,7 +20,7 @@ namespace AirBomber toolStripStatusLabelSpeed.Text = $"Скорость: {car.Airplane.Speed}"; toolStripStatusLabelWeight.Text = $"Вес: {car.Airplane.Weight}"; toolStripStatusLabelBodyColor.Text = $"Цвет: {car.Airplane.BodyColor.Name}"; - pictureBoxCar.Image = _abstractMap.CreateMap(pictureBoxCar.Width, pictureBoxCar.Height, + pictureBoxAirplane.Image = _abstractMap.CreateMap(pictureBoxAirplane.Width, pictureBoxAirplane.Height, new DrawningObject(car)); } /// @@ -59,7 +59,7 @@ namespace AirBomber dir = Direction.Right; break; } - pictureBoxCar.Image = _abstractMap?.MoveObject(dir); + pictureBoxAirplane.Image = _abstractMap?.MoveObject(dir); } /// /// Обработка нажатия кнопки "Модификация" -- 2.25.1 From 710e7086b91bebf660e092fcb897c1666ff2de3a 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: Thu, 29 Sep 2022 22:06:19 +0400 Subject: [PATCH 14/15] =?UTF-8?q?=D0=97=D0=B0=D0=BC=D0=B5=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=B0=D0=B2=D1=82=D0=BE=D0=BC=D0=BE=D0=B1=D0=B8=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=81=D0=B0=D0=BC=D0=BE=D0=BB=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/FormMap.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/AirBomber/AirBomber/FormMap.cs b/AirBomber/AirBomber/FormMap.cs index 6843933..8bd4c48 100644 --- a/AirBomber/AirBomber/FormMap.cs +++ b/AirBomber/AirBomber/FormMap.cs @@ -14,14 +14,14 @@ namespace AirBomber /// /// Заполнение информации по объекту /// - /// - private void SetData(DrawningAirplane car) + /// + private void SetData(DrawningAirplane airplane) { - toolStripStatusLabelSpeed.Text = $"Скорость: {car.Airplane.Speed}"; - toolStripStatusLabelWeight.Text = $"Вес: {car.Airplane.Weight}"; - toolStripStatusLabelBodyColor.Text = $"Цвет: {car.Airplane.BodyColor.Name}"; + toolStripStatusLabelSpeed.Text = $"Скорость: {airplane.Airplane.Speed}"; + toolStripStatusLabelWeight.Text = $"Вес: {airplane.Airplane.Weight}"; + toolStripStatusLabelBodyColor.Text = $"Цвет: {airplane.Airplane.BodyColor.Name}"; pictureBoxAirplane.Image = _abstractMap.CreateMap(pictureBoxAirplane.Width, pictureBoxAirplane.Height, - new DrawningObject(car)); + new DrawningObject(airplane)); } /// /// Обработка нажатия кнопки "Создать" @@ -31,8 +31,8 @@ namespace AirBomber private void ButtonCreate_Click(object sender, EventArgs e) { Random rnd = new(); - var car = new DrawningAirplane(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); - SetData(car); + var airplane = new DrawningAirplane(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + SetData(airplane); } /// /// Изменение размеров формы @@ -69,11 +69,11 @@ namespace AirBomber private void ButtonCreateModif_Click(object sender, EventArgs e) { Random rnd = new(); - var car = new DrawningAirBomber(rnd.Next(100, 300), rnd.Next(1000, 2000), + var 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)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2))); - SetData(car); + SetData(airplane); } /// /// Смена карты -- 2.25.1 From 92d046cc547872133c00832fa65da13150f24cf5 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: Thu, 29 Sep 2022 22:25:20 +0400 Subject: [PATCH 15/15] =?UTF-8?q?=D0=97=D0=B0=D0=BC=D0=B5=D0=BD=D0=B0=20pi?= =?UTF-8?q?ctureBoxCar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/FormAirBomber.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AirBomber/AirBomber/FormAirBomber.cs b/AirBomber/AirBomber/FormAirBomber.cs index 4949853..8eaaa46 100644 --- a/AirBomber/AirBomber/FormAirBomber.cs +++ b/AirBomber/AirBomber/FormAirBomber.cs @@ -24,7 +24,7 @@ namespace AirBomber private void SetData() { Random rnd = new(); - _airplane.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxCar.Width, pictureBoxCar.Height); + _airplane.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxAirplane.Width, pictureBoxAirplane.Height); toolStripStatusLabelSpeed.Text = $": {_airplane.Airplane.Speed}"; toolStripStatusLabelWeight.Text = $": {_airplane.Airplane.Weight}"; toolStripStatusLabelBodyColor.Text = $": {_airplane.Airplane.BodyColor.Name}"; -- 2.25.1