diff --git a/AirBomber/AirBomber/DrawningJet.cs b/AirBomber/AirBomber/DrawningJet.cs
index 23f0567..f96ccb1 100644
--- a/AirBomber/AirBomber/DrawningJet.cs
+++ b/AirBomber/AirBomber/DrawningJet.cs
@@ -14,15 +14,15 @@ namespace AirBomber
///
/// Класс-сущность
///
- public EntityJet Jet { get; private set; }
+ public EntityJet Jet { get; protected set; }
///
/// Левая координата отрисовки самолета
///
- private float _startPosX;
+ protected float _startPosX;
///
/// Верхняя кооридната отрисовки самолета
///
- private float _startPosY;
+ protected float _startPosY;
///
/// Ширина окна отрисовки
///
@@ -45,10 +45,16 @@ namespace AirBomber
/// Скорость
/// Вес самолета
/// Цвет самолета
- public void Init(int speed, float weight, Color bodyColor)
+ public DrawningJet(int speed, float weight, Color bodyColor)
{
- Jet = new EntityJet();
- Jet.Init(speed, weight, bodyColor);
+ Jet = new EntityJet(speed, weight, bodyColor);
+ }
+
+ protected DrawningJet(int speed, float weight, Color bodyColor, int jetWidth, int jetHeight) :
+ this(speed, weight, bodyColor)
+ {
+ _jetWidth = jetWidth;
+ _jetHeight = jetHeight;
}
///
/// Установка позиции самолета
@@ -58,7 +64,7 @@ namespace AirBomber
/// Ширина картинки
/// Высота картинки
- public void SetPosition(int x, int y, int width, int height)
+ public virtual void SetPosition(int x, int y, int width, int height)
{
if (x < 0 || y < 0 || width < x + _jetWidth || height < y + _jetHeight)
{
@@ -122,7 +128,7 @@ namespace AirBomber
/// Отрисовка самолета
///
///
- public void DrawTransport(Graphics g)
+ public virtual void DrawTransport(Graphics g)
{
if (_startPosX < 0 || _startPosY < 0
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
@@ -202,5 +208,12 @@ namespace AirBomber
_startPosY = _pictureHeight.Value - _jetHeight;
}
}
+ ///
+ /// Получение текущей позиции
+ ///
+ public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
+ {
+ return (_startPosX, _startPosY, _startPosX + _jetWidth, _startPosY + _jetHeight);
+ }
}
}
diff --git a/AirBomber/AirBomber/EntityJet.cs b/AirBomber/AirBomber/EntityJet.cs
index 02dd8b6..f713d10 100644
--- a/AirBomber/AirBomber/EntityJet.cs
+++ b/AirBomber/AirBomber/EntityJet.cs
@@ -35,7 +35,7 @@ namespace AirBomber
///
///
- public void Init(int speed, float weight, Color bodyColor)
+ public EntityJet(int speed, float weight, Color bodyColor)
{
Random rnd = new Random();
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
diff --git a/AirBomber/AirBomber/WarJet.cs b/AirBomber/AirBomber/WarJet.cs
index ca69f50..9f2fd7d 100644
--- a/AirBomber/AirBomber/WarJet.cs
+++ b/AirBomber/AirBomber/WarJet.cs
@@ -57,8 +57,7 @@ namespace AirBomber
private void buttonCreate_Click(object sender, EventArgs e)
{
Random rnd = new Random();
- _jet = new DrawningJet();
- _jet.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
+ _jet = new DrawningJet(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_jet.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxCar.Width, pictureBoxCar.Height);
toolStripStatusLabelSpeed.Text = $": {_jet.Jet.Speed}";
toolStripStatusLabelWeight.Text = $": {_jet.Jet.Weight}";