using System.Drawing.Drawing2D; namespace ElectricLocomotive; public class DrawingElectricLocomotiv : DrawingLocomotiv { public bool isBattery; public bool isRoga; public DrawingElectricLocomotiv(int speed, double weight, int width, int height, Color mainColor, Color dopColor, Color batteryColor, Color rogaColor,bool isBattery, bool isRoga) : base(speed, weight, width, height, mainColor, dopColor) { this.isBattery = isBattery; this.isRoga = isRoga; if (EntityLocomotiv != null) { EntityLocomotiv = new EntityElectricLocomotiv(speed, weight, batteryColor, rogaColor, mainColor, dopColor, isRoga, isBattery); } } public void ChangeAddColor(Color col) { ((EntityElectricLocomotiv)EntityLocomotiv).BatteryColor = col; ((EntityElectricLocomotiv)EntityLocomotiv).RogaColor = col; } public override void DrawLoco(Graphics g) { if (EntityLocomotiv == null) return; base.DrawLoco(g); if (EntityLocomotiv is not EntityElectricLocomotiv electricLocomotiv) return; SolidBrush batteryBrush = new(electricLocomotiv.BatteryColor); Pen rogaPen = new(electricLocomotiv.RogaColor); if (this.isRoga) { g.DrawLine(rogaPen, new Point(_startPosX + _vehicleWidth / 2, _startPosY + 30), new Point(_startPosX + _vehicleWidth / 2 + 10, _startPosY + 15)); g.DrawLine(rogaPen, new Point(_startPosX + _vehicleWidth / 2 + 10, _startPosY + 15), new Point(_startPosX + _vehicleWidth / 2, _startPosY)); } if (this.isBattery) { Point[] batteryPoints = { new Point(_startPosX + _vehicleWidth - 10,_startPosY + _vehicleHeight - 25), new Point(_startPosX + _vehicleWidth, _startPosY + _vehicleHeight - 20), new Point(_startPosX + _vehicleWidth, _startPosY + _vehicleHeight - 55), new Point(_startPosX + _vehicleWidth - 10, _startPosY + _vehicleHeight - 50) }; g.FillPolygon(batteryBrush, batteryPoints); } } }