2024-05-07 23:59:46 +04:00

77 lines
3.2 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 ProjectSeaplane.Entities;
using System.Windows.Forms.Design.Behavior;
namespace ProjectSeaplane.Drawnings;
/// <summary>
/// Отрисовка и перемещение
/// </summary>
public class DrawingSeaplane : DrawingBasicSeaplane
{
/// <summary>
/// Ширина прорисовки автомобиля
/// </summary>
private readonly int _drawningSeaplaneWidth = 170;
/// <summary>
/// Высота прорисовки автомобиля
/// </summary>
private readonly int _drawningSeaplaneHeight = 90;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="landingGear">Тип "шасси" (0 - поплавки, 1 - лодочный тип)</param>
/// <param name="radar">Признак наличия радара </param>
public DrawingSeaplane(int speed, double weight, Color bodyColor, Color additionalColor, bool landingGear, bool radar) : base(155, 70)
{
EntityBasicSeaplane = new EntitySeaplane(speed, weight, bodyColor, additionalColor, landingGear, radar);
}
public DrawingSeaplane(EntitySeaplane seaplane) : base(155, 70)
{
EntityBasicSeaplane = new EntitySeaplane(seaplane.Speed, seaplane.Weight, seaplane.BodyColor, seaplane.AdditionalColor, seaplane.LandingGear, seaplane.Radar);
}
public override void DrawTransport(Graphics g)
{
if (EntityBasicSeaplane == null || EntityBasicSeaplane is not EntitySeaplane seaplane || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
Brush brAdditional = new SolidBrush(seaplane.AdditionalColor);
Pen penKraya = new(Color.Black, 2);
if (seaplane.LandingGear)
{
g.FillEllipse(brAdditional, _startPosX.Value + 60, _startPosY.Value + 60, 70, 10);
g.FillEllipse(brAdditional, _startPosX.Value + 10, _startPosY.Value + 60, 20, 10);
g.DrawLine(penKraya, _startPosX.Value + 20, _startPosY.Value + 53, _startPosX.Value + 20, _startPosY.Value + 63);
g.DrawLine(penKraya, _startPosX.Value + 110, _startPosY.Value + 53, _startPosX.Value + 90, _startPosY.Value + 63);
g.DrawLine(penKraya, _startPosX.Value + 70, _startPosY.Value + 53, _startPosX.Value + 90, _startPosY.Value + 63);
}
base.DrawTransport(g);
if (seaplane.Radar)
{
Point point5 = new Point(_startPosX.Value + 50, _startPosY.Value + 22);
Point point6 = new Point(_startPosX.Value + 45, _startPosY.Value + 30);
Point point7 = new Point(_startPosX.Value + 55, _startPosY.Value + 30);
Point point8 = new Point(_startPosX.Value + 50, _startPosY.Value + 22);
Point[] Radar =
{
point5, point6 , point7 , point8
};
g.FillEllipse(brAdditional, _startPosX.Value + 30, _startPosY.Value + 12, 40, 15);
g.FillPolygon(brAdditional, Radar);
}
}
}