From 202d67a929e7b93dc0d741a26c82ff571add9a13 Mon Sep 17 00:00:00 2001 From: 1SooNoo1 Date: Sat, 16 Sep 2023 17:11:43 +0400 Subject: [PATCH 1/9] Lab_1_Kryukov_AI_Excavator --- ProjectExcavator/ProjectExcavator/DrawningExcavator.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs b/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs index 6a25801..88f5a9a 100644 --- a/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs +++ b/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs @@ -21,19 +21,19 @@ namespace ProjectExcavator /// private int _pictureHeight; /// - /// Левая координата прорисовки автомобиля + /// Левая координата прорисовки экскаватора /// private int _startPosX; /// - /// Верхняя кооридната прорисовки автомобиля + /// Верхняя кооридната прорисовки экскаватора /// private int _startPosY; /// - /// Ширина прорисовки автомобиля + /// Ширина прорисовки экскаватора /// private readonly int _excavatorWidth = 190; /// - /// Высота прорисовки автомобиля + /// Высота прорисовки экскаватора /// private readonly int _excavatorHeight = 170; /// @@ -124,7 +124,6 @@ namespace ProjectExcavator return; } Pen pen = new(Color.Black); - Brush additionalBrush = new SolidBrush(EntityExcavator.AdditionalColor); if (EntityExcavator.BodyKit) { From 2823410adc4d13df10fe63f30d230c0f1331c3da Mon Sep 17 00:00:00 2001 From: SooNooClose Date: Tue, 26 Sep 2023 12:28:52 +0400 Subject: [PATCH 2/9] Lab_1_KryukovAI_Excavator --- .../lab_1_pojectExcavator/DrawingExcavator.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lab_1_pojectExcavator/lab_1_pojectExcavator/DrawingExcavator.cs b/lab_1_pojectExcavator/lab_1_pojectExcavator/DrawingExcavator.cs index 631f5c8..65ba09a 100644 --- a/lab_1_pojectExcavator/lab_1_pojectExcavator/DrawingExcavator.cs +++ b/lab_1_pojectExcavator/lab_1_pojectExcavator/DrawingExcavator.cs @@ -31,11 +31,11 @@ namespace lab_1_pojectExcavator /// /// Ширина прорисовки автомобиля /// - private readonly int _excavatorWidth = 190; + private readonly int _excavatorWidth = 200; /// /// Высота прорисовки автомобиля /// - private readonly int _excavatorHeight = 170; + private readonly int _excavatorHeight = 150; /// /// Инициализация свойств /// @@ -51,9 +51,12 @@ namespace lab_1_pojectExcavator public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool backet,int width, int height) { - // TODO: Продумать проверки _pictureWidth = width; _pictureHeight = height; + if(_pictureHeight < _excavatorHeight || _pictureWidth < _excavatorWidth) + { + return false; + } EntityExcavator = new EntityExcavator(); EntityExcavator.Init(speed, weight, bodyColor, additionalColor,bodyKit, backet); return true; @@ -65,9 +68,9 @@ namespace lab_1_pojectExcavator /// Координата Y public void SetPosition(int x, int y) { - // TODO: Изменение x, y - _startPosX = x; - _startPosY = y; + + _startPosX = Math.Min(x,_pictureWidth - _excavatorWidth); + _startPosY = Math.Min(y,_pictureHeight - _excavatorHeight); } @@ -106,7 +109,7 @@ namespace lab_1_pojectExcavator break; //вниз case DirectionType.Down: - if (_startPosY + EntityExcavator.Step < _pictureHeight- _excavatorHeight) + if (_startPosY + EntityExcavator.Step < _pictureHeight - _excavatorHeight) { _startPosY += (int)EntityExcavator.Step; } From fcaa20eb94b0c6162f4b99a6f7053c83f45fa756 Mon Sep 17 00:00:00 2001 From: SooNooClose Date: Tue, 26 Sep 2023 14:17:03 +0400 Subject: [PATCH 3/9] Lab_1_Kryukov_AI_Excavator --- .../ProjectExcavator/DrawningExcavator.cs | 56 +++++++++---------- .../ProjectExcavator/EntityExcavator.cs | 1 - 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs b/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs index 17571fc..566c90e 100644 --- a/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs +++ b/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs @@ -31,11 +31,11 @@ namespace ProjectExcavator /// /// Ширина прорисовки экскаватора /// - private readonly int _excavatorWidth = 200; + private readonly int _excavatorWidth = 185; /// /// Высота прорисовки экскаватора /// - private readonly int _excavatorHeight = 150; + private readonly int _excavatorHeight = 100; /// /// Инициализация свойств /// @@ -95,7 +95,7 @@ namespace ProjectExcavator break; //вверх case DirectionType.Up: - if (_startPosY - EntityExcavator.Step > -50) + if (_startPosY - EntityExcavator.Step > 0) { _startPosY -= (int)EntityExcavator.Step; } @@ -130,41 +130,41 @@ namespace ProjectExcavator Brush additionalBrush = new SolidBrush(EntityExcavator.AdditionalColor); if (EntityExcavator.BodyKit) { - g.FillRectangle(additionalBrush, _startPosX + 20, _startPosY + 120, 130, 10); - g.DrawLine(pen, _startPosX + 20, _startPosY + 120, _startPosX + 150, _startPosY + 120); + g.FillRectangle(additionalBrush, _startPosX + 20, _startPosY + 70, 130, 10); + g.DrawLine(pen, _startPosX + 20, _startPosY + 70, _startPosX + 150, _startPosY + 70); } //корпус Brush bodyBrush = new SolidBrush(Color.Red); - g.FillRectangle(bodyBrush, _startPosX + 20, _startPosY + 110, 130, 20); - g.FillRectangle(bodyBrush, _startPosX + 100, _startPosY + 70, 30, 40); - g.FillRectangle(bodyBrush, _startPosX + 30, _startPosY + 90, 10, 20); - g.DrawRectangle(pen, _startPosX + 20, _startPosY + 110, 130, 20); - g.DrawRectangle(pen, _startPosX + 100, _startPosY + 70, 30, 40); - g.DrawRectangle(pen, _startPosX + 30, _startPosY + 90, 10, 20); + g.FillRectangle(bodyBrush, _startPosX + 20, _startPosY + 60, 130, 20); + g.FillRectangle(bodyBrush, _startPosX + 100, _startPosY + 20, 30, 40); + g.FillRectangle(bodyBrush, _startPosX + 30, _startPosY + 40, 10, 20); + g.DrawRectangle(pen, _startPosX + 20, _startPosY + 60, 130, 20); + g.DrawRectangle(pen, _startPosX + 100, _startPosY + 20, 30, 40); + g.DrawRectangle(pen, _startPosX + 30, _startPosY + 40, 10, 20); //гусеница Point[] points = { - new Point(_startPosX + 20, _startPosY + 130), - new Point(_startPosX + 15, _startPosY+ 135), - new Point(_startPosX + 15, _startPosY + 145), - new Point(_startPosX + 20, _startPosY + 150), - new Point(_startPosX + 145, _startPosY + 150), - new Point(_startPosX + 150, _startPosY + 145), - new Point(_startPosX + 150, _startPosY + 135), - new Point(_startPosX + 145, _startPosY + 130)}; + new Point(_startPosX + 20, _startPosY + 80), + new Point(_startPosX + 15, _startPosY+ 85), + new Point(_startPosX + 15, _startPosY + 95), + new Point(_startPosX + 20, _startPosY + 100), + new Point(_startPosX + 145, _startPosY + 100), + new Point(_startPosX + 150, _startPosY + 95), + new Point(_startPosX + 150, _startPosY + 85), + new Point(_startPosX + 145, _startPosY + 80)}; g.DrawPolygon(pen, points); - g.DrawEllipse(pen, _startPosX + 20, _startPosY + 130, 20, 20); - g.DrawEllipse(pen, _startPosX + 40, _startPosY + 130, 20, 20); - g.DrawEllipse(pen, _startPosX + 60, _startPosY + 130, 20, 20); - g.DrawEllipse(pen, _startPosX + 80, _startPosY + 130, 20, 20); - g.DrawEllipse(pen, _startPosX + 100, _startPosY + 130, 20, 20); - g.DrawEllipse(pen, _startPosX + 120, _startPosY + 130, 20, 20); + g.DrawEllipse(pen, _startPosX + 20, _startPosY + 80, 20, 20); + g.DrawEllipse(pen, _startPosX + 40, _startPosY + 80, 20, 20); + g.DrawEllipse(pen, _startPosX + 60, _startPosY + 80, 20, 20); + g.DrawEllipse(pen, _startPosX + 80, _startPosY + 80, 20, 20); + g.DrawEllipse(pen, _startPosX + 100, _startPosY + 80, 20, 20); + g.DrawEllipse(pen, _startPosX + 120, _startPosY + 80, 20, 20); //ковш if (EntityExcavator.Backet) { Point[] pointsBacket = { - new Point(_startPosX + 150, _startPosY + 75), - new Point(_startPosX + 150, _startPosY + 135), - new Point(_startPosX + 195, _startPosY + 135), + new Point(_startPosX + 150, _startPosY + 25), + new Point(_startPosX + 150, _startPosY + 85), + new Point(_startPosX + 195, _startPosY + 85), }; g.FillPolygon(additionalBrush, pointsBacket); g.DrawPolygon(pen, pointsBacket); diff --git a/ProjectExcavator/ProjectExcavator/EntityExcavator.cs b/ProjectExcavator/ProjectExcavator/EntityExcavator.cs index 6189140..8581d88 100644 --- a/ProjectExcavator/ProjectExcavator/EntityExcavator.cs +++ b/ProjectExcavator/ProjectExcavator/EntityExcavator.cs @@ -46,7 +46,6 @@ namespace ProjectExcavator /// Дополнительный цвет /// Признак наличия обвеса /// Признак наличия антикрыла - public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool backet) { From d4d3a85d126c4de5d4cc18bc91b300da78341b8f Mon Sep 17 00:00:00 2001 From: 1SooNoo1 Date: Tue, 10 Oct 2023 22:37:31 +0400 Subject: [PATCH 4/9] Lab_1_Kryukov_AI_Excavator --- ProjectExcavator/ProjectExcavator/DrawningExcavator.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs b/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs index 566c90e..ed815ee 100644 --- a/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs +++ b/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs @@ -31,11 +31,11 @@ namespace ProjectExcavator /// /// Ширина прорисовки экскаватора /// - private readonly int _excavatorWidth = 185; + private readonly int _excavatorWidth = 135; /// /// Высота прорисовки экскаватора /// - private readonly int _excavatorHeight = 100; + private readonly int _excavatorHeight = 80; /// /// Инициализация свойств /// From 5977a7ae6b957230165dd4efe9513ce54f801f3e Mon Sep 17 00:00:00 2001 From: 1SooNoo1 Date: Tue, 10 Oct 2023 22:38:08 +0400 Subject: [PATCH 5/9] Lab_1_Kryukov_AI_Excavator --- ProjectExcavator/ProjectExcavator/DrawningExcavator.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs b/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs index ed815ee..c31fe58 100644 --- a/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs +++ b/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs @@ -31,11 +31,11 @@ namespace ProjectExcavator /// /// Ширина прорисовки экскаватора /// - private readonly int _excavatorWidth = 135; + protected readonly int _excavatorWidth = 135; /// /// Высота прорисовки экскаватора /// - private readonly int _excavatorHeight = 80; + protected readonly int _excavatorHeight = 80; /// /// Инициализация свойств /// From 33a39039591fdd37bd2d3ded4098466759f1d6a7 Mon Sep 17 00:00:00 2001 From: 1SooNoo1 Date: Tue, 10 Oct 2023 22:39:01 +0400 Subject: [PATCH 6/9] Lab_1_Kryukov_AI_Excavator --- ProjectExcavator/ProjectExcavator/EntityExcavator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProjectExcavator/ProjectExcavator/EntityExcavator.cs b/ProjectExcavator/ProjectExcavator/EntityExcavator.cs index 8581d88..afd0a6a 100644 --- a/ProjectExcavator/ProjectExcavator/EntityExcavator.cs +++ b/ProjectExcavator/ProjectExcavator/EntityExcavator.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace ProjectExcavator { - internal class EntityExcavator + public class EntityExcavator { // /// Скорость From 64ba213971e259a58b67449321e4fd2808f858b7 Mon Sep 17 00:00:00 2001 From: 1SooNoo1 Date: Tue, 10 Oct 2023 22:59:12 +0400 Subject: [PATCH 7/9] Lab_1_Kryukov_AI_Excavator --- ProjectExcavator/ProjectExcavator/DrawningExcavator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs b/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs index c31fe58..6769c3c 100644 --- a/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs +++ b/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace ProjectExcavator { - internal class DrawningExcavator + public class DrawningExcavator { /// /// Класс-сущность From c7478ab5f81174ccfe3505d872223ba448b605ce Mon Sep 17 00:00:00 2001 From: 1SooNoo1 Date: Tue, 10 Oct 2023 23:34:30 +0400 Subject: [PATCH 8/9] =?UTF-8?q?=D0=BF=D0=BE=D0=BC=D0=B5=D0=BD=D1=8F=D0=BB?= =?UTF-8?q?=20=D1=86=D0=B2=D0=B5=D1=82=20=D0=BA=D0=BE=D1=80=D0=BF=D1=83?= =?UTF-8?q?=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectExcavator/ProjectExcavator/DrawningExcavator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs b/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs index 6769c3c..7f55c69 100644 --- a/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs +++ b/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs @@ -134,7 +134,7 @@ namespace ProjectExcavator g.DrawLine(pen, _startPosX + 20, _startPosY + 70, _startPosX + 150, _startPosY + 70); } //корпус - Brush bodyBrush = new SolidBrush(Color.Red); + Brush bodyBrush = new SolidBrush(EntityExcavator.BodyColor); g.FillRectangle(bodyBrush, _startPosX + 20, _startPosY + 60, 130, 20); g.FillRectangle(bodyBrush, _startPosX + 100, _startPosY + 20, 30, 40); g.FillRectangle(bodyBrush, _startPosX + 30, _startPosY + 40, 10, 20); From e96e7debf3a398d78a942082c7cd35d98963b033 Mon Sep 17 00:00:00 2001 From: 1SooNoo1 Date: Sun, 22 Oct 2023 15:51:47 +0400 Subject: [PATCH 9/9] =?UTF-8?q?=D0=BF=D0=BE=D1=84=D0=B8=D0=BA=D1=81=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BA=D0=BE=D0=BD=D1=84=D0=BB=D0=B8=D0=BA=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectExcavator/DrawningExcavator.cs | 95 ++++++++++++++----- .../ProjectExcavator/EntityExcavator.cs | 6 +- 2 files changed, 71 insertions(+), 30 deletions(-) diff --git a/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs b/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs index 96bc3fc..7dd58fa 100644 --- a/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs +++ b/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs @@ -38,6 +38,43 @@ namespace ProjectExcavator.DrawningObjects /// protected readonly int _excavatorHeight = 80; /// + /// Координата X объекта + /// + public int GetPosX => _startPosX; + /// + /// Координата Y объекта + /// + public int GetPosY => _startPosY; + /// Ширина объекта + /// + public int GetWidth => _excavatorWidth; + /// + /// Высота объекта + /// + public int GetHeight => _excavatorHeight; + /// + /// Конструктор + /// + /// Скорость + /// Вес + /// Основной цвет + /// Ширина картинки + /// Высота картинки + public DrawningExcavator(int speed, double weight, + Color bodyColor, + int width, int height) + { + _pictureWidth = width; + _pictureHeight = height; + if(_pictureHeight < _excavatorHeight || _pictureWidth < _excavatorWidth) + { + return; + } + _pictureWidth = width; + _pictureHeight = height; + EntityExcavator = new EntityExcavator(speed,weight,bodyColor); + } + /// /// Конструктор /// /// Скорость @@ -47,20 +84,20 @@ namespace ProjectExcavator.DrawningObjects /// Высота картинки /// Ширина прорисовки экскаватора /// Высота прорисовки экскаватора - protected DrawningExcavator(int speed, double weight, - Color bodyColor, - int width, int height, + protected DrawningExcavator(int speed, double weight, + Color bodyColor, + int width, int height, int excavatorWidth, int excavatorHeight) { _pictureWidth = width; _pictureHeight = height; - if(_pictureHeight < _excavatorHeight || _pictureWidth < _excavatorWidth) + _excavatorWidth = excavatorWidth; + _excavatorHeight = excavatorHeight; + if (_pictureHeight < _excavatorHeight || _pictureWidth < _excavatorWidth) { - return false; + return; } - EntityExcavator = new EntityExcavator(); - EntityExcavator.Init(speed, weight, bodyColor, additionalColor, bodyKit, backet); - return true; + EntityExcavator = new EntityExcavator(speed, weight, bodyColor); } /// /// Установка позиции @@ -74,6 +111,30 @@ namespace ProjectExcavator.DrawningObjects _startPosY = Math.Min(y,_pictureHeight - _excavatorHeight); + } + /// + /// Проверка, что объект может переместится по указанному направлению + /// + /// Направление + /// true - можно переместится по указанному направлению + public bool CanMove(DirectionType direction) + { + if (EntityExcavator == null) + { + return false; + } + return direction switch + { + //влево + DirectionType.Left => _startPosX - EntityExcavator.Step > 0, + //вверх + DirectionType.Up => _startPosY - EntityExcavator.Step > 0, + //вправо + DirectionType.Right => _startPosX + EntityExcavator.Step < _pictureWidth - _excavatorWidth, + //вниз + DirectionType.Down => _startPosY + EntityExcavator.Step < _pictureHeight - _excavatorHeight, + _ => false, + }; } /// /// Изменение направления перемещения @@ -122,12 +183,6 @@ namespace ProjectExcavator.DrawningObjects return; } Pen pen = new(Color.Black); - Brush additionalBrush = new SolidBrush(EntityExcavator.AdditionalColor); - if (EntityExcavator.BodyKit) - { - g.FillRectangle(additionalBrush, _startPosX + 20, _startPosY + 70, 130, 10); - g.DrawLine(pen, _startPosX + 20, _startPosY + 70, _startPosX + 150, _startPosY + 70); - } //корпус Brush bodyBrush = new SolidBrush(EntityExcavator.BodyColor); g.FillRectangle(bodyBrush, _startPosX + 20, _startPosY + 60, 130, 20); @@ -153,17 +208,7 @@ namespace ProjectExcavator.DrawningObjects g.DrawEllipse(pen, _startPosX + 80, _startPosY + 80, 20, 20); g.DrawEllipse(pen, _startPosX + 100, _startPosY + 80, 20, 20); g.DrawEllipse(pen, _startPosX + 120, _startPosY + 80, 20, 20); - //ковш - if (EntityExcavator.Backet) - { - Point[] pointsBacket = { - new Point(_startPosX + 150, _startPosY + 25), - new Point(_startPosX + 150, _startPosY + 85), - new Point(_startPosX + 195, _startPosY + 85), - }; - g.FillPolygon(additionalBrush, pointsBacket); - g.DrawPolygon(pen, pointsBacket); - } + } } } diff --git a/ProjectExcavator/ProjectExcavator/EntityExcavator.cs b/ProjectExcavator/ProjectExcavator/EntityExcavator.cs index c2acec2..4a0a157 100644 --- a/ProjectExcavator/ProjectExcavator/EntityExcavator.cs +++ b/ProjectExcavator/ProjectExcavator/EntityExcavator.cs @@ -30,11 +30,7 @@ namespace ProjectExcavator.Entities /// Скорость /// Вес экскаватора /// Основной цвет - /// Дополнительный цвет - /// Признак наличия обвеса - /// Признак наличия антикрыла - public void Init(int speed, double weight, Color bodyColor, Color - additionalColor, bool bodyKit, bool backet) + public EntityExcavator(int speed, double weight, Color bodyColor) { Speed = speed; Weight = weight;