From 8290c1632ea8dd2e57e0711ae31599d94390285a Mon Sep 17 00:00:00 2001 From: MayDayR Date: Tue, 14 Nov 2023 13:00:37 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C=20'D?= =?UTF-8?q?oubleDeckerBus/DrawingBus.cs'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DoubleDeckerBus/DrawingBus.cs | 197 ---------------------------------- 1 file changed, 197 deletions(-) delete mode 100644 DoubleDeckerBus/DrawingBus.cs diff --git a/DoubleDeckerBus/DrawingBus.cs b/DoubleDeckerBus/DrawingBus.cs deleted file mode 100644 index 545fa19..0000000 --- a/DoubleDeckerBus/DrawingBus.cs +++ /dev/null @@ -1,197 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DoubleDeckerBus -{ - internal class DrawingBus - { - /// - /// Класс-сущность - /// - public EntityDoubleDeckerBus? EntityDoubleDeckerBus { get; private set; } - /// - /// Ширина окна - /// - private int _pictureWidth; - /// - /// Высота окна - /// - private int _pictureHeight; - /// - /// Левая координата прорисовки автобуса - /// - private int _startPosX; - /// - /// Верхняя кооридната прорисовки автобуса - /// - private int _startPosY; - /// - /// Ширина прорисовки автобуса - /// - private readonly int _busWidth = 180; - /// - /// Высота прорисовки автобуса - /// - private readonly int _busHeight = 120; - /// - /// Инициализация свойств - /// - /// Скорость - /// Вес - /// Основной цвет - /// Дополнительный цвет - /// Признак наличия второго этажа - /// Признак наличия лестницы - /// Ширина картинки - /// Высота картинки - /// true - объект создан, false - проверка не пройдена - /// - public bool Init(EntityDoubleDeckerBus bus, int width, int height) - { - _pictureWidth = width; - _pictureHeight = height; - EntityDoubleDeckerBus = bus; - if (_pictureWidth < _busWidth || _pictureHeight < _busHeight) - { - return false; - } - return true; - } - /// - /// Установка позиции - /// - /// Координата X - /// Координата Y - /// - public void SetPosition(int x, int y) - { - _startPosX = x; - _startPosY = y; - if (_startPosX + _busWidth > _pictureWidth) { - _startPosX = _pictureWidth - _busWidth; - } - if (_startPosX < 0) - { - _startPosX = 0; - } - if (_startPosY + _busHeight > _pictureHeight) - { - _startPosY = _pictureHeight - _busHeight; - } - if (_startPosY < 0) - { - _startPosY = 0; - } - } - /// - /// Изменение направления перемещения - /// - /// Направление - public void MoveTransport(Direction direction) - { - if (EntityDoubleDeckerBus == null) - { - return; - } - switch (direction) - { - //влево - case Direction.Left: - if (_startPosX - EntityDoubleDeckerBus.Step > 0) - { - _startPosX -= (int)EntityDoubleDeckerBus.Step; - } - break; - //вверх - case Direction.Up: - if (_startPosY - EntityDoubleDeckerBus.Step > 0) - { - _startPosY -= (int)EntityDoubleDeckerBus.Step; - } - break; - // вправо - case Direction.Right: - if (_startPosX + EntityDoubleDeckerBus.Step + _busWidth < _pictureWidth) - { - _startPosX += (int)EntityDoubleDeckerBus.Step; - } - break; - //вниз - case Direction.Down: - if (_startPosY + EntityDoubleDeckerBus.Step + _busHeight < _pictureHeight) - { - _startPosY += (int)EntityDoubleDeckerBus.Step; - } - break; - } - } - /// - /// Прорисовка объекта - /// - /// - public void DrawTransport(Graphics g) - { - if (EntityDoubleDeckerBus == null) - { - return; - } - Pen pen = new(Color.Black); - Brush bodyColor = new - SolidBrush(EntityDoubleDeckerBus.BodyColor); - - g.FillRectangle(bodyColor, _startPosX + 147, _startPosY + 52, 21, 20); //маленький - g.FillRectangle(bodyColor, _startPosX + 147, _startPosY + 71, 30, 27); //2 - g.FillRectangle(bodyColor, _startPosX + 10, _startPosY + 52, 137, 46); //большой прямоугольник 2 - - //окна - Brush brBlue = new SolidBrush(Color.LightBlue); - g.FillRectangle(brBlue, _startPosX + 150, _startPosY + 55, 15, 15); - - g.FillRectangle(brBlue, _startPosX + 42, _startPosY + 55, 15, 15); - g.FillRectangle(brBlue, _startPosX + 69, _startPosY + 55, 15, 15); - g.FillRectangle(brBlue, _startPosX + 96, _startPosY + 55, 15, 15); - g.FillRectangle(brBlue, _startPosX + 123, _startPosY + 55, 15, 15); - - g.DrawLine(pen, _startPosX + 30, _startPosY + 52, _startPosX + 30, _startPosY + 98); - g.DrawLine(pen, _startPosX + 35, _startPosY + 52, _startPosX + 35, _startPosY + 98); - //ВТОРОЙ ЭТАЖ - if (EntityDoubleDeckerBus.SecondFloor) - { - Brush additionalColor = new - SolidBrush(EntityDoubleDeckerBus.AdditionalColor); - - g.FillRectangle(additionalColor, _startPosX + 7, _startPosY + 12, 172, 40); //большой прямоугольник - - g.DrawLine(pen, _startPosX + 7, _startPosY + 36, _startPosX + 178, _startPosY + 36); - - g.FillRectangle(brBlue, _startPosX + 15, _startPosY + 15, 15, 15); - g.FillRectangle(brBlue, _startPosX + 42, _startPosY + 15, 15, 15); - g.FillRectangle(brBlue, _startPosX + 69, _startPosY + 15, 15, 15); - g.FillRectangle(brBlue, _startPosX + 96, _startPosY + 15, 15, 15); - g.FillRectangle(brBlue, _startPosX + 123, _startPosY + 15, 15, 15); - g.FillRectangle(brBlue, _startPosX + 150, _startPosY + 15, 15, 15); - } - //ЛЕСТНИЦА - if (EntityDoubleDeckerBus.Stairs) - { - g.DrawLine(pen, _startPosX + 10, _startPosY + 55, _startPosX + 34, _startPosY + 55); - g.DrawLine(pen, _startPosX + 10, _startPosY + 58, _startPosX + 34, _startPosY + 58); - g.DrawLine(pen, _startPosX + 10, _startPosY + 64, _startPosX + 34, _startPosY + 64); - g.DrawLine(pen, _startPosX + 10, _startPosY + 72, _startPosX + 34, _startPosY + 72); - g.DrawLine(pen, _startPosX + 10, _startPosY + 80, _startPosX + 34, _startPosY + 80); - g.DrawLine(pen, _startPosX + 10, _startPosY + 88, _startPosX + 34, _startPosY + 88); - g.DrawLine(pen, _startPosX + 10, _startPosY + 94, _startPosX + 34, _startPosY + 94); - } - // колёса - Brush gr = new SolidBrush(Color.Gray); - g.FillEllipse(bodyColor, _startPosX + 23, _startPosY + 88, 25, 25); - g.FillEllipse(bodyColor, _startPosX + 123, _startPosY + 88, 25, 25); - - g.FillEllipse(gr, _startPosX + 25, _startPosY + 90, 21, 21); - g.FillEllipse(gr, _startPosX + 125, _startPosY + 90, 21, 21); - } - } -} \ No newline at end of file