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