PIbd-22_Bondarenko_M.S._War.../WarmlyShip/WarmlyShip/DrawningMotorShip.cs

49 lines
1.8 KiB
C#
Raw Normal View History

2022-10-18 20:14:31 +04:00
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);
}
}
2022-11-11 01:12:45 +04:00
public DrawningMotorShip ModifShip(int? speed = null, float? weight = null, Color? bodyColor = null, Color? dopColor = null, bool? tubes = null, bool? cistern = null)
{
2022-11-11 16:06:26 +04:00
return new DrawningMotorShip(speed ?? warmlyShip.Speed, weight ?? warmlyShip.Weight, bodyColor ?? warmlyShip.BodyColor, dopColor ?? ((EntityMotorShip)warmlyShip).DopColor, tubes ?? ((EntityMotorShip)warmlyShip).Tubes, cistern ?? ((EntityMotorShip)warmlyShip).Cistern);
2022-11-11 01:12:45 +04:00
}
2022-10-18 20:14:31 +04:00
}
}