Фиксация

This commit is contained in:
Макс Бондаренко 2022-10-04 21:21:25 +04:00
parent fe5fe24f5a
commit e51d851a32
3 changed files with 21 additions and 11 deletions

View File

@ -8,7 +8,7 @@ namespace WarmlyShip
{ {
internal class DrawningMotorShip : DrawningWarmlyShip internal class DrawningMotorShip : DrawningWarmlyShip
{ {
public DrawningMotorShip(int speed, float weight, Color bodyColor, Color dopColor, bool tubes, bool cistern) : base(speed, weight, bodyColor, 110, 60) 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); warmlyShip = new EntityMotorShip(speed, weight, bodyColor, dopColor, tubes , cistern);
} }
@ -20,14 +20,24 @@ namespace WarmlyShip
return; return;
} }
Pen pen = new(Color.Black, 2);
Brush dopBrush = new SolidBrush(motorShip.DopColor);
if (motorShip.Tubes) 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) if (motorShip.Cistern)
{ {
g.FillEllipse(dopBrush, _startPosX, _startPosY + 25, 25, 20);
g.DrawEllipse(pen, _startPosX, _startPosY + 25, 25, 20);
} }
} }
} }

View File

@ -13,8 +13,8 @@ namespace WarmlyShip
protected float _startPosY; //Координаты отрисовки по оси y protected float _startPosY; //Координаты отрисовки по оси y
private int? _pictureWidth = null; //Ширина окна private int? _pictureWidth = null; //Ширина окна
private int? _pictureHeight = null; //Высота окна private int? _pictureHeight = null; //Высота окна
private readonly int _warmlyShipWidth = 125; //Ширина отрисовки корабля protected readonly int _warmlyShipWidth = 125; //Ширина отрисовки корабля
private readonly int _warmlyShipHeight = 50; //Высота отрисовки корабля protected readonly int _warmlyShipHeight = 50; //Высота отрисовки корабля
//Конструктор класса //Конструктор класса
public DrawningWarmlyShip(int speed, float weight, Color bodyColor) public DrawningWarmlyShip(int speed, float weight, Color bodyColor)
@ -73,8 +73,8 @@ namespace WarmlyShip
{ {
new Point((int)(_startPosX), (int)(_startPosY + 20)), new Point((int)(_startPosX), (int)(_startPosY + 20)),
new Point((int)(_startPosX + _warmlyShipWidth), (int)(_startPosY + 20)), new Point((int)(_startPosX + _warmlyShipWidth), (int)(_startPosY + 20)),
new Point((int)(_startPosX + _warmlyShipWidth - 25), (int)(_startPosY + _warmlyShipHeight)), new Point((int)(_startPosX + _warmlyShipWidth - 25), (int)(_startPosY + 50)),
new Point((int)(_startPosX + 25), (int)(_startPosY + _warmlyShipHeight)) new Point((int)(_startPosX + 25), (int)(_startPosY +50))
}); });
g.FillRectangle(brush, _startPosX + _warmlyShipWidth / 5, _startPosY, _warmlyShipWidth * 3 / 5, 20); g.FillRectangle(brush, _startPosX + _warmlyShipWidth / 5, _startPosY, _warmlyShipWidth * 3 / 5, 20);
g.FillEllipse(new SolidBrush(Color.Aquamarine), _startPosX + _warmlyShipWidth / 5, _startPosY + 25, 20, 20); g.FillEllipse(new SolidBrush(Color.Aquamarine), _startPosX + _warmlyShipWidth / 5, _startPosY + 25, 20, 20);
@ -84,8 +84,8 @@ namespace WarmlyShip
{ {
new Point((int)(_startPosX), (int)(_startPosY + 20)), new Point((int)(_startPosX), (int)(_startPosY + 20)),
new Point((int)(_startPosX + _warmlyShipWidth), (int)(_startPosY + 20)), new Point((int)(_startPosX + _warmlyShipWidth), (int)(_startPosY + 20)),
new Point((int)(_startPosX + _warmlyShipWidth - 25), (int)(_startPosY + _warmlyShipHeight)), new Point((int)(_startPosX + _warmlyShipWidth - 25), (int)(_startPosY + 50)),
new Point((int)(_startPosX + 25), (int)(_startPosY + _warmlyShipHeight)) new Point((int)(_startPosX + 25), (int)(_startPosY + 50))
}); });
g.DrawRectangle(pen, _startPosX + _warmlyShipWidth / 5, _startPosY, _warmlyShipWidth * 3 / 5, 20); g.DrawRectangle(pen, _startPosX + _warmlyShipWidth / 5, _startPosY, _warmlyShipWidth * 3 / 5, 20);
g.DrawEllipse(new(Color.Blue, 2), _startPosX + _warmlyShipWidth / 5, _startPosY + 25, 20, 20); g.DrawEllipse(new(Color.Blue, 2), _startPosX + _warmlyShipWidth / 5, _startPosY + 25, 20, 20);

View File

@ -20,7 +20,7 @@ namespace WarmlyShip
private void SetData() private void SetData()
{ {
Random random = new Random(); Random random = new Random();
_warmlyShip.SetPosition(random.Next(pictureBox.Width - 150, pictureBox.Width - 125), random.Next(pictureBox.Height - 150, pictureBox.Height - 50), pictureBox.Width, pictureBox.Height); _warmlyShip.SetPosition(random.Next(0, 100), random.Next(0, 100), pictureBox.Width, pictureBox.Height);
toolStripStatusSpeed.Text = $"Ñêîðîñòü: {_warmlyShip.warmlyShip?.Speed}"; toolStripStatusSpeed.Text = $"Ñêîðîñòü: {_warmlyShip.warmlyShip?.Speed}";
toolStripStatusWeight.Text = $"Âåñ: {_warmlyShip.warmlyShip?.Weight}"; toolStripStatusWeight.Text = $"Âåñ: {_warmlyShip.warmlyShip?.Weight}";
toolStripStatusLabelBodyColor.Text = $"Öâåò: {_warmlyShip.warmlyShip?.BodyColor}"; toolStripStatusLabelBodyColor.Text = $"Öâåò: {_warmlyShip.warmlyShip?.BodyColor}";
@ -67,7 +67,7 @@ namespace WarmlyShip
_warmlyShip = new DrawningMotorShip(random.Next(100, 300), random.Next(1000, 3000), _warmlyShip = new DrawningMotorShip(random.Next(100, 300), random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Convert.ToBoolean(random.Next(0, 1)), Convert.ToBoolean(random.Next(0, 1))); Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
SetData(); SetData();
Draw(); Draw();
} }