PIbd-14_Pruidze_I.K_Simple_.../ProjectCruiser/DrawningSamples/DrawningCruiser.cs

55 lines
1.9 KiB
C#
Raw Permalink Normal View History

2024-06-12 19:21:59 +04:00
using System.Drawing.Drawing2D;
using ProjectCruiser.Entities;
namespace ProjectCruiser.DrawningSamples;
public class DrawningCruiser : DrawningBase
{
// Инициализация свойств (все параметры класса (сущности))
public DrawningCruiser(int speed, double weight, Color bodyColor,
Color additionalColor, bool pads, bool hangar) : base(302, 42)
// all additional featchures 'inside' object, so size remains
{
EntityTransport = new EntityCruiser(speed, weight,
bodyColor, additionalColor, pads, hangar);
}
public override void DrawTransport(Graphics g)
{
if (EntityTransport == null || EntityTransport is not EntityCruiser ship ||
!_startPosX.HasValue || !_startPosY.HasValue) // [ !!! ] :O
{
return;
}
Pen pen = new(Color.Black, 2);
Brush PadBrush = new HatchBrush(HatchStyle.DottedDiamond, Color.LightGray, Color.Black);
Brush additionalBrush = new SolidBrush(ship.AdditionalColor);
//границы cruiser <...>
// &
// салон на верхней палубе :
base.DrawTransport(g);
// вертолетная площадка
if (ship.HelicopterPads)
{
g.DrawEllipse(pen, _startPosX.Value + 170, _startPosY.Value + 11, 20, 20);
g.FillEllipse(PadBrush, _startPosX.Value + 170, _startPosY.Value + 11, 20, 20);
}
// ангар
if (ship.Hangar)
{
int n = EntityTransport.values[2];
if (n == 1) g.FillRectangle(additionalBrush, _startPosX.Value + 250, _startPosY.Value + 20, 14, 7);
else
{
g.FillRectangle(additionalBrush, _startPosX.Value + 80, _startPosY.Value + 10, 10, 20);
g.FillRectangle(additionalBrush, _startPosX.Value + 70, _startPosY.Value + 12, 8, 12);
}
}
}
}