From 1f0eb7baa586ccdedefee88752ed11f6f596b53b Mon Sep 17 00:00:00 2001 From: Pyro <75787064+pyro-p@users.noreply.github.com> Date: Sun, 18 Feb 2024 18:11:24 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=20=E2=84=961=20(=D1=83=D1=81=D0=BB=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D1=91=D0=BD=D0=BD=D0=B0=D1=8F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectMotorBoat/DrawingMotorBoat.cs | 44 ++++++++++++++----- .../ProjectMotorBoat/EntityMotorBoat.cs | 28 +++++++++--- .../ProjectMotorBoat/FormMotorBoat.cs | 2 +- 3 files changed, 56 insertions(+), 18 deletions(-) diff --git a/ProjectMotorBoat/ProjectMotorBoat/DrawingMotorBoat.cs b/ProjectMotorBoat/ProjectMotorBoat/DrawingMotorBoat.cs index b379b19..5b0c30f 100644 --- a/ProjectMotorBoat/ProjectMotorBoat/DrawingMotorBoat.cs +++ b/ProjectMotorBoat/ProjectMotorBoat/DrawingMotorBoat.cs @@ -13,6 +13,11 @@ public class DrawingMotorBoat /// public EntityMotorBoat? EntityMotorBoat { get; private set; } + /// + /// Класс-сущность + /// + public EntityPaddle? EntityPaddle { get; private set; } + /// /// Ширина окна /// @@ -54,10 +59,12 @@ public class DrawingMotorBoat /// /// /// - public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool inboardEngine, bool paddle, bool protectiveGlass) + public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool inboardEngine, bool protectiveGlass, int paddle) { EntityMotorBoat = new EntityMotorBoat(); - EntityMotorBoat.Init(speed, weight, bodyColor, additionalColor, inboardEngine, paddle, protectiveGlass); + EntityMotorBoat.Init(speed, weight, bodyColor, additionalColor, inboardEngine, protectiveGlass); + EntityPaddle = new EntityPaddle(); + EntityPaddle.Init(paddle); _pictureWidth = null; _pictureHeight = null; _startPosX = null; @@ -245,17 +252,32 @@ public class DrawingMotorBoat } // Вёсла - if (EntityMotorBoat.Paddle) + if (EntityPaddle.Paddle != 0) { - g.DrawRectangle(pen, _startPosX.Value + 32, _startPosY.Value + 3, 2, 17); - g.DrawRectangle(pen, _startPosX.Value + 32, _startPosY.Value + 30, 2, 17); - g.FillRectangle(additionalBrush, _startPosX.Value + 33, _startPosY.Value + 3, 1, 17); - g.FillRectangle(additionalBrush, _startPosX.Value + 33, _startPosY.Value + 31, 1, 16); + if (EntityPaddle.Paddle >= 1) + { + g.DrawRectangle(pen, _startPosX.Value + 32, _startPosY.Value + 3, 2, 17); + g.FillRectangle(additionalBrush, _startPosX.Value + 33, _startPosY.Value + 3, 1, 17); - g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value, 6, 8); - g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value + 42, 6, 8); - g.FillEllipse(additionalBrush, _startPosX.Value + 30, _startPosY.Value, 6, 8); - g.FillEllipse(additionalBrush, _startPosX.Value + 30, _startPosY.Value + 42, 6, 8); + g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value, 6, 8); + g.FillEllipse(additionalBrush, _startPosX.Value + 30, _startPosY.Value, 6, 8); + } + if (EntityPaddle.Paddle >= 2) + { + g.DrawRectangle(pen, _startPosX.Value + 27, _startPosY.Value + 30, 2, 17); + g.FillRectangle(additionalBrush, _startPosX.Value + 28, _startPosY.Value + 31, 1, 16); + + g.DrawEllipse(pen, _startPosX.Value + 25, _startPosY.Value + 42, 6, 8); + g.FillEllipse(additionalBrush, _startPosX.Value + 25, _startPosY.Value + 42, 6, 8); + } + if (EntityPaddle.Paddle == 3) + { + g.DrawRectangle(pen, _startPosX.Value + 36, _startPosY.Value + 30, 2, 17); + g.FillRectangle(additionalBrush, _startPosX.Value + 37, _startPosY.Value + 31, 1, 16); + + g.DrawEllipse(pen, _startPosX.Value + 34, _startPosY.Value + 42, 6, 8); + g.FillEllipse(additionalBrush, _startPosX.Value + 34, _startPosY.Value + 42, 6, 8); + } } // Защитное стекло diff --git a/ProjectMotorBoat/ProjectMotorBoat/EntityMotorBoat.cs b/ProjectMotorBoat/ProjectMotorBoat/EntityMotorBoat.cs index 9d238ad..61179d9 100644 --- a/ProjectMotorBoat/ProjectMotorBoat/EntityMotorBoat.cs +++ b/ProjectMotorBoat/ProjectMotorBoat/EntityMotorBoat.cs @@ -30,10 +30,10 @@ public class EntityMotorBoat /// public bool InboardEngine { get; private set; } - /// - /// Признак (опция) наличия вёсел - /// - public bool Paddle { get; private set; } + ///// + ///// Признак (опция) наличия вёсел + ///// + //public int Paddle { get; private set; } /// /// Возможность глиссирования @@ -55,14 +55,30 @@ public class EntityMotorBoat /// /// /// - public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool inboardEngine, bool paddle, bool protectiveGlass) + public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool inboardEngine, bool protectiveGlass) { Speed = speed; Weight = weight; BodyColor = bodyColor; AdditionalColor = additionalColor; InboardEngine = inboardEngine; - Paddle = paddle; ProtectiveGlass = protectiveGlass; } +} + +public class EntityPaddle +{ + /// + /// Признак (опция) наличия вёсел + /// + public int Paddle { get; private set; } + + /// + /// Инициализация полей объекта-класса вёсел + /// + /// + public void Init(int paddle) + { + Paddle = paddle; + } } \ No newline at end of file diff --git a/ProjectMotorBoat/ProjectMotorBoat/FormMotorBoat.cs b/ProjectMotorBoat/ProjectMotorBoat/FormMotorBoat.cs index b12a68c..705ed40 100644 --- a/ProjectMotorBoat/ProjectMotorBoat/FormMotorBoat.cs +++ b/ProjectMotorBoat/ProjectMotorBoat/FormMotorBoat.cs @@ -47,7 +47,7 @@ public partial class FormMotorBoat : Form 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))); + random.Next(0, 4)); _drawingMotorBoat.SetPictureSize(pictureBoxMotorBoat.Width, pictureBoxMotorBoat.Height); _drawingMotorBoat.SetPosition(random.Next(10, 100), random.Next(10, 100));