From e2a51ace3c4183e26f4edf585cf2b4266702df4f 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, 18 Oct 2022 19:56:18 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B1=D0=B0=20=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ningWarmlyShip.cs => DrawingWarmlyShip.cs} | 26 +++++++++---------- WarmlyShip/WarmlyShip/DrawningMotorShip.cs | 2 +- WarmlyShip/WarmlyShip/DrawningObjectShip.cs | 4 +-- WarmlyShip/WarmlyShip/EntityWarmlyShip.cs | 1 + WarmlyShip/WarmlyShip/FormClass.cs | 4 +-- WarmlyShip/WarmlyShip/FormMap.cs | 4 +-- 6 files changed, 21 insertions(+), 20 deletions(-) rename WarmlyShip/WarmlyShip/{DrawningWarmlyShip.cs => DrawingWarmlyShip.cs} (83%) diff --git a/WarmlyShip/WarmlyShip/DrawningWarmlyShip.cs b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs similarity index 83% rename from WarmlyShip/WarmlyShip/DrawningWarmlyShip.cs rename to WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs index b6df0c9..de2d7a2 100644 --- a/WarmlyShip/WarmlyShip/DrawningWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs @@ -6,29 +6,29 @@ using System.Threading.Tasks; namespace WarmlyShip { - internal class DrawningWarmlyShip + internal class DrawingWarmlyShip { public EntityWarmlyShip warmlyShip { protected set; get; } //Класс-сущность - protected float _startPosX; //Координаты отрисовки по оси x - protected float _startPosY; //Координаты отрисовки по оси y + public float _startPosX; //Координаты отрисовки по оси x + public float _startPosY; //Координаты отрисовки по оси y private int? _pictureWidth = null; //Ширина окна private int? _pictureHeight = null; //Высота окна protected readonly int _warmlyShipWidth = 125; //Ширина отрисовки корабля protected readonly int _warmlyShipHeight = 50; //Высота отрисовки корабля - //Конструктор класса - public DrawningWarmlyShip(int speed, float weight, Color bodyColor) + //Инициализация + public DrawingWarmlyShip(int speed, float weight, Color bodyColor) { warmlyShip = new EntityWarmlyShip(speed, weight, bodyColor); } - protected DrawningWarmlyShip(int speed, float weight, Color bodyColor, int warmlyWidth, int warmlyHeight) : this(speed, weight, bodyColor) + protected DrawingWarmlyShip(int speed, float weight, Color bodyColor, int warmlyWidth, int warmlyHeight) : this(speed, weight, bodyColor) { _warmlyShipWidth = warmlyWidth; _warmlyShipHeight = warmlyHeight; } - //Начальная позиция коробля + //Начальные коордитанты public void SetPosition(int x, int y, int width, int height) { if (width < _warmlyShipWidth || height < _warmlyShipHeight) return; @@ -39,7 +39,7 @@ namespace WarmlyShip _pictureHeight = height; } - //Функция передвижения объекта + //Движение транспорта по координатам public void MoveTransport(Direction direction) { if (!_pictureWidth.HasValue || !_pictureHeight.HasValue) return; @@ -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 + 50)), - new Point((int)(_startPosX + 25), (int)(_startPosY +50)) + new Point((int)(_startPosX + _warmlyShipWidth - 25), (int)(_startPosY + _warmlyShipHeight)), + new Point((int)(_startPosX + 25), (int)(_startPosY + _warmlyShipHeight)) }); 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 + 50)), - new Point((int)(_startPosX + 25), (int)(_startPosY + 50)) + new Point((int)(_startPosX + _warmlyShipWidth - 25), (int)(_startPosY + _warmlyShipHeight)), + new Point((int)(_startPosX + 25), (int)(_startPosY + _warmlyShipHeight)) }); g.DrawRectangle(pen, _startPosX + _warmlyShipWidth / 5, _startPosY, _warmlyShipWidth * 3 / 5, 20); g.DrawEllipse(new(Color.Blue, 2), _startPosX + _warmlyShipWidth / 5, _startPosY + 25, 20, 20); @@ -93,7 +93,7 @@ namespace WarmlyShip g.DrawEllipse(new(Color.Blue, 2), _startPosX + _warmlyShipWidth * 2 / 5 + 2.5f, _startPosY + 25, 20, 20); } - //Изменение границ отрисовки + //Изменение границ отрисовки public void ChangeBorders(int width, int height) { _pictureWidth = width; diff --git a/WarmlyShip/WarmlyShip/DrawningMotorShip.cs b/WarmlyShip/WarmlyShip/DrawningMotorShip.cs index dd551ca..0d17867 100644 --- a/WarmlyShip/WarmlyShip/DrawningMotorShip.cs +++ b/WarmlyShip/WarmlyShip/DrawningMotorShip.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace WarmlyShip { - internal class DrawningMotorShip : DrawningWarmlyShip + internal class DrawningMotorShip : DrawingWarmlyShip { public DrawningMotorShip(int speed, float weight, Color bodyColor, Color dopColor, bool tubes, bool cistern) : base(speed, weight, bodyColor, 150, 75) { diff --git a/WarmlyShip/WarmlyShip/DrawningObjectShip.cs b/WarmlyShip/WarmlyShip/DrawningObjectShip.cs index eaecf5e..e9c2b8a 100644 --- a/WarmlyShip/WarmlyShip/DrawningObjectShip.cs +++ b/WarmlyShip/WarmlyShip/DrawningObjectShip.cs @@ -8,9 +8,9 @@ namespace WarmlyShip { internal class DrawningObjectShip : IDrawningObject { - private DrawningWarmlyShip _warmlyShip = null; + private DrawingWarmlyShip _warmlyShip = null; - public DrawningObjectShip(DrawningWarmlyShip warmlyShip) + public DrawningObjectShip(DrawingWarmlyShip warmlyShip) { _warmlyShip = warmlyShip; } diff --git a/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs b/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs index 0049f81..1da24c8 100644 --- a/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs @@ -13,6 +13,7 @@ namespace WarmlyShip public Color BodyColor { get; private set; } //Цвет public float Step => Speed * 100 / Weight; //Шаг при перемещении + //Инициализация public EntityWarmlyShip(int speed, float weight, Color bodyColor) { Random random = new Random(); diff --git a/WarmlyShip/WarmlyShip/FormClass.cs b/WarmlyShip/WarmlyShip/FormClass.cs index 9348d08..5d1bf94 100644 --- a/WarmlyShip/WarmlyShip/FormClass.cs +++ b/WarmlyShip/WarmlyShip/FormClass.cs @@ -2,7 +2,7 @@ namespace WarmlyShip { public partial class FormClass : Form { - private DrawningWarmlyShip _warmlyShip; + private DrawingWarmlyShip _warmlyShip; public FormClass() { @@ -29,7 +29,7 @@ namespace WarmlyShip private void ButtonCreate_Click(object sender, EventArgs e) { Random random = new Random(); - _warmlyShip = new DrawningWarmlyShip(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256))); + _warmlyShip = new DrawingWarmlyShip(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256))); SetData(); Draw(); } diff --git a/WarmlyShip/WarmlyShip/FormMap.cs b/WarmlyShip/WarmlyShip/FormMap.cs index 57b6071..3d6c502 100644 --- a/WarmlyShip/WarmlyShip/FormMap.cs +++ b/WarmlyShip/WarmlyShip/FormMap.cs @@ -20,7 +20,7 @@ namespace WarmlyShip _abstractMap = new SimpleMap(); } - private void SetData(DrawningWarmlyShip warmlyShip) + private void SetData(DrawingWarmlyShip warmlyShip) { toolStripStatusSpeed.Text = $"Скорость: {warmlyShip.warmlyShip?.Speed}"; toolStripStatusWeight.Text = $"Вес: {warmlyShip.warmlyShip?.Weight}"; @@ -32,7 +32,7 @@ namespace WarmlyShip private void ButtonCreate_Click(object sender, EventArgs e) { Random random = new Random(); - var warmlyShip = new DrawningWarmlyShip(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256))); + var warmlyShip = new DrawingWarmlyShip(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256))); SetData(warmlyShip); }