PIbd-22_Shabunov_O.A._AirBo.../AirBomber/Rendering/BomberRenderer.cs

62 lines
2.4 KiB
C#
Raw Normal View History

using AirBomber.Entities;
namespace AirBomber.Rendering
{
public class BomberRenderer : BomberRendererBase
{
public BomberRenderer(int Speed, double Weight, Color BodyColor, Color AdditionalColor, bool FuelTanks, bool Bombs, int Width, int Height)
: base(Speed, Weight, BodyColor, Width, Height, 200, 200)
{
if (EntityBomber is not null)
EntityBomber = new BomberEntity(Speed, Weight, BodyColor, AdditionalColor, FuelTanks, Bombs);
}
public override void DrawEntity(Graphics g)
{
if (EntityBomber is not BomberEntity DerivedEntityBomber)
return;
base.DrawEntity(g);
Brush AdditionalBrush = new SolidBrush(DerivedEntityBomber.AdditionalColor);
/** Отрисовка дополнительных элементов */
if (DerivedEntityBomber.FuelTanks)
{
Point[] LeftGasTank = {
new Point(_startPosX + 50, _startPosY + 85),
new Point(_startPosX + 75, _startPosY + 85),
new Point(_startPosX + 75, _startPosY + 70),
new Point(_startPosX + 50, _startPosY + 70),
};
g.FillPolygon(AdditionalBrush, LeftGasTank);
Point[] RightGasTank = {
new Point(_startPosX + 50, _startPosY + 115),
new Point(_startPosX + 75, _startPosY + 115),
new Point(_startPosX + 75, _startPosY + 130),
new Point(_startPosX + 50, _startPosY + 130),
};
g.FillPolygon(AdditionalBrush, RightGasTank);
}
if (DerivedEntityBomber.Bombs)
{
Point LeftBombStartXY = new Point(_startPosX + 110, _startPosY + 115);
Size LeftBombSize = new Size(50, 25);
g.FillEllipse(AdditionalBrush, new Rectangle(LeftBombStartXY, LeftBombSize));
Point RightBombStartXY = new Point(_startPosX + 110, _startPosY + 60);
Size RightBombSize = new Size(50, 25);
g.FillEllipse(AdditionalBrush, new Rectangle(RightBombStartXY, RightBombSize));
}
}
public void SetAdditionalColor(Color AdditionalColor)
{
if (EntityBomber is BomberEntity AdvancedBomber)
AdvancedBomber.SetAdditionalColor(AdditionalColor);
}
}
}