Ожидает принятия
This commit is contained in:
parent
ede02decf3
commit
e483224393
@ -14,11 +14,11 @@ namespace GasolineTanker
|
|||||||
private int _startPosX = 0;
|
private int _startPosX = 0;
|
||||||
private int _startPosY = 0;
|
private int _startPosY = 0;
|
||||||
//Ширина грузовика
|
//Ширина грузовика
|
||||||
private readonly int _gasolineTankerWidth = 110;
|
private readonly int _gasolineTankerWidth = 200;
|
||||||
//Высота грузовика
|
//Высота грузовика
|
||||||
private readonly int _gasolineTankerHeight = 60;
|
private readonly int _gasolineTankerHeight = 100;
|
||||||
//Инициализация свойств
|
//Инициализация свойств
|
||||||
public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool wing, bool sportLine, int width, int height)
|
public bool Init(int speed, double weight, Color bodyColor, bool tank, bool signalBeacon, Color additionalColor, int width, int height)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (width <= _gasolineTankerWidth || height <= _gasolineTankerHeight)
|
if (width <= _gasolineTankerWidth || height <= _gasolineTankerHeight)
|
||||||
@ -28,8 +28,7 @@ namespace GasolineTanker
|
|||||||
_pictureWidth = width;
|
_pictureWidth = width;
|
||||||
_pictureHeight = height;
|
_pictureHeight = height;
|
||||||
EntityGasolineTanker = new EntityGasolineTanker();
|
EntityGasolineTanker = new EntityGasolineTanker();
|
||||||
//!!!!!!
|
EntityGasolineTanker.Init(speed, weight, bodyColor, tank, signalBeacon, additionalColor);
|
||||||
EntityGasolineTanker.Init(speed, weight, bodyColor, additionalColor, bodyKit, wing, sportLine);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public void SetPosition(int x, int y)
|
public void SetPosition(int x, int y)
|
||||||
@ -103,28 +102,61 @@ namespace GasolineTanker
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
|
Brush bodyBrush = new SolidBrush(EntityGasolineTanker.BodyColor);
|
||||||
Brush additionalBrush = new SolidBrush(EntityGasolineTanker.AdditionalColor);
|
Brush additionalBrush = new SolidBrush(EntityGasolineTanker.AdditionalColor);
|
||||||
|
Brush wheelBrush = new SolidBrush(Color.Black);
|
||||||
//Дополнительные элементы
|
//Дополнительные элементы
|
||||||
if (EntityGasolineTanker.BodyKit)
|
if (EntityGasolineTanker.Tank)
|
||||||
{
|
{
|
||||||
//обвес
|
//Цистерна
|
||||||
|
g.FillEllipse(additionalBrush, _startPosX + _gasolineTankerWidth / 20 * 3, _startPosY + _gasolineTankerHeight / 10 * 2, _gasolineTankerWidth / 20 * 4, _gasolineTankerHeight / 10 * 4);
|
||||||
|
g.FillEllipse(additionalBrush, _startPosX + _gasolineTankerWidth / 20 * 9, _startPosY + _gasolineTankerHeight / 10 * 2, _gasolineTankerWidth / 20 * 4, _gasolineTankerHeight / 10 * 4);
|
||||||
|
Point[] pointsTunk =
|
||||||
|
{
|
||||||
|
new Point(_startPosX + _gasolineTankerWidth / 20 * 5, _startPosY + _gasolineTankerHeight / 10 * 2),
|
||||||
|
new Point(_startPosX + _gasolineTankerWidth / 20 * 11, _startPosY + _gasolineTankerHeight / 10 * 2),
|
||||||
|
new Point(_startPosX + _gasolineTankerWidth / 20 * 11, _startPosY + _gasolineTankerHeight / 10 * 6),
|
||||||
|
new Point(_startPosX + _gasolineTankerWidth / 20 * 5, _startPosY + _gasolineTankerHeight / 10 * 6),
|
||||||
|
};
|
||||||
|
g.FillPolygon(additionalBrush, pointsTunk);
|
||||||
}
|
}
|
||||||
//границы автомобиля
|
if (EntityGasolineTanker.SignalBeacon)
|
||||||
g.DrawEllipse(pen, _startPosX + 10, _startPosY + 5, 20, 20);
|
{
|
||||||
g.DrawEllipse(pen, _startPosX + 10, _startPosY + 35, 20, 20);
|
//Маячок
|
||||||
g.DrawEllipse(pen, _startPosX + 80, _startPosY + 5, 20, 20);
|
Point[] pointsBeacon =
|
||||||
g.DrawEllipse(pen, _startPosX + 80, _startPosY + 35, 20, 20);
|
{
|
||||||
g.DrawRectangle(pen, _startPosX + 9, _startPosY + 15, 10, 30);
|
new Point(_startPosX + _gasolineTankerWidth / 20 * 14, _startPosY + _gasolineTankerHeight / 10 * 2),
|
||||||
g.DrawRectangle(pen, _startPosX + 90, _startPosY + 15, 10, 30);
|
new Point(_startPosX + _gasolineTankerWidth / 20 * 14, _startPosY + _gasolineTankerHeight / 10 * 1),
|
||||||
g.DrawRectangle(pen, _startPosX + 20, _startPosY + 4, 70, 52);
|
new Point(_startPosX + _gasolineTankerWidth / 20 * 15, _startPosY + _gasolineTankerHeight / 10 * 1),
|
||||||
//задние фары
|
new Point(_startPosX + _gasolineTankerWidth / 20 * 15, _startPosY + _gasolineTankerHeight / 10 * 2),
|
||||||
Brush brRed = new SolidBrush(Color.Red);
|
};
|
||||||
g.FillEllipse(brRed, _startPosX + 10, _startPosY + 5, 20, 20);
|
g.FillPolygon(additionalBrush, pointsBeacon);
|
||||||
g.FillEllipse(brRed, _startPosX + 10, _startPosY + 35, 20, 20);
|
//g.DrawPolygon(pen, pointsBeacon);
|
||||||
//передние фары
|
}
|
||||||
Brush brYellow = new SolidBrush(Color.Yellow);
|
/*
|
||||||
g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 5, 20, 20);
|
//Граница отрисовки объекта
|
||||||
g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 35, 20, 20);
|
Point[] pointsBorder = { new Point(_startPosX, _startPosY),
|
||||||
|
new Point(_startPosX, _startPosY + _gasolineTankerHeight),
|
||||||
|
new Point(_startPosX + _gasolineTankerWidth, _startPosY + _gasolineTankerHeight),
|
||||||
|
new Point(_startPosX + _gasolineTankerWidth, _startPosY)};
|
||||||
|
|
||||||
|
g.DrawPolygon(pen, pointsBorder);
|
||||||
|
*/
|
||||||
|
Point[] pointsFrame = {
|
||||||
|
new Point(_startPosX + _gasolineTankerWidth / 20 * 2, _startPosY + _gasolineTankerHeight / 10 * 6),
|
||||||
|
new Point(_startPosX + _gasolineTankerWidth / 20 * 13, _startPosY + _gasolineTankerHeight / 10 * 6),
|
||||||
|
new Point(_startPosX + _gasolineTankerWidth / 20 * 13, _startPosY + _gasolineTankerHeight / 10 * 2),
|
||||||
|
new Point(_startPosX + _gasolineTankerWidth / 20 * 16, _startPosY + _gasolineTankerHeight / 10 * 2),
|
||||||
|
new Point(_startPosX + _gasolineTankerWidth / 20 * 18, _startPosY + _gasolineTankerHeight / 10 * 5),
|
||||||
|
new Point(_startPosX + _gasolineTankerWidth / 20 * 18, _startPosY + _gasolineTankerHeight / 10 * 7),
|
||||||
|
new Point(_startPosX + _gasolineTankerWidth / 20 * 2, _startPosY + _gasolineTankerHeight / 10 * 7),};
|
||||||
|
|
||||||
|
g.FillPolygon(bodyBrush, pointsFrame);
|
||||||
|
g.DrawPolygon(pen, pointsFrame);
|
||||||
|
//Колёса
|
||||||
|
g.FillEllipse(wheelBrush, _startPosX + _gasolineTankerWidth / 20 * 3, _startPosY + _gasolineTankerHeight / 10 * 7, _gasolineTankerWidth / 20 * 2, _gasolineTankerHeight / 10 * 2);
|
||||||
|
g.FillEllipse(wheelBrush, _startPosX + _gasolineTankerWidth / 20 * 5, _startPosY + _gasolineTankerHeight / 10 * 7, _gasolineTankerWidth / 20 * 2, _gasolineTankerHeight / 10 * 2);
|
||||||
|
g.FillEllipse(wheelBrush, _startPosX + _gasolineTankerWidth / 20 * 15, _startPosY + _gasolineTankerHeight / 10 * 7, _gasolineTankerWidth / 20 * 2, _gasolineTankerHeight / 10 * 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,26 +13,23 @@ namespace GasolineTanker
|
|||||||
public double Weight { get; private set; }
|
public double Weight { get; private set; }
|
||||||
// Основной цвет
|
// Основной цвет
|
||||||
public Color BodyColor { get; private set; }
|
public Color BodyColor { get; private set; }
|
||||||
|
//Наличие цистерны
|
||||||
|
public bool Tank { get; private set; }
|
||||||
|
//Наличие сигнального маяка
|
||||||
|
public bool SignalBeacon { get; private set; }
|
||||||
//Дополнительный цвет
|
//Дополнительный цвет
|
||||||
public Color AdditionalColor { get; private set; }
|
public Color AdditionalColor { get; private set; }
|
||||||
//Наличие обвеса
|
|
||||||
public bool BodyKit { get; private set; }
|
|
||||||
//Наличие антикрыла
|
|
||||||
public bool Wing { get; private set; }
|
|
||||||
//Наличие гоночной полосы
|
|
||||||
public bool SportLine { get; private set; }
|
|
||||||
//Шаг перемещения
|
//Шаг перемещения
|
||||||
public double Step => (double)Speed * 100 / Weight;
|
public double Step => (double)Speed * 100 / Weight;
|
||||||
//Инициализация полей Грузовика
|
//Инициализация полей Грузовика
|
||||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool wing, bool sportLine)
|
public void Init(int speed, double weight, Color bodyColor, bool tank, bool signalBeacon, Color additionalColor)
|
||||||
{
|
{
|
||||||
Speed = speed;
|
Speed = speed;
|
||||||
Weight = weight;
|
Weight = weight;
|
||||||
BodyColor = bodyColor;
|
BodyColor = bodyColor;
|
||||||
|
Tank = tank;
|
||||||
|
SignalBeacon = signalBeacon;
|
||||||
AdditionalColor = additionalColor;
|
AdditionalColor = additionalColor;
|
||||||
BodyKit = bodyKit;
|
|
||||||
Wing = wing;
|
|
||||||
SportLine = sportLine;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,19 +20,20 @@ namespace GasolineTanker
|
|||||||
|
|
||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
Random random = new();
|
Random random = new();
|
||||||
_drawningGasolineTanker = new DrawningGasolineTanker();
|
_drawningGasolineTanker = new DrawningGasolineTanker();
|
||||||
_drawningGasolineTanker.Init(random.Next(100, 300),
|
_drawningGasolineTanker.Init(
|
||||||
|
random.Next(100, 300),
|
||||||
random.Next(1000, 3000),
|
random.Next(1000, 3000),
|
||||||
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)),
|
|
||||||
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)),
|
||||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)),
|
Convert.ToBoolean(random.Next(0, 2)),
|
||||||
|
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||||
PictureBoxGasolineTanker.Width, PictureBoxGasolineTanker.Height);
|
PictureBoxGasolineTanker.Width, PictureBoxGasolineTanker.Height);
|
||||||
_drawningGasolineTanker.SetPosition(random.Next(10, 100),
|
_drawningGasolineTanker.SetPosition(random.Next(10, 100),
|
||||||
random.Next(10, 100));
|
random.Next(10, 100));
|
||||||
|
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
|
Loading…
Reference in New Issue
Block a user