PIBD-14_Khalikova.A.R_Storm.../ProjectStormtrooper/Drawnings/DrawingStormtrooper.cs

71 lines
2.6 KiB
C#

using ProjectStormtrooper.Entities;
namespace ProjectStormtrooper.Drawnings;
/// <summary>
/// Класс отвечающий за прорисовку и перемещение объекта-сущности
/// </summary>
public class DrawingStormtrooper: DrawningStormtrooperBase
{
/// <summary>
/// Конструктор
/// </summary>
/// <param name="speed"></param>
/// <param name="weight"></param>
/// <param name="bodyColor"></param>
/// <param name="additionalColor"></param>
/// <param name="rockets"></param>
/// <param name="bombs"></param>
public DrawingStormtrooper(int speed,double weight, Color bodyColor,Color additionalColor, bool rockets, bool bombs):base(140,140)
{
EntityStormtrooperBase = new EntityStormtrooper(speed, weight, bodyColor, additionalColor, rockets, bombs);
}
public DrawingStormtrooper(EntityStormtrooper entityStormtrooperBase) : base(140, 135)
{
EntityStormtrooperBase = new EntityStormtrooper(entityStormtrooperBase.Speed, entityStormtrooperBase.Weight, entityStormtrooperBase.BodyColor, entityStormtrooperBase.AdditionalColor, entityStormtrooperBase.Bombs, entityStormtrooperBase.Rockets);
}
/// <summary>
/// Прорисовка объекта
/// </summary>
/// <param name="q"></param>
public override void DrawTransport(Graphics g)
{
if (EntityStormtrooperBase == null || EntityStormtrooperBase is not EntityStormtrooper stormtrooper || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
Pen pen = new(Color.Black);
Brush additionalBrush = new SolidBrush(stormtrooper.AdditionalColor);
base.DrawTransport(g);
//ракеты штурмовика
if (stormtrooper.Rockets)
{
g.FillRectangle(additionalBrush, _startPosX.Value + 45, _startPosY.Value + 20, 15, 5);
g.FillRectangle(additionalBrush, _startPosX.Value + 45, _startPosY.Value + 110, 15, 5);
g.DrawRectangle(pen, _startPosX.Value + 45, _startPosY.Value + 20, 15, 5);
g.DrawRectangle(pen, _startPosX.Value + 45, _startPosY.Value + 110, 15, 5);
}
//бомбы штурмовика
if (stormtrooper.Bombs)
{
g.FillRectangle(additionalBrush, _startPosX.Value + 50, _startPosY.Value + 40, 10, 10);
g.FillRectangle(additionalBrush, _startPosX.Value + 50, _startPosY.Value + 90, 10, 10);
g.DrawRectangle(pen, _startPosX.Value + 50, _startPosY.Value + 40, 10, 10);
g.DrawRectangle(pen, _startPosX.Value + 50, _startPosY.Value + 90, 10, 10);
}
}
}