Пибд-23 Тихоненков Алексей Лабораторная №1 #2

Closed
YourDax wants to merge 6 commits from Lab1 into main
3 changed files with 41 additions and 16 deletions
Showing only changes of commit cb138fd554 - Show all commits

View File

@ -52,13 +52,13 @@ namespace AntiAircraftGun
/// <returns>true - объект создан, false - проверка не пройдена,
///нельзя создать объект в этих размерах</returns>
public bool Init(int speed, double weight, Color bodyColor, Color
additionalColor, int width, int height)
additionalColor, Color dopColor, bool rocket, bool radar, int width, int height)
{
// TODO: Продумать проверки
_pictureWidth = width;
_pictureHeight = height;
AntiAircraftGun = new EntityAntiAircraftGun();
AntiAircraftGun.Init(speed, weight, bodyColor, additionalColor);
AntiAircraftGun.Init(speed, weight, bodyColor, additionalColor,dopColor,rocket,radar);
return true;
}
/// <summary>
@ -136,30 +136,42 @@ namespace AntiAircraftGun
Brush bodyBrush = new SolidBrush(AntiAircraftGun.BodyColor);
Brush additionalBrush = new SolidBrush(AntiAircraftGun.AdditionalColor);
// Нарисовать гусеницы
g.FillEllipse(additionalBrush, _startPosX, _startPosY+40, 110, 10);
g.DrawEllipse(pen, _startPosX, _startPosY+40, 110, 10);
g.FillRectangle(bodyBrush, _startPosX, _startPosY+30, 110, 10);
g.DrawRectangle(pen, _startPosX, _startPosY+30, 110, 10);
g.FillRectangle(bodyBrush, _startPosX+80, _startPosY+10, 30, 20);
g.DrawRectangle(pen, _startPosX+80, _startPosY+10, 30, 20);
points[0] = new Point(_startPosX, _startPosY+30);
points[1] = new Point(_startPosX+95, _startPosY+5);
points[2] = new Point(_startPosX+92, _startPosY);
points[3] = new Point(_startPosX, _startPosY+25);
g.FillPolygon(additionalBrush, points);
g.DrawPolygon(pen, points);
//g.DrawLine(pen, _startPosX, _startPosY+30, _startPosX+95,_startPosY+5 );
//g.DrawLine(pen, _startPosX+95, _startPosY+5, _startPosX+92, _startPosY);
//g.DrawLine(pen, _startPosX+92, _startPosY, _startPosX, _startPosY+26);
//g.DrawLine(pen, _startPosX, _startPosY+26, _startPosX, _startPosY+30);
for (int i = 0; i < 4; i++)
{
Rectangle trackRect = new Rectangle(_startPosX+20 + i*19, _startPosY+40,10, 10);
Rectangle trackRect = new Rectangle(_startPosX+20 + i*19, _startPosY+40, 10, 10);
g.DrawEllipse(pen, trackRect);
g.FillEllipse(Brushes.Black, trackRect);
}
Brush dopBrush = new SolidBrush(AntiAircraftGun.DopColor);
Pen dopPen = new Pen(AntiAircraftGun.DopColor);
if (AntiAircraftGun.Rocket)
{
points[0] = new Point(_startPosX, _startPosY + 30);
points[1] = new Point(_startPosX + 95, _startPosY + 5);
points[2] = new Point(_startPosX + 92, _startPosY);
points[3] = new Point(_startPosX, _startPosY + 25);
g.FillPolygon(dopBrush, points);
g.DrawPolygon(pen, points);
}
if (AntiAircraftGun.Radar)
{
g.DrawLine(dopPen, _startPosX + 105, _startPosY + 20, _startPosX +105, _startPosY + 5);
g.FillPie(dopBrush, _startPosX + 81, _startPosY-15, 30, 30, -45, 180);
g.DrawLine(dopPen, _startPosX + 98, _startPosY, _startPosX + 93, _startPosY + 10);
g.FillEllipse(dopBrush, _startPosX + 88, _startPosY -10, 10, 10);
}

View File

@ -28,6 +28,12 @@ namespace AntiAircraftGun
/// Шаг перемещения автомобиля
/// </summary>
public double Step => (double)Speed * 100 / Weight;
public Color DopColor { get; private set; }
public bool Rocket { get; private set; }
public bool Radar { get; private set; }
/// <summary>
/// Инициализация полей объекта-класса спортивного автомобиля
/// </summary>
@ -35,12 +41,15 @@ namespace AntiAircraftGun
/// <param name="weight">Вес автомобиля</param>
/// <param name="bodyColor">Основной цвет</param>
public void Init(int speed, double weight, Color bodyColor, Color additionalColor)
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, Color dopColor, bool rocket, bool radar)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
AdditionalColor = additionalColor;
DopColor = dopColor;
Rocket = rocket;
Radar = radar;
}
}
}

View File

@ -102,6 +102,10 @@ namespace AntiAircraftGun
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)), // Äîï. öâåò2
Convert.ToBoolean(random.Next(2)), // Rocket
Convert.ToBoolean(random.Next(2)), // Radar
pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
_drawing.SetPosition(random.Next(10, 100),