Добавление тента

This commit is contained in:
Владимир Данилов 2023-10-27 20:04:01 +04:00
parent 94fd66d63a
commit 2b42cbf8bc
4 changed files with 18 additions and 5 deletions

View File

@ -46,7 +46,7 @@ namespace Project_DumpTruck
/// <param name="additionalColor"></param>
/// <param name="width">Ширина картинки</param>
/// <param name="height">Высота картинки</param>
public bool Init(int speed, float weight, Color bodyColor, Color additionalColor, bool body, int width, int height)
public bool Init(int speed, float weight, Color bodyColor, Color additionalColor, bool body, bool tent, int width, int height)
{
// TODO: Продумать проверки
if (width < _dumptruckWidth || height < _dumptruckHeight)
@ -56,7 +56,7 @@ namespace Project_DumpTruck
_pictureHeight = height;
EntityDumpTruck = new EntityDumpTruck();
EntityDumpTruck.Init(speed, weight, bodyColor, additionalColor, body);
EntityDumpTruck.Init(speed, weight, bodyColor, additionalColor, body, tent);
return true;
}
/// <summary>
@ -161,6 +161,12 @@ namespace Project_DumpTruck
{
g.FillRectangle(brushAdditionalColor, _startPosX, _startPosY + 10, 70, 20);
g.DrawRectangle(penBlack, _startPosX, _startPosY + 10, 70, 20);
if (EntityDumpTruck.Tent)
{
g.FillRectangle(brushWhite, _startPosX, _startPosY + 10, 70, 5);
g.DrawRectangle(penBlack, _startPosX, _startPosY + 10, 70, 5);
}
}
}
/// <summary>

View File

@ -33,6 +33,11 @@ namespace Project_DumpTruck
/// </summary>
public bool BodyKit { get; private set; }
/// <summary>
/// Признак (опция) наличия тента
/// </summary>
public bool Tent { get; private set; }
/// <summary>
/// Шаг перемещения автомобиля
/// </summary>
@ -46,13 +51,14 @@ namespace Project_DumpTruck
/// <param name="bodyColor"></param>
/// <param name="additionalColor"></param>
/// <returns></returns>
public void Init(int speed, float weight, Color bodyColor, Color additionalColor, bool bodyKit)
public void Init(int speed, float weight, Color bodyColor, Color additionalColor, bool bodyKit, bool tent)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
AdditionalColor = additionalColor;
BodyKit = bodyKit;
Tent = tent;
}
}
}

View File

@ -106,7 +106,7 @@
buttonRight.UseVisualStyleBackColor = true;
buttonRight.Click += buttonMove_Click;
//
// Form1
// FormDumpTruck
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
@ -117,7 +117,7 @@
Controls.Add(buttonLeft);
Controls.Add(buttonCreate);
Controls.Add(pictureBoxDumpTruck);
Name = "Form1";
Name = "FormDumpTruck";
StartPosition = FormStartPosition.CenterScreen;
Text = "Form1";
((System.ComponentModel.ISupportInitialize)pictureBoxDumpTruck).EndInit();

View File

@ -43,6 +43,7 @@
Color.FromArgb(random.Next(0, 256), random.Next(0, 256),
random.Next(0, 256)),
Convert.ToBoolean(random.Next(0, 2)),
Convert.ToBoolean(random.Next(0, 2)),
pictureBoxDumpTruck.Width, pictureBoxDumpTruck.Height);
_drawningDumpTruck.SetPosition(random.Next(10, 100),
random.Next(10, 100));