PIBD-13_Fomichev_V.S._Simple_/AntiAircraftGun/Drawnings/DrawningAntiAircraftGun.cs

64 lines
2.9 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 AntiAircraftGun.Entities;
namespace AntiAircraftGun.Drawnings;
/// <summary>
/// Класс отвечающий за прорисовку и перемещение объекта - сущности
/// </summary>
public class DrawningAntiAircraftGun : DrawningAircraftGun
{
/// <summary>
/// Конструктор
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="bodyKit">Признак наличия обвесов</param>
/// <param name="tower">Признак наличия башни</param>
/// <param name="radar">Признак наличия радара</param>
public DrawningAntiAircraftGun(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool radar, bool tower) : base(129, 60)
{
EntityAircraftGun = new EntityAntiAircraftGun(speed, weight, bodyColor, radar, tower, bodyKit, additionalColor);
}
/// <summary>
/// Прорисовка объекта
/// </summary>
/// <param name="g"></param>
public override void DrawTransport(Graphics g)
{
if (EntityAircraftGun == null || EntityAircraftGun is not EntityAntiAircraftGun aircraftGun || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
Pen pen = new(Color.Black);
Brush additionalBrush = new SolidBrush(aircraftGun.AdditionalColor);
base.DrawTransport(g);
if (aircraftGun.Tower)
{
g.FillRectangle(additionalBrush, _startPosX.Value + 35, _startPosY.Value + 50, 35, 15);
g.DrawRectangle(pen, _startPosX.Value + 35, _startPosY.Value + 50, 35, 15);
g.DrawLine(pen, _startPosX.Value + 45, _startPosY.Value + 50, _startPosX.Value + 90, _startPosY.Value + 20);
g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value + 50, _startPosX.Value + 95, _startPosY.Value + 27);
g.DrawLine(pen, _startPosX.Value + 45, _startPosY.Value + 50, _startPosX.Value + 60, _startPosY.Value + 50);
g.DrawLine(pen, _startPosX.Value + 90, _startPosY.Value + 20, _startPosX.Value + 95, _startPosY.Value + 27);
g.DrawLine(pen, _startPosX.Value + 90, _startPosY.Value + 20, _startPosX.Value + 100, _startPosY.Value + 20);
g.DrawLine(pen, _startPosX.Value + 100, _startPosY.Value + 20, _startPosX.Value + 95, _startPosY.Value + 27);
}
if (aircraftGun.Radar)
{
g.DrawLine(pen, _startPosX.Value + 20, _startPosY.Value + 65, _startPosX.Value + 20, _startPosY.Value + 40);
g.FillRectangle(additionalBrush, _startPosX.Value + 10, _startPosY.Value + 40, 20, 20);
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 40, 20, 20);
}
}
}