107 lines
5.0 KiB
C#
107 lines
5.0 KiB
C#
using AirBomber.Entities;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Net.Http.Headers;
|
||
using System.Security.Cryptography.X509Certificates;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace AirBomber.Drawnings;
|
||
|
||
/// <summary>
|
||
/// Класс, отвечающий за отрисовку и перемещение объекта-сущности
|
||
/// </summary>
|
||
public class DrawningAirBomber : DrawningAirPlane
|
||
{
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="speed">Скорость</param>
|
||
/// <param name="weight">Вес</param>
|
||
/// <param name="bodyColor">Основной цвет</param>
|
||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||
/// <param name="bombs">Признак наличия бомб</param>
|
||
/// <param name="fuelTanks">Признак наличия дополнительный топливных баков</param>
|
||
public DrawningAirBomber(int speed, double weight, Color bodyColor, Color additionalColor, bool bombs, bool fuelTanks) : base(140, 128)
|
||
{
|
||
EntityAirPlane = new EntityAirBomber(speed, weight, bodyColor, additionalColor, bombs, fuelTanks);
|
||
}
|
||
|
||
/// <summary>
|
||
/// Конструктор через сущность
|
||
/// </summary>
|
||
/// <param name="entityAirPlane"></param>
|
||
public DrawningAirBomber(EntityAirPlane entityAirPlane) : base()
|
||
{
|
||
EntityAirPlane = entityAirPlane;
|
||
}
|
||
public override void DrawTransport(Graphics g)
|
||
{
|
||
if (EntityAirPlane == null || EntityAirPlane is not EntityAirBomber airbomber || !_startPosX.HasValue || !_startPosY.HasValue)
|
||
{
|
||
return;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// Установка границ поля
|
||
/// </summary>
|
||
/// <param name="width"><Ширина/param>
|
||
/// <param name="height">Высота</param>
|
||
/// <returns></returns>
|
||
|
||
/// <summary>
|
||
/// Прорисовка объекта
|
||
/// </summary>
|
||
/// <param name="g"></param>
|
||
|
||
|
||
Pen pen = new(Color.Black);
|
||
Brush additionalBrush = new
|
||
SolidBrush(airbomber.AdditionalColor);
|
||
|
||
if (airbomber.FuelTanks)
|
||
{
|
||
//Дополнительные топливные баки
|
||
g.FillEllipse(additionalBrush, _startPosX.Value + 90, _startPosY.Value + 50, 29, 29);
|
||
g.DrawEllipse(pen, _startPosX.Value + 90, _startPosY.Value + 50, 29, 29);
|
||
|
||
g.FillEllipse(additionalBrush, _startPosX.Value + 30, _startPosY.Value + 50, 29, 29);
|
||
g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value + 50, 29, 29);
|
||
|
||
}
|
||
|
||
|
||
Brush brGreen = new SolidBrush(Color.Green);
|
||
Brush brRed = new SolidBrush(Color.Red);
|
||
Brush BodyBrush = new SolidBrush(airbomber.BodyColor);
|
||
|
||
|
||
//Бомбы
|
||
if (airbomber.Bombs)
|
||
{
|
||
Point[] Bomb1Point = { new Point(_startPosX.Value + 77, _startPosY.Value + 125), new Point(_startPosX.Value + 84, _startPosY.Value + 128), new Point(_startPosX.Value + 84, _startPosY.Value + 120), new Point(_startPosX.Value + 79, _startPosY.Value + 122) };
|
||
g.FillPolygon(brGreen, Bomb1Point);
|
||
g.DrawLine(pen, _startPosX.Value + 77, _startPosY.Value + 125, _startPosX.Value + 84, _startPosY.Value + 128);
|
||
g.DrawLine(pen, _startPosX.Value + 84, _startPosY.Value + 128, _startPosX.Value + 84, _startPosY.Value + 120);
|
||
g.DrawLine(pen, _startPosX.Value + 84, _startPosY.Value + 120, _startPosX.Value + 79, _startPosY.Value + 122);
|
||
g.FillRectangle(brGreen, _startPosX.Value + 65, _startPosY.Value + 121, 5, 5);
|
||
g.DrawRectangle(pen, _startPosX.Value + 65, _startPosY.Value + 121, 5, 5);
|
||
Point[] BombNose1Point = { new Point(_startPosX.Value + 65, _startPosY.Value + 119), new Point(_startPosX.Value + 60, _startPosY.Value + 123), new Point(_startPosX.Value + 65, _startPosY.Value + 128) };
|
||
g.FillPolygon(brRed, BombNose1Point);
|
||
|
||
Point[] Bomb2Point = { new Point(_startPosX.Value + 77, _startPosY.Value + 3), new Point(_startPosX.Value + 84, _startPosY.Value), new Point(_startPosX.Value + 84, _startPosY.Value + 8), new Point(_startPosX.Value + 79, _startPosY.Value + 6) };
|
||
g.FillPolygon(brGreen, Bomb2Point);
|
||
g.DrawLine(pen, _startPosX.Value + 77, _startPosY.Value + 3, _startPosX.Value + 84, _startPosY.Value);
|
||
g.DrawLine(pen, _startPosX.Value + 84, _startPosY.Value, _startPosX.Value + 84, _startPosY.Value + 8);
|
||
g.DrawLine(pen, _startPosX.Value + 84, _startPosY.Value + 8, _startPosX.Value + 79, _startPosY.Value + 6);
|
||
g.FillRectangle(brGreen, _startPosX.Value + 65, _startPosY.Value + 2, 5, 5);
|
||
g.DrawRectangle(pen, _startPosX.Value + 65, _startPosY.Value + 2, 5, 5);
|
||
Point[] BombNose2Point = { new Point(_startPosX.Value + 65, _startPosY.Value + 9), new Point(_startPosX.Value + 60, _startPosY.Value + 5), new Point(_startPosX.Value + 65, _startPosY.Value) };
|
||
g.FillPolygon(brRed, BombNose2Point);
|
||
}
|
||
base.DrawTransport(g);
|
||
}
|
||
}
|