105 lines
4.9 KiB
C#
105 lines
4.9 KiB
C#
|
using lab1.Entities;
|
|||
|
namespace lab1.Drawnings;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
|||
|
/// </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 additionalBrush = new SolidBrush(fighter.AdditionalColor);
|
|||
|
Brush BodyBrush = new SolidBrush(fighter.BodyColor);
|
|||
|
Brush CraneBrush = new SolidBrush(fighter.AdditionalColor);
|
|||
|
|
|||
|
|
|||
|
//корпус
|
|||
|
g.FillRectangle(BodyBrush, _startPosX.Value + 10, _startPosY.Value + 30, 62, 12);
|
|||
|
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 30, 62, 12);
|
|||
|
g.FillRectangle(BodyBrush, _startPosX.Value + 22, _startPosY.Value + 16, 4, 15);
|
|||
|
g.DrawRectangle(pen, _startPosX.Value + 22, _startPosY.Value + 16, 4, 14);
|
|||
|
g.FillRectangle(BodyBrush, _startPosX.Value + 37, _startPosY.Value + 1, 5, 30);
|
|||
|
g.DrawRectangle(pen, _startPosX.Value + 37, _startPosY.Value + 1, 5, 30);
|
|||
|
|
|||
|
//стекло
|
|||
|
g.FillRectangle(additionalBrush, _startPosX.Value + 52, _startPosY.Value + 14, 21, 16);
|
|||
|
g.DrawRectangle(pen, _startPosX.Value + 52, _startPosY.Value + 14, 20, 16);
|
|||
|
|
|||
|
//гусеницы
|
|||
|
g.DrawLine(pen, _startPosX.Value + 8, _startPosY.Value + 42, _startPosX.Value + 10, _startPosY.Value + 42);
|
|||
|
g.DrawLine(pen, _startPosX.Value + 7, _startPosY.Value + 43, _startPosX.Value + 7, _startPosY.Value + 53);
|
|||
|
g.DrawLine(pen, _startPosX.Value + 8, _startPosY.Value + 54, _startPosX.Value + 12, _startPosY.Value + 54);
|
|||
|
g.DrawLine(pen, _startPosX.Value + 13, _startPosY.Value + 55, _startPosX.Value + 69, _startPosY.Value + 55);
|
|||
|
g.DrawLine(pen, _startPosX.Value + 70, _startPosY.Value + 54, _startPosX.Value + 73, _startPosY.Value + 54);
|
|||
|
g.DrawLine(pen, _startPosX.Value + 74, _startPosY.Value + 53, _startPosX.Value + 74, _startPosY.Value + 43);
|
|||
|
g.DrawLine(pen, _startPosX.Value + 71, _startPosY.Value + 42, _startPosX.Value + 73, _startPosY.Value + 42);
|
|||
|
|
|||
|
//колеса
|
|||
|
g.FillEllipse(BodyBrush, _startPosX.Value + 10, _startPosY.Value + 44, 9, 9);
|
|||
|
g.DrawEllipse(pen, _startPosX.Value + 10, _startPosY.Value + 44, 9, 9);
|
|||
|
g.FillEllipse(BodyBrush, _startPosX.Value + 63, _startPosY.Value + 44, 9, 9);
|
|||
|
g.DrawEllipse(pen, _startPosX.Value + 63, _startPosY.Value + 44, 9, 9);
|
|||
|
|
|||
|
g.FillEllipse(BodyBrush, _startPosX.Value + 25, _startPosY.Value + 48, 6, 6);
|
|||
|
g.DrawEllipse(pen, _startPosX.Value + 25, _startPosY.Value + 48, 6, 6);
|
|||
|
g.FillEllipse(BodyBrush, _startPosX.Value + 38, _startPosY.Value + 48, 6, 6);
|
|||
|
g.DrawEllipse(pen, _startPosX.Value + 38, _startPosY.Value + 48, 6, 6);
|
|||
|
g.FillEllipse(BodyBrush, _startPosX.Value + 50, _startPosY.Value + 48, 6, 6);
|
|||
|
g.DrawEllipse(pen, _startPosX.Value + 50, _startPosY.Value + 48, 6, 6);
|
|||
|
|
|||
|
g.FillEllipse(BodyBrush, _startPosX.Value + 33, _startPosY.Value + 44, 4, 4);
|
|||
|
g.DrawEllipse(pen, _startPosX.Value + 33, _startPosY.Value + 44, 4, 4);
|
|||
|
g.FillEllipse(BodyBrush, _startPosX.Value + 45, _startPosY.Value + 44, 4, 4);
|
|||
|
g.DrawEllipse(pen, _startPosX.Value + 45, _startPosY.Value + 44, 4, 4);
|
|||
|
|
|||
|
|
|||
|
|
|||
|
_startPosX += 10;
|
|||
|
_startPosY += 25;
|
|||
|
base.DrawTransport(g);
|
|||
|
_startPosX -= 10;
|
|||
|
_startPosY -= 25;
|
|||
|
|
|||
|
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);
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|