From e51d851a3204978d119dd3b7a09438dd9e87cc63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=20=D0=91=D0=BE=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Tue, 4 Oct 2022 21:21:25 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarmlyShip/WarmlyShip/DrawningMotorShip.cs | 16 +++++++++++++--- WarmlyShip/WarmlyShip/DrawningWarmlyShip.cs | 12 ++++++------ WarmlyShip/WarmlyShip/FormClass.cs | 4 ++-- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/WarmlyShip/WarmlyShip/DrawningMotorShip.cs b/WarmlyShip/WarmlyShip/DrawningMotorShip.cs index 7ef8c2c..dd551ca 100644 --- a/WarmlyShip/WarmlyShip/DrawningMotorShip.cs +++ b/WarmlyShip/WarmlyShip/DrawningMotorShip.cs @@ -8,7 +8,7 @@ namespace WarmlyShip { internal class DrawningMotorShip : DrawningWarmlyShip { - public DrawningMotorShip(int speed, float weight, Color bodyColor, Color dopColor, bool tubes, bool cistern) : base(speed, weight, bodyColor, 110, 60) + public DrawningMotorShip(int speed, float weight, Color bodyColor, Color dopColor, bool tubes, bool cistern) : base(speed, weight, bodyColor, 150, 75) { warmlyShip = new EntityMotorShip(speed, weight, bodyColor, dopColor, tubes , cistern); } @@ -20,14 +20,24 @@ namespace WarmlyShip return; } + Pen pen = new(Color.Black, 2); + Brush dopBrush = new SolidBrush(motorShip.DopColor); if (motorShip.Tubes) { - + g.FillRectangle(dopBrush, _startPosX + _warmlyShipWidth / 5, _startPosY, _warmlyShipWidth / 5, _warmlyShipHeight / 2); + g.DrawRectangle(pen, _startPosX + _warmlyShipWidth / 5, _startPosY, _warmlyShipWidth / 5, _warmlyShipHeight / 2); + g.FillRectangle(dopBrush, _startPosX + _warmlyShipWidth * 3 / 5, _startPosY, _warmlyShipWidth / 5, _warmlyShipHeight / 2); + g.DrawRectangle(pen, _startPosX + _warmlyShipWidth * 3 / 5, _startPosY, _warmlyShipWidth / 5, _warmlyShipHeight / 2); } + _startPosY += 25; + base.DrawTransport(g); + _startPosY -= 25; + if (motorShip.Cistern) { - + g.FillEllipse(dopBrush, _startPosX, _startPosY + 25, 25, 20); + g.DrawEllipse(pen, _startPosX, _startPosY + 25, 25, 20); } } } diff --git a/WarmlyShip/WarmlyShip/DrawningWarmlyShip.cs b/WarmlyShip/WarmlyShip/DrawningWarmlyShip.cs index b3e03f1..74f0c7b 100644 --- a/WarmlyShip/WarmlyShip/DrawningWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/DrawningWarmlyShip.cs @@ -13,8 +13,8 @@ namespace WarmlyShip protected float _startPosY; //Координаты отрисовки по оси y private int? _pictureWidth = null; //Ширина окна private int? _pictureHeight = null; //Высота окна - private readonly int _warmlyShipWidth = 125; //Ширина отрисовки корабля - private readonly int _warmlyShipHeight = 50; //Высота отрисовки корабля + protected readonly int _warmlyShipWidth = 125; //Ширина отрисовки корабля + protected readonly int _warmlyShipHeight = 50; //Высота отрисовки корабля //Конструктор класса public DrawningWarmlyShip(int speed, float weight, Color bodyColor) @@ -73,8 +73,8 @@ namespace WarmlyShip { new Point((int)(_startPosX), (int)(_startPosY + 20)), new Point((int)(_startPosX + _warmlyShipWidth), (int)(_startPosY + 20)), - new Point((int)(_startPosX + _warmlyShipWidth - 25), (int)(_startPosY + _warmlyShipHeight)), - new Point((int)(_startPosX + 25), (int)(_startPosY + _warmlyShipHeight)) + new Point((int)(_startPosX + _warmlyShipWidth - 25), (int)(_startPosY + 50)), + new Point((int)(_startPosX + 25), (int)(_startPosY +50)) }); g.FillRectangle(brush, _startPosX + _warmlyShipWidth / 5, _startPosY, _warmlyShipWidth * 3 / 5, 20); g.FillEllipse(new SolidBrush(Color.Aquamarine), _startPosX + _warmlyShipWidth / 5, _startPosY + 25, 20, 20); @@ -84,8 +84,8 @@ namespace WarmlyShip { new Point((int)(_startPosX), (int)(_startPosY + 20)), new Point((int)(_startPosX + _warmlyShipWidth), (int)(_startPosY + 20)), - new Point((int)(_startPosX + _warmlyShipWidth - 25), (int)(_startPosY + _warmlyShipHeight)), - new Point((int)(_startPosX + 25), (int)(_startPosY + _warmlyShipHeight)) + new Point((int)(_startPosX + _warmlyShipWidth - 25), (int)(_startPosY + 50)), + new Point((int)(_startPosX + 25), (int)(_startPosY + 50)) }); g.DrawRectangle(pen, _startPosX + _warmlyShipWidth / 5, _startPosY, _warmlyShipWidth * 3 / 5, 20); g.DrawEllipse(new(Color.Blue, 2), _startPosX + _warmlyShipWidth / 5, _startPosY + 25, 20, 20); diff --git a/WarmlyShip/WarmlyShip/FormClass.cs b/WarmlyShip/WarmlyShip/FormClass.cs index c28b163..9348d08 100644 --- a/WarmlyShip/WarmlyShip/FormClass.cs +++ b/WarmlyShip/WarmlyShip/FormClass.cs @@ -20,7 +20,7 @@ namespace WarmlyShip private void SetData() { Random random = new Random(); - _warmlyShip.SetPosition(random.Next(pictureBox.Width - 150, pictureBox.Width - 125), random.Next(pictureBox.Height - 150, pictureBox.Height - 50), pictureBox.Width, pictureBox.Height); + _warmlyShip.SetPosition(random.Next(0, 100), random.Next(0, 100), pictureBox.Width, pictureBox.Height); toolStripStatusSpeed.Text = $": {_warmlyShip.warmlyShip?.Speed}"; toolStripStatusWeight.Text = $": {_warmlyShip.warmlyShip?.Weight}"; toolStripStatusLabelBodyColor.Text = $": {_warmlyShip.warmlyShip?.BodyColor}"; @@ -67,7 +67,7 @@ namespace WarmlyShip _warmlyShip = new DrawningMotorShip(random.Next(100, 300), random.Next(1000, 3000), 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, 1)), Convert.ToBoolean(random.Next(0, 1))); + Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); SetData(); Draw(); }