Реализована логика отрисовки дополнительных частей локомотива

This commit is contained in:
Данила Мочалов 2022-09-25 17:52:02 +04:00
parent fc639a1deb
commit 760ccf3570
3 changed files with 22 additions and 14 deletions

View File

@ -107,7 +107,7 @@ namespace Locomotive
} }
Pen pen = new(Color.Black); Pen pen = new(Color.Black);
//тело //тело
g.DrawRectangle(pen, _startPosX , _startPosY, _locomotiveWidth - 10, _locomotiveHeight - 10); g.DrawRectangle(pen, _startPosX , _startPosY, 110 - 10, 50 - 10);
//окна //окна
g.FillRectangle(new SolidBrush(Locomotive?.BodyColor ?? Color.Black), _startPosX + 10, _startPosY + 10, 10, 10); g.FillRectangle(new SolidBrush(Locomotive?.BodyColor ?? Color.Black), _startPosX + 10, _startPosY + 10, 10, 10);
g.FillRectangle(new SolidBrush(Locomotive?.BodyColor ?? Color.Black), _startPosX + 30, _startPosY + 10, 10, 10); g.FillRectangle(new SolidBrush(Locomotive?.BodyColor ?? Color.Black), _startPosX + 30, _startPosY + 10, 10, 10);

View File

@ -9,7 +9,7 @@ namespace Locomotive
internal class DrawningWarmlyLocomotive : DrawningLocomotive internal class DrawningWarmlyLocomotive : DrawningLocomotive
{ {
public DrawningWarmlyLocomotive(int speed, float weight, Color bodyColor, Color extraColor, bool pipe, bool storage) public DrawningWarmlyLocomotive(int speed, float weight, Color bodyColor, Color extraColor, bool pipe, bool storage)
: base(speed, weight, bodyColor, locomotiveWidth: 110, locomotiveHeight: 50) : base(speed, weight, bodyColor, locomotiveWidth: 130, locomotiveHeight: 70)
{ {
Locomotive = new EntityWarmlyLocomotive(speed, weight, bodyColor, extraColor, pipe, storage); Locomotive = new EntityWarmlyLocomotive(speed, weight, bodyColor, extraColor, pipe, storage);
} }
@ -23,21 +23,29 @@ namespace Locomotive
Pen pen = new(Color.Black); Pen pen = new(Color.Black);
Brush extraBrush = new SolidBrush(warmlyLocomotive.ExtraColor); Brush extraBrush = new SolidBrush(warmlyLocomotive.ExtraColor);
base.DrawTransport(g);
if (warmlyLocomotive.Pipe)
{
//TODO
}
if (warmlyLocomotive.FuelStorage) if (warmlyLocomotive.FuelStorage)
{ {
//TODO g.FillRectangle(extraBrush, _startPosX + 10, _startPosY, 30, 20);
g.FillRectangle(extraBrush, _startPosX + 60, _startPosY, 20, 20);
g.FillRectangle(extraBrush, _startPosX + 60, _startPosY + 10, 30, 10);
} }
if (warmlyLocomotive.Pipe)
{
g.FillRectangle(extraBrush, _startPosX + 110, _startPosY + 10, 10, 50);
g.FillRectangle(extraBrush, _startPosX + 110, _startPosY + 40, 20, 20);
g.FillRectangle(extraBrush, _startPosX + 100, _startPosY, 30, 10);
}
_startPosY += 20;
base.DrawTransport(g);
_startPosY -= 20;
} }
} }

View File

@ -68,8 +68,8 @@ namespace Locomotive
_locomotive = new DrawningWarmlyLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000), _locomotive = new DrawningWarmlyLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
Convert.ToBoolean(rnd.Next(0,1)), Convert.ToBoolean(rnd.Next(0, 2)),
Convert.ToBoolean(rnd.Next(0, 1))); Convert.ToBoolean(rnd.Next(0, 2)));
_locomotive.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height); _locomotive.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
SetData(); SetData();