This commit is contained in:
devil_1nc 2024-02-27 10:58:27 +04:00
parent b5fa935cf2
commit f526a5f2bc

View File

@ -38,16 +38,17 @@ namespace WarmlyShip
{ {
_pictureWidth = width; _pictureWidth = width;
_pictureHeight = height; _pictureHeight = height;
if (_startPosX != null && _startPosY != null) if (_startPosX != null && _startPosY != null)
{ {
if (_startPosX.Value + _drawningWarmlyShipWidth > _pictureWidth || _startPosY.Value + _drawningWarmlyShipHeight > _pictureHeight) if (_startPosX.Value + _drawningWarmlyShipWidth > _pictureWidth)
{ {
EntityWarmlyShip = null; _startPosX = _pictureWidth - _drawningWarmlyShipWidth;
}
if (_startPosY.Value + _drawningWarmlyShipHeight > _pictureHeight)
{
_startPosY = _pictureHeight - _drawningWarmlyShipHeight;
} }
} }
return true; return true;
} }
return false; return false;
@ -55,17 +56,26 @@ namespace WarmlyShip
} }
public void SetPosition(int x, int y) public void SetPosition(int x, int y)
{ {
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue) { if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
return;
}
_startPosX = x;
_startPosY = y;
if (_drawningWarmlyShipHeight + _startPosY.Value > _pictureHeight || _drawningWarmlyShipWidth + _startPosX > _pictureWidth)
{ {
_startPosX = 0; return;
_startPosY = 0; }
else
{
_startPosX = x;
_startPosY = y;
if (_startPosX < 0) _startPosX = 0;
if (_startPosY < 0) _startPosY = 0;
if (_startPosX + _drawningWarmlyShipWidth > _pictureWidth.Value)
{
_startPosX = _pictureWidth.Value - _drawningWarmlyShipWidth;
}
if (_startPosY + _drawningWarmlyShipHeight > _pictureHeight.Value)
{
_startPosY = _pictureHeight.Value - _drawningWarmlyShipHeight;
}
} }
} }