PIbd-22_Bondarenko_M.S._War.../WarmlyShip/WarmlyShip/DrawningMotorShip.cs
Макс Бондаренко 117d18566a Готово
2022-11-11 16:06:26 +04:00

49 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WarmlyShip
{
internal class DrawningMotorShip : DrawingWarmlyShip
{
public DrawningMotorShip(int speed, float weight, Color bodyColor, Color dopColor, bool tubes, bool cistern) : base(speed, weight, bodyColor, 150, 75)
{
warmlyShip = new EntityMotorShip(speed, weight, bodyColor, dopColor, tubes , cistern);
}
public override void DrawTransport(Graphics g)
{
if (warmlyShip is not EntityMotorShip motorShip)
{
return;
}
Pen pen = new(Color.Black, 2);
Brush dopBrush = new SolidBrush(motorShip.DopColor);
if (motorShip.Tubes)
{
g.FillRectangle(dopBrush, _startPosX + _warmlyShipWidth / 5, _startPosY, _warmlyShipWidth / 5, _warmlyShipHeight / 2);
g.DrawRectangle(pen, _startPosX + _warmlyShipWidth / 5, _startPosY, _warmlyShipWidth / 5, _warmlyShipHeight / 2);
g.FillRectangle(dopBrush, _startPosX + _warmlyShipWidth * 3 / 5, _startPosY, _warmlyShipWidth / 5, _warmlyShipHeight / 2);
g.DrawRectangle(pen, _startPosX + _warmlyShipWidth * 3 / 5, _startPosY, _warmlyShipWidth / 5, _warmlyShipHeight / 2);
}
_startPosY += 25;
base.DrawTransport(g);
_startPosY -= 25;
if (motorShip.Cistern)
{
g.FillEllipse(dopBrush, _startPosX, _startPosY + 25, 25, 20);
g.DrawEllipse(pen, _startPosX, _startPosY + 25, 25, 20);
}
}
public DrawningMotorShip ModifShip(int? speed = null, float? weight = null, Color? bodyColor = null, Color? dopColor = null, bool? tubes = null, bool? cistern = null)
{
return new DrawningMotorShip(speed ?? warmlyShip.Speed, weight ?? warmlyShip.Weight, bodyColor ?? warmlyShip.BodyColor, dopColor ?? ((EntityMotorShip)warmlyShip).DopColor, tubes ?? ((EntityMotorShip)warmlyShip).Tubes, cistern ?? ((EntityMotorShip)warmlyShip).Cistern);
}
}
}