81 lines
3.1 KiB
C#
81 lines
3.1 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 DrawingElectroTrans(EntityTrans trans) : base(110, 60)
|
||
{
|
||
if (trans != null && trans is EntityElectroTrans electroTrans)
|
||
{
|
||
EntityTrans = new EntityElectroTrans(electroTrans.Speed, electroTrans.Weight, electroTrans.BodyColor, electroTrans.AdditionalColor, electroTrans.Horns, electroTrans.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),
|
||
|
||
});
|
||
}
|
||
}
|
||
}
|