68 lines
2.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using ProjectGasolineTanker.Entities;
namespace ProjectGasolineTanker.Drawings;
/// <summary>
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
/// </summary>
public class DrawingGasolineTanker : DrawingTruck
{
/// <summary>
/// Конструктор
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="gasTank">Признак наличия бака под бензин</param>
/// <param name="signalBeacon">Признак наличия сигнального маяка на кабине</param>
public DrawingGasolineTanker(int speed, double weight, Color bodyColor, Color additionalColor, bool gasTank, bool signalBeacon) : base(105, 70)
{
EntityTruck = new EntityGasolineTanker(speed, weight, bodyColor, additionalColor, gasTank, signalBeacon);
}
public DrawingGasolineTanker(EntityGasolineTanker truck) : base(105,70)
{
EntityTruck = new EntityGasolineTanker(truck.Speed, truck.Weight, truck.BodyColor, truck.AdditionalColor, truck.GasTank, truck.SignalBeacon);
}
public override void DrawTransport(Graphics g)
{
if (EntityTruck == null || EntityTruck is not EntityGasolineTanker gasolineTanker || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
Pen pen = new(Color.Black);
Brush additonalBrush = new SolidBrush(gasolineTanker.AdditionalColor);
// бензобак
if (gasolineTanker.GasTank)
{
g.DrawEllipse(pen, _startPosX.Value + 7, _startPosY.Value + 19, 31, 31);
g.DrawEllipse(pen, _startPosX.Value + 47, _startPosY.Value + 19, 31, 31);
g.DrawRectangle(pen, _startPosX.Value + 20, _startPosY.Value + 20, 45, 30);
g.FillEllipse(additonalBrush, _startPosX.Value + 7, _startPosY.Value + 19, 31, 31);
g.FillEllipse(additonalBrush, _startPosX.Value + 47, _startPosY.Value + 19, 31, 31);
g.FillRectangle(additonalBrush, _startPosX.Value + 20, _startPosY.Value + 21, 45, 30);
}
base.DrawTransport(g);
// сигнальный маяк
if (gasolineTanker.SignalBeacon)
{
g.DrawRectangle(pen, _startPosX.Value + 85, _startPosY.Value + 8, 7, 7);
g.FillRectangle(additonalBrush, _startPosX.Value + 85, _startPosY.Value + 8, 7, 7);
}
}
}