From 289e6b619251a911b2b37e12ec5e834291983115 Mon Sep 17 00:00:00 2001 From: bulatova_karina Date: Tue, 26 Sep 2023 13:29:10 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B8=D0=B4=D1=83=D0=BC=D0=B0?= =?UTF-8?q?=D0=BB=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs | 65 ++++++++++++---------- WarmlyShip/WarmlyShip/EntityWarmlyShip.cs | 30 ++++------ WarmlyShip/WarmlyShip/FormWarmlyShip.cs | 11 ++-- 3 files changed, 53 insertions(+), 53 deletions(-) diff --git a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs index ce8b835..12347d2 100644 --- a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs @@ -24,43 +24,44 @@ namespace WarmlyShip /// private int _pictureHeight; /// - /// Левая координата прорисовки автомобиля + /// Левая координата прорисовки теплохода /// private int _startPosX; /// - /// Верхняя кооридната прорисовки автомобиля + /// Верхняя кооридната прорисовки теплохода /// private int _startPosY; /// /// Ширина прорисовки теплохода /// - private readonly int _WarmlyShipWidth = 170; + private readonly int _WarmlyShipWidth = 180; /// /// Высота прорисовки теплохода /// - private readonly int _WarmlyShipHeight = 180; + private readonly int _WarmlyShipHeight = 185; /// /// Инициализация свойств /// /// Скорость /// Вес - /// Цвет кузова + /// Цвет корпуса /// Дополнительный цвет - /// Признак наличия обвеса - /// Признак наличия антикрыла - /// Признак наличия гоночной полосы + /// Признак наличия труб + /// Признак наличия отсека для топлива /// Ширина картинки /// Высота картинки /// true - объект создан, false - проверка не пройдена,нельзя создать объект в этих размерах -public bool Init(int speed, double weight, Color bodyColor, Color -additionalColor, bool bodyKit, bool wing, bool sportLine, int width, int height) + public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool pipes, bool section, + int width, int height) { - // TODO: Продумать проверки + if (width <_WarmlyShipWidth || height <_WarmlyShipHeight) + { + return false; + } _pictureWidth = width; _pictureHeight = height; EntityWarmlyShip = new EntityWarmlyShip(); - EntityWarmlyShip.Init(speed, weight, bodyColor, additionalColor, - bodyKit, wing, sportLine); + EntityWarmlyShip.Init(speed, weight, bodyColor, additionalColor, pipes, section); return true; } /// @@ -70,9 +71,11 @@ additionalColor, bool bodyKit, bool wing, bool sportLine, int width, int height) /// Координата Y public void SetPosition(int x, int y) { - // TODO: Изменение x, y - _startPosX = x; - _startPosY = y; + if (x >= 0 && x + _WarmlyShipWidth <= _pictureWidth && y >= 0 && y + _WarmlyShipHeight <= _pictureHeight) + { + _startPosX = x; + _startPosY = y; + } } /// /// Изменение направления перемещения @@ -132,26 +135,32 @@ additionalColor, bool bodyKit, bool wing, bool sportLine, int width, int height) //корпус теплохода Point[] hull = new Point[] { - new Point(_startPosX + 10, _startPosY + 115), - new Point(_startPosX + 190, _startPosY + 115), - new Point(_startPosX + 150, _startPosY + 190), - new Point(_startPosX + 50, _startPosY + 190), + new Point(_startPosX, _startPosY + 110), + new Point(_startPosX + 180, _startPosY + 110), + new Point(_startPosX + 140, _startPosY + 185), + new Point(_startPosX + 40, _startPosY + 185), }; g.FillPolygon(additionalBrush, hull); g.DrawPolygon(pen, hull); Brush bra = new SolidBrush(EntityWarmlyShip.AdditionalColor); //палуба - g.FillRectangle(bra, _startPosX + 35, _startPosY + 85, 130, 30); - g.DrawRectangle(pen, _startPosX + 35, _startPosY + 85, 130, 30); + g.FillRectangle(bra, _startPosX + 25, _startPosY + 80, 130, 30); + g.DrawRectangle(pen, _startPosX + 25, _startPosY + 80, 130, 30); //отсек для топлива Brush brGray = new SolidBrush(Color.Gray); - g.FillEllipse(brGray, _startPosX + 140, _startPosY + 130, 20, 20); - g.DrawEllipse(pen, _startPosX + 140, _startPosY + 130, 20, 20); + if (EntityWarmlyShip.Section) + { + g.FillEllipse(brGray, _startPosX + 130, _startPosY + 130, 20, 20); + g.DrawEllipse(pen, _startPosX + 130, _startPosY + 130, 20, 20); + } //трубы - g.FillRectangle(additionalBrush, _startPosX + 65, _startPosY + 5, 25, 80); - g.DrawRectangle(pen, _startPosX + 65, _startPosY + 5, 25, 80); - g.FillRectangle(additionalBrush, _startPosX + 100, _startPosY + 25, 25, 60); - g.DrawRectangle(pen, _startPosX + 100, _startPosY + 25, 25, 60); + if (EntityWarmlyShip.Pipes) + { + g.FillRectangle(brGray, _startPosX + 55, _startPosY, 25, 80); + g.DrawRectangle(pen, _startPosX + 55, _startPosY, 25, 80); + g.FillRectangle(brGray, _startPosX + 90, _startPosY + 20, 25, 60); + g.DrawRectangle(pen, _startPosX + 90, _startPosY + 20, 25, 60); + } //якорь g.DrawLine(anchor, new Point(_startPosX + 50, _startPosY + 130), new Point(_startPosX + 50,_startPosY + 150)); g.DrawLine(anchor, new Point(_startPosX + 40, _startPosY + 140), new Point(_startPosX + 60, _startPosY + 140)); diff --git a/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs b/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs index 94f5114..6e78824 100644 --- a/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs @@ -25,41 +25,35 @@ namespace WarmlyShip /// public Color AdditionalColor { get; private set; } /// - /// Признак (опция) наличия обвеса + /// Признак (опция) наличия труб /// - public bool BodyKit { get; private set; } + public bool Pipes { get; private set; } /// - /// Признак (опция) наличия антикрыла + /// Признак (опция) наличия отсека для топлива /// - public bool Wing { get; private set; } + public bool Section { get; private set; } /// - /// Признак (опция) наличия гоночной полосы - /// - public bool SportLine { get; private set; } - /// - /// Шаг перемещения автомобиля + /// Шаг перемещения теплохода /// public double Step => (double)Speed * 100 / Weight; /// - /// Инициализация полей объекта-класса спортивного автомобиля + /// Инициализация полей объекта-класса теплохода /// /// Скорость - /// Вес автомобиля + /// Вес теплохода /// Основной цвет /// Дополнительный цвет - /// Признак наличия обвеса - /// Признак наличия антикрыла - /// Признак наличия гоночной полосы + /// Признак наличия труб + /// Признак наличия отсека для топлива public void Init(int speed, double weight, Color bodyColor, Color - additionalColor, bool bodyKit, bool wing, bool sportLine) + additionalColor, bool pipes, bool section) { Speed = speed; Weight = weight; BodyColor = bodyColor; AdditionalColor = additionalColor; - BodyKit = bodyKit; - Wing = wing; - SportLine = sportLine; + Pipes = pipes; + Section = section; } } } diff --git a/WarmlyShip/WarmlyShip/FormWarmlyShip.cs b/WarmlyShip/WarmlyShip/FormWarmlyShip.cs index 706e1fa..74a8a85 100644 --- a/WarmlyShip/WarmlyShip/FormWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/FormWarmlyShip.cs @@ -44,10 +44,9 @@ namespace WarmlyShip 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)), + Convert.ToBoolean(random.Next(0, 2)), pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height); - _drawingWarmlyShip.SetPosition(random.Next(10, 100), - random.Next(10, 100)); + _drawingWarmlyShip.SetPosition(random.Next(10, 100), random.Next(10, 100)); Draw(); } /// @@ -92,12 +91,10 @@ namespace WarmlyShip 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)), + Convert.ToBoolean(random.Next(0, 2)), pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height); - _drawingWarmlyShip.SetPosition(random.Next(10, 100), - random.Next(10, 100)); + _drawingWarmlyShip.SetPosition(random.Next(10, 100), random.Next(10, 100)); Draw(); - } private void ButtonMove_Click(object sender, EventArgs e)