bimbim
This commit is contained in:
parent
b5fa935cf2
commit
f526a5f2bc
@ -38,16 +38,17 @@ namespace WarmlyShip
|
||||
{
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
|
||||
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 false;
|
||||
@ -55,17 +56,26 @@ namespace WarmlyShip
|
||||
}
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue) {
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
if (_drawningWarmlyShipHeight + _startPosY.Value > _pictureHeight || _drawningWarmlyShipWidth + _startPosX > _pictureWidth)
|
||||
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||
{
|
||||
_startPosX = 0;
|
||||
_startPosY = 0;
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user