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

65 lines
2.2 KiB
C#
Raw Normal View History

using lab1.Entities;
2024-10-22 13:26:55 +04:00
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);
}
2024-10-22 13:26:55 +04:00
public DrawningEntityFighter(EntityFighter fighter) : base(91, 65)
{
EntityTrackedVehicle = new EntityFighter(fighter.Speed, fighter.Weight, fighter.BodyColor, fighter.AdditionalColor, fighter.Kovsh, fighter.Otval);
}
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-05-20 14:42:55 +04:00
base.DrawTransport(g);
if (fighter.Kovsh)
{
2024-05-20 14:42:55 +04:00
///ковш
2024-05-22 14:22:42 +04:00
g.DrawRectangle(pen, _startPosX.Value - 17, _startPosY.Value + 12, 8, 15);
g.FillRectangle(CraneBrush, _startPosX.Value - 17, _startPosY.Value + 12, 8, 15);
g.DrawRectangle(pen, _startPosX.Value - 8, _startPosY.Value + 17, 5, 1);
}
2024-05-20 14:42:55 +04:00
///противовес
if (fighter.Otval)
{
2024-05-22 14:22:42 +04:00
g.DrawRectangle(pen, _startPosX.Value + 63, _startPosY.Value + 17, 17, 1);
g.DrawRectangle(pen, _startPosX.Value + 80, _startPosY.Value + 17, 1, 16);
}
}
}