PIBD-14_Lavrova_K.I._Simple/solution/lab1/Drawnings/DrawningEntityFighter.cs

58 lines
2.0 KiB
C#
Raw Normal View History

using lab1.Entities;
namespace lab1.Drawnings;
/// <summary>
2024-04-24 13:20:48 +04:00
/// Класс, отвечающий за прорисовку и перемещение базового объекта-сущности
/// </summary>
public class DrawningEntityFighter : DrawningTrackedVehicle
{
/// <summary>
/// Конструктор
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">>Вес истребителя</param>
/// <param name="bodyColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="rockets">Признак наличия ракет</param>
/// <param name="extraWings">Признак наличия доп. крыльев</param>
public DrawningEntityFighter(int speed, double weight, Color bodyColor, Color additionalColor, bool rockets, bool extraWings) : base (91, 65)
{
EntityTrackedVehicle = new EntityFighter(speed, weight, bodyColor, additionalColor, rockets, extraWings);
}
public override void DrawTransport(Graphics g)
{
if (EntityTrackedVehicle == null || EntityTrackedVehicle is not EntityFighter fighter || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
Pen pen = new(Color.Black);
Brush CraneBrush = new SolidBrush(fighter.AdditionalColor);
2024-04-24 22:45:48 +04:00
if (fighter.Kovsh)
{
//ковш
g.DrawRectangle(pen, _startPosX.Value - 2, _startPosY.Value + 37, 8, 15);
g.FillRectangle(CraneBrush, _startPosX.Value - 2, _startPosY.Value + 37, 8, 15);
g.DrawRectangle(pen, _startPosX.Value - -6, _startPosY.Value + 37, 4, 1);
}
//противовес
if (fighter.Otval)
{
g.DrawRectangle(pen, _startPosX.Value + 73, _startPosY.Value + 37, 17, 1);
g.DrawRectangle(pen, _startPosX.Value + 90, _startPosY.Value + 37, 1, 17);
}
}
}