64 lines
2.5 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 ProjectTank.Entities;
namespace ProjectTank.Drawnings;
/// <summary>
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
/// </summary>
public class DrawningTank1 : DrawningTank2
{
/// <summary>
/// Конструктор
/// <summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес автомобиля</param>
/// <param name="bodyColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="gun">Признак наличия пушки</param>
/// <param name="machinGun">признак наличия пулемета</param>
///
public DrawningTank1(int speed, double weight, Color bodyColor, Color additionalColor, bool gun, bool machinGun) : base(150, 87)
{
EntityTank2 = new EntityTank1(speed, weight, bodyColor, additionalColor, gun, machinGun);
}
/// <summary>
/// Прорисовка объекта
/// </summary>
/// <param name="g"></param>
public override void DrawTransport(Graphics g)
{
if (EntityTank2 == null || EntityTank2 is not EntityTank1 Tank1 || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
Pen pen = new(Color.Black);
Brush additionalBrush = new SolidBrush(Tank1.AdditionalColor);
if (Tank1.Gun)
{
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 30, 45, 5);
g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value + 30, 45, 5);
}
//пулемет
if (Tank1.MachinGun)
{
g.DrawRectangle(pen, _startPosX.Value + 65, _startPosY.Value + 15, 16, 5);
g.DrawRectangle(pen, _startPosX.Value + 72, _startPosY.Value + 10, 5, 5);
g.DrawRectangle(pen, _startPosX.Value + 71, _startPosY.Value + 3, 7, 7);
g.DrawRectangle(pen, _startPosX.Value + 55, _startPosY.Value + 5, 15, 3);
g.FillRectangle(additionalBrush, _startPosX.Value + 65, _startPosY.Value + 15, 16, 5);
g.FillRectangle(additionalBrush, _startPosX.Value + 72, _startPosY.Value + 10, 5, 5);
g.FillRectangle(additionalBrush, _startPosX.Value + 71, _startPosY.Value + 3, 7, 7);
g.FillRectangle(additionalBrush, _startPosX.Value + 55, _startPosY.Value + 5, 15, 3);
}
_startPosY += 20;
base.DrawTransport(g);
_startPosY -= 20;
}
}