72 lines
2.8 KiB
C#
72 lines
2.8 KiB
C#
|
using ProjectElectroTrans.Entities;
|
|||
|
|
|||
|
namespace ProjectElectroTrans.Drawnings;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
|||
|
/// </summary>
|
|||
|
public class DrawingElectroTrans : DrawingTrans
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// Конструктор
|
|||
|
/// </summary>
|
|||
|
/// <param name="speed">Скорость</param>
|
|||
|
/// <param name="weight">Вес</param>
|
|||
|
/// <param name="bodyColor">Основной цвет</param>
|
|||
|
/// <param name="additionalColor">Дополнительный цвет</param>
|
|||
|
/// <param name="bodyKit">Признак наличия обвеса</param>
|
|||
|
/// <param name="wing">Признак наличия антикрыла</param>
|
|||
|
/// <param name="sportLine">Признак наличия гоночной полосы</param>
|
|||
|
public DrawingElectroTrans(int speed, double weight, Color bodyColor, Color
|
|||
|
additionalColor, bool horns, bool battery) : base(110, 60)
|
|||
|
{
|
|||
|
EntityTrans = new EntityElectroTrans(speed, weight, bodyColor, additionalColor, horns, battery);
|
|||
|
}
|
|||
|
public override void DrawTransport(Graphics g)
|
|||
|
{
|
|||
|
if (EntityTrans == null || EntityTrans is not EntityElectroTrans electroTrans ||
|
|||
|
!_startPosX.HasValue || !_startPosY.HasValue)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
Pen pen = new(electroTrans.BodyColor);
|
|||
|
Brush additionalBrush= new SolidBrush(electroTrans.AdditionalColor);
|
|||
|
|
|||
|
base.DrawTransport(g);
|
|||
|
|
|||
|
if (electroTrans.Horns)
|
|||
|
{
|
|||
|
g.DrawPolygon(pen, new Point[] {
|
|||
|
new Point(_startPosX.Value + 40, _startPosY.Value + 10),
|
|||
|
new Point(_startPosX.Value + 20, _startPosY.Value),
|
|||
|
new Point(_startPosX.Value + 60, _startPosY.Value),
|
|||
|
|
|||
|
});
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
g.DrawPolygon(pen, new Point[] {
|
|||
|
new Point(_startPosX.Value + 40, _startPosY.Value + 7),
|
|||
|
new Point(_startPosX.Value + 20, _startPosY.Value + 7),
|
|||
|
new Point(_startPosX.Value + 60, _startPosY.Value + 7),
|
|||
|
|
|||
|
});
|
|||
|
}
|
|||
|
if (electroTrans.Battery)
|
|||
|
{
|
|||
|
g.FillPolygon(additionalBrush, new Point[] {
|
|||
|
new Point(_startPosX.Value + 25, _startPosY.Value + 32),
|
|||
|
new Point(_startPosX.Value + 25, _startPosY.Value + 36),
|
|||
|
new Point(_startPosX.Value + 22, _startPosY.Value + 36),
|
|||
|
new Point(_startPosX.Value + 22, _startPosY.Value + 40),
|
|||
|
new Point(_startPosX.Value + 25, _startPosY.Value + 40),
|
|||
|
new Point(_startPosX.Value + 25, _startPosY.Value + 46),
|
|||
|
new Point(_startPosX.Value + 58, _startPosY.Value + 46),
|
|||
|
new Point(_startPosX.Value + 58, _startPosY.Value + 32),
|
|||
|
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|