69 lines
2.8 KiB
C#
69 lines
2.8 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel.DataAnnotations;
|
||
using System.Drawing;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace AirBomber
|
||
{
|
||
internal class DrawningAirBomber : DrawningAirplane
|
||
{
|
||
/// <summary>
|
||
/// Инициализация свойств
|
||
/// </summary>
|
||
/// <param name="speed">Скорость</param>
|
||
/// <param name="weight">Вес самолета</param>
|
||
/// <param name="bodyColor">Цвет обшивки</param>
|
||
/// <param name="dopColor">Дополнительный цвет</param>
|
||
/// <param name="hasBombs">Признак наличия бомб</param>
|
||
/// <param name="hasFuelTanks">Признак наличия топливных баков</param>
|
||
/// <param name="typeAirplaneEngines">Какой будет двигатель самолета. null - двигатели отсутствуют</param>
|
||
public DrawningAirBomber(int speed, float weight, Color bodyColor, Color dopColor, bool hasBombs, bool hasFuelTanks, IAirplaneEngines? typeAirplaneEngines = null)
|
||
: base(speed, weight, bodyColor, 115, 155, typeAirplaneEngines)
|
||
{
|
||
Airplane = new EntityAirBomber(speed, weight, bodyColor, dopColor, hasBombs, hasFuelTanks);
|
||
}
|
||
|
||
public override void DrawTransport(Graphics g)
|
||
{
|
||
if (Airplane is not EntityAirBomber airBomber)
|
||
{
|
||
return;
|
||
}
|
||
|
||
var x = _startPosX;
|
||
var y = _startPosY;
|
||
var w = _airplaneWidth;
|
||
var h = _airplaneHeight;
|
||
Brush brush = new SolidBrush(airBomber.DopColor);
|
||
|
||
if (airBomber.HasBombs) // Бомбы снизу рисуются сначала
|
||
{
|
||
DrawBomb(g, airBomber.DopColor, new RectangleF(x + w / 2 - 15, y + h / 2 - 19, 23, 10));
|
||
DrawBomb(g, airBomber.DopColor, new RectangleF(x + w / 2 - 15, y + h / 2 + 9, 23, 10));
|
||
}
|
||
|
||
base.DrawTransport(g);
|
||
|
||
if (airBomber.HasFuelTanks)
|
||
{
|
||
g.FillEllipse(brush, new RectangleF(x + w / 4, y + h / 2 - 6, w / 2.5f, 12));
|
||
}
|
||
}
|
||
|
||
private void DrawBomb(Graphics g, Color colorBomb, RectangleF r)
|
||
{
|
||
Pen pen = new(colorBomb);
|
||
pen.Width = r.Height / 3;
|
||
var widthTail = r.Width / 6;
|
||
g.FillEllipse(new SolidBrush(colorBomb), r.X, r.Y, r.Width - widthTail, r.Height); // Основание бомбы
|
||
// Хвост бомбы
|
||
var baseTail = new PointF(r.Right - widthTail, r.Y + r.Height / 2);
|
||
g.DrawLine(pen, baseTail, new PointF(r.Right, r.Top));
|
||
g.DrawLine(pen, baseTail, new PointF(r.Right, r.Bottom));
|
||
}
|
||
}
|
||
}
|