diff --git a/Stormtrooper/Stormtrooper/DirectionType.cs b/Stormtrooper/Stormtrooper/Drawnings/DirectionType.cs similarity index 87% rename from Stormtrooper/Stormtrooper/DirectionType.cs rename to Stormtrooper/Stormtrooper/Drawnings/DirectionType.cs index cf5dd7d..e30a328 100644 --- a/Stormtrooper/Stormtrooper/DirectionType.cs +++ b/Stormtrooper/Stormtrooper/Drawnings/DirectionType.cs @@ -4,17 +4,17 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Stormtrooper +namespace Stormtrooper.Drawnings { public enum DirectionType { Up = 1, Down = 2, - + Left = 3, Right = 4, - + } } diff --git a/Stormtrooper/Stormtrooper/Drawnings/DrawningAircraft.cs b/Stormtrooper/Stormtrooper/Drawnings/DrawningAircraft.cs new file mode 100644 index 0000000..94c3524 --- /dev/null +++ b/Stormtrooper/Stormtrooper/Drawnings/DrawningAircraft.cs @@ -0,0 +1,125 @@ +using Stormtrooper.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Stormtrooper.Drawnings; + +public class DrawningAircraft +{ + // Класс-сущность + public EntityAircraft? EntityAircraft { get; private set; } // объявление 1 + + // Ширина окна + + public int? _pictureWidth; + + // Высота окна + + public int? _pictureHeight; + + // Левая координата прорисовки штурмовика + + protected int? _startPosX; + + // Верхняя координата прорисовки автомобиля + + protected int? _startPosY; + + // Ширина прорисовки штурмовика + + private readonly int _drawningAircraftWidth = 120; + + // Высота прорисовки штурмовика + + private readonly int _drawningAircraftHeight = 140; + + // Пустой конструктор + private DrawningAircraft() + { + _pictureWidth = null; + _pictureHeight = null; + _startPosX = null; + _startPosY = null; + } + // Конструктор + + /// Скорость + /// Вес + /// Основной цвет + public DrawningAircraft(int speed, double weight, Color bodyColor) : this() + { + EntityAircraft = new EntityAircraft(speed, weight, bodyColor); + } + + // Конструктор для наследников + + /// Ширина прорисовки штурмовика + /// Высота прорисовки штурмовика + protected DrawningAircraft(int drawningAircraftWidth, int drawningAircraftHeight) : this() + { + _drawningAircraftWidth = drawningAircraftWidth; + _pictureHeight = drawningAircraftHeight; + } + + /// Прорисовка объекта + /// + public virtual void DrawTransport(Graphics g) + { + if (EntityAircraft == null || !_startPosX.HasValue || !_startPosY.HasValue) + { + return; + } + + Pen pen = new(Color.Black); + Brush bodyColorBrush = new SolidBrush(EntityAircraft.BodyColor); + + //нос штурмовика + Brush brBlack = new SolidBrush(Color.Black); + + Point[] Nose = new Point[3]; + Nose[0].X = _startPosX.Value + 10; Nose[0].Y = _startPosY.Value + 70; + Nose[1].X = _startPosX.Value + 10; Nose[1].Y = _startPosY.Value + 50; + Nose[2].X = _startPosX.Value - 10; Nose[2].Y = _startPosY.Value + 60; + g.FillPolygon(brBlack, Nose); + g.DrawPolygon(pen, Nose); + //Заднии крылья штурмовика + + Point[] pflybtwings = new Point[6]; + pflybtwings[0].X = _startPosX.Value + 110; pflybtwings[0].Y = _startPosY.Value + 50; + pflybtwings[1].X = _startPosX.Value + 110; pflybtwings[1].Y = _startPosY.Value + 40; + pflybtwings[2].X = _startPosX.Value + 130; pflybtwings[2].Y = _startPosY.Value + 20; + pflybtwings[3].X = _startPosX.Value + 130; pflybtwings[3].Y = _startPosY.Value + 100; + pflybtwings[4].X = _startPosX.Value + 110; pflybtwings[4].Y = _startPosY.Value + 80; + pflybtwings[5].X = _startPosX.Value + 110; pflybtwings[5].Y = _startPosY.Value + 70; + g.FillPolygon(bodyColorBrush, pflybtwings); + g.DrawPolygon(pen, pflybtwings); + //Тело штурмовика + g.FillRectangle(bodyColorBrush, _startPosX.Value + 10, _startPosY.Value + 50, 120, 20); + g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 50, 120, 20); + + + //Крылья штурмовика + + + Point[] frontwings = new Point[4]; + frontwings[0].X = _startPosX.Value + 50; frontwings[0].Y = _startPosY.Value + 50; + frontwings[1].X = _startPosX.Value + 50; frontwings[1].Y = _startPosY.Value - 10; + frontwings[2].X = _startPosX.Value + 60; frontwings[2].Y = _startPosY.Value - 10; + frontwings[3].X = _startPosX.Value + 70; frontwings[3].Y = _startPosY.Value + 50; + g.FillPolygon(bodyColorBrush, frontwings); + g.DrawPolygon(pen, frontwings); + + Point[] frontwings2 = new Point[4]; + frontwings2[0].X = _startPosX.Value + 50; frontwings2[0].Y = _startPosY.Value + 70; + frontwings2[1].X = _startPosX.Value + 50; frontwings2[1].Y = _startPosY.Value + 130; + frontwings2[2].X = _startPosX.Value + 60; frontwings2[2].Y = _startPosY.Value + 130; + frontwings2[3].X = _startPosX.Value + 70; frontwings2[3].Y = _startPosY.Value + 70; + g.FillPolygon(bodyColorBrush, frontwings2); + g.DrawPolygon(pen, frontwings2); + + + } +} diff --git a/Stormtrooper/Stormtrooper/DrawningStormtrooper.cs b/Stormtrooper/Stormtrooper/Drawnings/DrawningStormtrooper.cs similarity index 94% rename from Stormtrooper/Stormtrooper/DrawningStormtrooper.cs rename to Stormtrooper/Stormtrooper/Drawnings/DrawningStormtrooper.cs index 937731a..eb60a20 100644 --- a/Stormtrooper/Stormtrooper/DrawningStormtrooper.cs +++ b/Stormtrooper/Stormtrooper/Drawnings/DrawningStormtrooper.cs @@ -7,12 +7,11 @@ using System.Reflection.Metadata; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using Stormtrooper.Entities; -namespace Stormtrooper; -public class DrawningStormtrooper +namespace Stormtrooper.Drawnings; +public class DrawningStormtrooper : DrawningAircraft { - // Класс-сущность - public EntityStormtrooper? EntityStormtrooper { get; private set; } // объявление // Ширина окна @@ -47,15 +46,12 @@ public class DrawningStormtrooper /// Признак наличия ракет /// Признак наличия бомбы /// Признак наличия крыла - public void Init(int speed, double weight, Color bodyColor, Color + public DrawningStormtrooper(int speed, double weight, Color bodyColor, Color additionalColor, bool rocket, bool bomb, bool wing) { - EntityStormtrooper = new EntityStormtrooper(); // инициализация - EntityStormtrooper.Init(speed, weight, bodyColor, additionalColor,rocket, bomb, wing); - _pictureWidth = null; - _pictureHeight = null; - _startPosX = null; - _startPosY = null; + EntityStormtrooper = new EntityStormtrooper(); + EntityStormtrooper.Init(speed, weight, bodyColor, additionalColor, rocket, bomb, wing); + } // Установка границ поля diff --git a/Stormtrooper/Stormtrooper/Entities/EntityAircraft.cs b/Stormtrooper/Stormtrooper/Entities/EntityAircraft.cs new file mode 100644 index 0000000..c81d626 --- /dev/null +++ b/Stormtrooper/Stormtrooper/Entities/EntityAircraft.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.NetworkInformation; +using System.Net.Sockets; +using System.Text; +using System.Threading.Tasks; + +namespace Stormtrooper.Entities; + +// Класс-сущность "самолет" +public class EntityAircraft +{ + public int Speed { get; private set; } + // скорость + public double Weight { get; private set; } + // вес + public Color BodyColor { get; private set; } + // цвет + public double Step => Speed * 100 / Weight; + // шаг в поле + /// Конструктор сущности + /// Скорость + /// Вес штурмовика + /// Основной цвет + + public EntityAircraft(int speed, double weight, Color bodyColor) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + + } +} diff --git a/Stormtrooper/Stormtrooper/Entities/EntityStormtrooper.cs b/Stormtrooper/Stormtrooper/Entities/EntityStormtrooper.cs new file mode 100644 index 0000000..da05b84 --- /dev/null +++ b/Stormtrooper/Stormtrooper/Entities/EntityStormtrooper.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Stormtrooper.Entities; + +public class EntityStormtrooper : EntityAircraft +{ + public int Speed { get; private set; } + // скорость + public double Weight { get; private set; } + // вес + public Color BodyColor { get; private set; } + // цвет + public Color AdditionalColor { get; private set; } + // дополнительные цвета + public bool Rocket { get; private set; } + // ракета + public bool Bomb { get; private set; } + // бомба + public bool Wing { get; private set; } + // крыло + + /// Инициализация полей объекта-класса штурмовика + + /// Скорость + /// Вес штурмовика + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия ракет + /// Признак наличия бомб + /// Признак наличия крыла а + + public EntityStormtrooper(int speed, double weight, Color bodyColor, Color + additionalColor, bool rocket, bool bomb, bool wing) : base(speed, weight, bodyColor) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + AdditionalColor = additionalColor; + Rocket = rocket; + Bomb = bomb; + Wing = wing; + } +} diff --git a/Stormtrooper/Stormtrooper/EntityStormtrooper.cs b/Stormtrooper/Stormtrooper/EntityStormtrooper.cs deleted file mode 100644 index 3a6e4cf..0000000 --- a/Stormtrooper/Stormtrooper/EntityStormtrooper.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Stormtrooper -{ - public class EntityStormtrooper - { - public int Speed { get; private set; } - // скорость - public double Weight { get; private set; } - // вес - public Color BodyColor { get; private set; } - // цвет - public Color AdditionalColor { get; private set; } - // дополнительные цвета - public bool Rocket { get; private set; } - // ракета - public bool Bomb { get; private set; } - // бомба - public bool Wing { get; private set; } - // крыло - public double Step => Speed * 100 / Weight; - // шаг в поле - - /// Инициализация полей объекта-класса штурмовика - - /// Скорость - /// Вес штурмовика - /// Основной цвет - /// Дополнительный цвет - /// Признак наличия ракет - /// Признак наличия бомб - /// Признак наличия крыла а - - public void Init(int speed, double weight, Color bodyColor, Color - additionalColor, bool rocket, bool bomb, bool wing) - { - Speed = speed; - Weight = weight; - BodyColor = bodyColor; - AdditionalColor = additionalColor; - Rocket = rocket; - Bomb = bomb; - Wing = wing; - } - } -} diff --git a/Stormtrooper/Stormtrooper/FormStormtrooper.cs b/Stormtrooper/Stormtrooper/FormStormtrooper.cs index 00bc307..58c6536 100644 --- a/Stormtrooper/Stormtrooper/FormStormtrooper.cs +++ b/Stormtrooper/Stormtrooper/FormStormtrooper.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using Stormtrooper.Drawnings; namespace Stormtrooper {