PIbd-12_Alkin_D.V_AirBomber.../AirBomber/Drawnings/DrawningAirBomber.cs
2024-05-21 00:47:54 +04:00

107 lines
5.0 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 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);
}
}