diff --git a/Airbus/Airbus/DrawingAirbus.cs b/Airbus/Airbus/DrawningAirbus.cs similarity index 93% rename from Airbus/Airbus/DrawingAirbus.cs rename to Airbus/Airbus/DrawningAirbus.cs index 7452b16..f457f5a 100644 --- a/Airbus/Airbus/DrawingAirbus.cs +++ b/Airbus/Airbus/DrawningAirbus.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace Airbus { //класс, отвечающий за прорисовку и перемещение объект - internal class DrawingAirbus + internal class DrawningAirbus { public EntityAirbus Airbus { get; protected set; } //класс-сущность @@ -24,11 +24,11 @@ namespace Airbus protected readonly int _airbusHeight = 62; //высота отрисовки самолёта //инициализаци свойств - public DrawingAirbus(int speed, float weight, Color corpusColor) + public DrawningAirbus(int speed, float weight, Color corpusColor) { Airbus = new EntityAirbus(speed, weight, corpusColor); } - protected DrawingAirbus(int speed, float weight, Color corpusColor, int airbusWidth, int airbusHeight) : + protected DrawningAirbus(int speed, float weight, Color corpusColor, int airbusWidth, int airbusHeight) : this(speed, weight, corpusColor) { _airbusWidth = airbusWidth; @@ -196,5 +196,10 @@ namespace Airbus _startPosY = _pictureHeight.Value - _airbusHeight; } } + //получение текущей позиции объекта + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return (_startPosX, _startPosY, _startPosX + _airbusWidth, _startPosY + _airbusHeight); + } } } \ No newline at end of file diff --git a/Airbus/Airbus/DrawningObjectAirbus.cs b/Airbus/Airbus/DrawningObjectAirbus.cs new file mode 100644 index 0000000..5903969 --- /dev/null +++ b/Airbus/Airbus/DrawningObjectAirbus.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Airbus +{ + internal class DrawningObjectAirbus: IDrawningObject + { + private DrawningAirbus _airbus; + + public float Step => _airbus?.Airbus?.Step ?? 0; + + public DrawningObjectAirbus(DrawningAirbus airbus) + { + _airbus = airbus; + } + + void IDrawningObject.DrawningObject(Graphics g) + { + //ДОДУМАТЬ ЛОГИКУ ЭТОГО МЕТОДА + } + + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return _airbus?.GetCurrentPosition() ?? default; + } + + public void MoveObject(Direction direction) + { + _airbus?.MoveTransport(direction); + } + + public void SetObject(int x, int y, int width, int height) + { + _airbus?.SetPosition(x, y, width, height); + } + } +} diff --git a/Airbus/Airbus/DrawingSuperAirbus.cs b/Airbus/Airbus/DrawningSuperAirbus.cs similarity index 88% rename from Airbus/Airbus/DrawingSuperAirbus.cs rename to Airbus/Airbus/DrawningSuperAirbus.cs index 2fbf20c..86e9344 100644 --- a/Airbus/Airbus/DrawingSuperAirbus.cs +++ b/Airbus/Airbus/DrawningSuperAirbus.cs @@ -6,10 +6,10 @@ using System.Threading.Tasks; namespace Airbus { - internal class DrawingSuperAirbus : DrawingAirbus + internal class DrawningSuperAirbus : DrawningAirbus { //Инициализаци свойств - public DrawingSuperAirbus(int speed, float weight, Color corpusColor, Color addColor, bool addCompartment, bool addEngine) : + public DrawningSuperAirbus(int speed, float weight, Color corpusColor, Color addColor, bool addCompartment, bool addEngine) : base(speed, weight, corpusColor, 110, 60) { Airbus = new EntitySuperAirbus(speed, weight, corpusColor, addColor, addCompartment, addEngine); diff --git a/Airbus/Airbus/FormAirbus.cs b/Airbus/Airbus/FormAirbus.cs index 8c7b0e4..fe088f2 100644 --- a/Airbus/Airbus/FormAirbus.cs +++ b/Airbus/Airbus/FormAirbus.cs @@ -12,7 +12,7 @@ namespace Airbus { public partial class FormAirbus : Form { - private DrawingAirbus _airbus; + private DrawningAirbus _airbus; public FormAirbus() { InitializeComponent(); @@ -39,7 +39,7 @@ namespace Airbus private void ButtonCreate_Click(object sender, EventArgs e) { Random rnd = new(); - _airbus = new DrawingAirbus(rnd.Next(100, 300), rnd.Next(1000, 2000),Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + _airbus = new DrawningAirbus(rnd.Next(100, 300), rnd.Next(1000, 2000),Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); SetData(); Draw(); } @@ -77,7 +77,7 @@ namespace Airbus private void ButtonCreateModif_Click(object sender, EventArgs e) { Random rnd = new(); - _airbus = new DrawingSuperAirbus(rnd.Next(100, 300), rnd.Next(1000, 2000), + _airbus = new DrawningSuperAirbus(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2))); diff --git a/Airbus/Airbus/IDrawningObject.cs b/Airbus/Airbus/IDrawningObject.cs new file mode 100644 index 0000000..5472733 --- /dev/null +++ b/Airbus/Airbus/IDrawningObject.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Airbus +{ + internal interface IDrawningObject + { + //шаг перемещения объекта + public float Step { get; } + + //установка позиции объекта + void SetObject(int x, int y, int width, int height); + + //изменение направления перемещения объекта + void MoveObject(Direction direction); + + //отрисовка объекта + void DrawningObject(Graphics g); + + //получение текущей позиции объекта + (float Left, float Right, float Top, float Bottom) GetCurrentPosition(); + } +} +}