Добавление новых методов класса DrawningBoat
This commit is contained in:
parent
92af897804
commit
810b4f70a6
@ -48,9 +48,21 @@ namespace Sailboat.DrawingObjects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _boatHeight = 160;
|
private readonly int _boatHeight = 160;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Координата X объекта
|
||||||
|
/// </summary>
|
||||||
public int GetPosX => _startPosX;
|
public int GetPosX => _startPosX;
|
||||||
|
/// <summary>
|
||||||
|
/// Координата Y объекта
|
||||||
|
/// </summary>
|
||||||
public int GetPosY => _startPosY;
|
public int GetPosY => _startPosY;
|
||||||
|
/// <summary>
|
||||||
|
/// Ширина объекта
|
||||||
|
/// </summary>
|
||||||
public int GetWidth => _boatWidth;
|
public int GetWidth => _boatWidth;
|
||||||
|
/// <summary>
|
||||||
|
/// Высота объекта
|
||||||
|
/// </summary>
|
||||||
public int GetHeight => _boatHeight;
|
public int GetHeight => _boatHeight;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -114,6 +126,11 @@ namespace Sailboat.DrawingObjects
|
|||||||
_startPosY = y;
|
_startPosY = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Проверка, что объект может переместится по указанному направлению
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="direction">Направление</param>
|
||||||
|
/// <returns>true - можно переместится по указанному направлению</returns>
|
||||||
public bool CanMove(DirectionType direction)
|
public bool CanMove(DirectionType direction)
|
||||||
{
|
{
|
||||||
if (EntityBoat == null)
|
if (EntityBoat == null)
|
||||||
@ -146,24 +163,28 @@ namespace Sailboat.DrawingObjects
|
|||||||
}
|
}
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
|
//влево
|
||||||
case DirectionType.Left:
|
case DirectionType.Left:
|
||||||
if (_startPosX - EntityBoat.Step > 0)
|
if (_startPosX - EntityBoat.Step > 0)
|
||||||
{
|
{
|
||||||
_startPosX -= (int)EntityBoat.Step;
|
_startPosX -= (int)EntityBoat.Step;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
//вверх
|
||||||
case DirectionType.Up:
|
case DirectionType.Up:
|
||||||
if (_startPosY - EntityBoat.Step > 0)
|
if (_startPosY - EntityBoat.Step > 0)
|
||||||
{
|
{
|
||||||
_startPosY -= (int)EntityBoat.Step;
|
_startPosY -= (int)EntityBoat.Step;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
//вправо
|
||||||
case DirectionType.Right:
|
case DirectionType.Right:
|
||||||
if (_startPosX + EntityBoat.Step + _boatWidth < _pictureWidth)
|
if (_startPosX + EntityBoat.Step + _boatWidth < _pictureWidth)
|
||||||
{
|
{
|
||||||
_startPosX += (int)EntityBoat.Step;
|
_startPosX += (int)EntityBoat.Step;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
//вниз
|
||||||
case DirectionType.Down:
|
case DirectionType.Down:
|
||||||
if (_startPosY + EntityBoat.Step + _boatHeight < _pictureHeight)
|
if (_startPosY + EntityBoat.Step + _boatHeight < _pictureHeight)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user