using ProjectElectroTrans.Entities; namespace ProjectElectroTrans.Drawnings; /// /// Класс, отвечающий за прорисовку и перемещение объекта-сущности /// public class DrawingElectroTrans : DrawingTrans { /// /// Конструктор /// /// Скорость /// Вес /// Основной цвет /// Дополнительный цвет /// Признак наличия обвеса /// Признак наличия антикрыла /// Признак наличия гоночной полосы public DrawingElectroTrans(int speed, double weight, Color bodyColor, Color additionalColor, bool horns, bool battery) : base(110, 60) { EntityTrans = new EntityElectroTrans(speed, weight, bodyColor, additionalColor, horns, battery); } public DrawingElectroTrans(EntityTrans trans) : base(110, 60) { if (trans != null && trans is EntityElectroTrans electroTrans) { EntityTrans = new EntityElectroTrans(electroTrans.Speed, electroTrans.Weight, electroTrans.BodyColor, electroTrans.AdditionalColor, electroTrans.Horns, electroTrans.Battery); } } public override void DrawTransport(Graphics g) { if (EntityTrans == null || EntityTrans is not EntityElectroTrans electroTrans || !_startPosX.HasValue || !_startPosY.HasValue) { return; } Pen pen = new(electroTrans.BodyColor); Brush additionalBrush= new SolidBrush(electroTrans.AdditionalColor); base.DrawTransport(g); if (electroTrans.Horns) { g.DrawPolygon(pen, new Point[] { new Point(_startPosX.Value + 40, _startPosY.Value + 10), new Point(_startPosX.Value + 20, _startPosY.Value), new Point(_startPosX.Value + 60, _startPosY.Value), }); } else { g.DrawPolygon(pen, new Point[] { new Point(_startPosX.Value + 40, _startPosY.Value + 7), new Point(_startPosX.Value + 20, _startPosY.Value + 7), new Point(_startPosX.Value + 60, _startPosY.Value + 7), }); } if (electroTrans.Battery) { g.FillPolygon(additionalBrush, new Point[] { new Point(_startPosX.Value + 25, _startPosY.Value + 32), new Point(_startPosX.Value + 25, _startPosY.Value + 36), new Point(_startPosX.Value + 22, _startPosY.Value + 36), new Point(_startPosX.Value + 22, _startPosY.Value + 40), new Point(_startPosX.Value + 25, _startPosY.Value + 40), new Point(_startPosX.Value + 25, _startPosY.Value + 46), new Point(_startPosX.Value + 58, _startPosY.Value + 46), new Point(_startPosX.Value + 58, _startPosY.Value + 32), }); } } }