diff --git a/Warship/Warship/DrawningShip.cs b/Warship/Warship/DrawningShip.cs
index e20169c..541f7bb 100644
--- a/Warship/Warship/DrawningShip.cs
+++ b/Warship/Warship/DrawningShip.cs
@@ -7,20 +7,20 @@ using System.Threading.Tasks;
namespace Warship
{
- internal class DrawningShip
+ public class DrawningShip
{
///
/// Класс-сущность
///
- public EntityShip Ship { private set; get; }
+ public EntityShip Ship { protected set; get; }
///
/// Левая координата отрисовки лодки
///
- private float _startPosX;
+ protected float _startPosX;
///
/// Верхняя кооридната отрисовки лодки
///
- private float _startPosY;
+ protected float _startPosY;
///
/// Ширина окна отрисовки
///
@@ -32,7 +32,7 @@ namespace Warship
///
/// Ширина отрисовки лодки
///
- private readonly int _shipWidth = 120;
+ private readonly int _shipWidth = 125;
///
/// Высота отрисовки лодки
///
@@ -43,10 +43,14 @@ namespace Warship
/// Скорость
/// Вес лодки
/// Цвет кузова
- public void Init(int speed, float weight, Color bodyColor)
+ public DrawningShip(int speed, float weight, Color bodyColor)
{
- Ship = new EntityShip();
- Ship.Init(speed, weight, bodyColor);
+ Ship = new EntityShip(speed, weight, bodyColor);
+ }
+ protected DrawningShip(int speed, float weight, Color bodyColor, int shipWight, int shipHeight) : this(speed, weight, bodyColor)
+ {
+ _shipWidth = shipWight;
+ _shipHeight = shipHeight;
}
///
/// Установка позиции корабля
@@ -111,8 +115,17 @@ namespace Warship
break;
}
}
+
+ public bool DrawCheck()
+ {
+ if (_startPosX < 0 || _startPosY < 0 || !_pictureHeight.HasValue || !_pictureWidth.HasValue)
+ {
+ return false;
+ }
+ return true;
+ }
///
- public void DrawTransport(Graphics g)
+ public virtual void DrawTransport(Graphics g)
{
if (_startPosX < 0 || _startPosY < 0
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
@@ -165,5 +178,10 @@ namespace Warship
_startPosY = _pictureHeight.Value - _shipHeight;
}
}
+
+ public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
+ {
+ return (_startPosX, _startPosY, _startPosX + _shipWidth, _startPosY + _shipHeight);
+ }
}
}
diff --git a/Warship/Warship/EntityShip.cs b/Warship/Warship/EntityShip.cs
index ca5df94..4f04bc3 100644
--- a/Warship/Warship/EntityShip.cs
+++ b/Warship/Warship/EntityShip.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Warship
{
- internal class EntityShip
+ public class EntityShip
{
///
@@ -32,7 +32,7 @@ namespace Warship
///
///
///
- public void Init(int speed, float weight, Color bodyColor)
+ public EntityShip(int speed, float weight, Color bodyColor)
{
Random rnd = new();
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;