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

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

View File

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

View File

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

View File

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