using RoadTrain.Entities; using System.Drawing; namespace RoadTrain.DrawningObjects { /// /// Класс, отвечающий за прорисовку и перемещение объекта-сущности /// public class DrawningTrain : DrawningRoadTrain { /// /// Конструктор /// /// Скорость /// Вес /// Основной цвет /// Дополнительный цвет /// Признак наличия обвеса /// Признак наличия антикрыла /// Ширина картинки /// Высота картинки public DrawningTrain(int speed, double weight, Color bodyColor, Color additionalColor, bool waterContainer, bool sweepingBrush, int width, int height) :base(speed, weight, bodyColor, width, height) { if (EntityRoadTrain != null) { EntityRoadTrain = new EntityTrain(speed, weight, bodyColor, additionalColor, waterContainer, sweepingBrush); } } public override void DrawTransport(Graphics g) { if (EntityRoadTrain is not EntityTrain train) { return; } Pen pen = new(Color.Black); Brush additionalBrush = new SolidBrush(train.AdditionalColor); //Контейнер с водой if (train.WaterContainer) { g.DrawEllipse(pen, _startPosX + 30, _startPosY, 10, 20); g.FillEllipse(additionalBrush, _startPosX + 30, _startPosY, 10, 20); } base.DrawTransport(g); if (train.SweepingBrush) { g.DrawLine(pen, _startPosX + 30, _startPosY + 10, _startPosX + 20, _startPosY + 10); g.DrawLine(pen, _startPosX + 20, _startPosY + 10, _startPosX + 10, _startPosY + 30); g.DrawLine(pen, _startPosX + 17, _startPosY + 30, _startPosX + 3, _startPosY + 30); } } public void SetAdditionalColor(Color color) { (EntityRoadTrain as EntityTrain).SetAdditionalColor(color); } } }