готова

This commit is contained in:
xom9kxom9k 2024-02-11 12:37:25 +04:00
parent 1ee58a8b53
commit 19122ab559

View File

@ -51,6 +51,12 @@ public class DrawingSeaplane
_startPosX = null;
_startPosY = null;
}
/// <summary>
/// Установка границ поля
/// </summary>
/// <param name="width"></param>
/// <param name="height"></param>
/// <returns></returns>
public bool SetPictureSize(int width, int height)
{
// TODO проверка, что объект "влезает" в размеры поля
@ -86,12 +92,14 @@ public class DrawingSeaplane
/// <param name="y"></param>
public void SetPosition(int x, int y)
{
// TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы
// то надо изменить координаты, чтобы он оставался в этих границах
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
{
return;
}
// TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы
// то надо изменить координаты, чтобы он оставался в этих границах
if (x + _drawningPlaneWidth > _pictureWidth)
{
_startPosX = _pictureWidth - _drawningPlaneWidth;
@ -121,7 +129,7 @@ public class DrawingSeaplane
/// <summary>
/// Изменение направления перемещения
/// </summary>
/// <param name="direction"></param>
/// <param name="direction">Направление</param>
/// <returns></returns>
public bool MoveTransport(DirectionType direction)
{
@ -131,34 +139,30 @@ public class DrawingSeaplane
}
switch (direction)
{
//влево
case DirectionType.Left:
if (_startPosX.Value - EntitySeaplane.Step > 0)
{
_startPosX -= (int)EntitySeaplane.Step;
}
return true;
//вверх
case DirectionType.Up:
if (_startPosY.Value - EntitySeaplane.Step > 0)
{
_startPosY -= (int)EntitySeaplane.Step;
}
return true;
// вправо
case DirectionType.Right:
if (_startPosX.Value + _drawningPlaneWidth + EntitySeaplane.Step < _pictureWidth)
{
_startPosX += (int)EntitySeaplane.Step;
}
return true;
//вниз
case DirectionType.Down:
if (_startPosY.Value + _drawningPlaneHeight + EntitySeaplane.Step < _pictureHeight)
{
_startPosY += (int)EntitySeaplane.Step;
}
return true;
case DirectionType.Up: //вверх
if (_startPosY - EntitySeaplane.Step > 0)
{
_startPosY -= (int)EntitySeaplane.Step;
}
return true;
default:
return false;
}