Правки лабораторная 2
This commit is contained in:
parent
21ce7abbe3
commit
37572c6e3c
@ -22,20 +22,6 @@ namespace Tank
|
|||||||
public int GetWidth => _Width;
|
public int GetWidth => _Width;
|
||||||
public int GetHeight => _Height;
|
public int GetHeight => _Height;
|
||||||
|
|
||||||
public bool CanMove(Direction direction)
|
|
||||||
{
|
|
||||||
if (Tank == null)
|
|
||||||
return false;
|
|
||||||
return direction switch
|
|
||||||
{
|
|
||||||
Direction.Left => _startPosX - Tank.Step > 0,
|
|
||||||
Direction.Up => _startPosY - Tank.Step > 0,
|
|
||||||
Direction.Right => _startPosX + _Width + Tank.Step < _pictureWidth,
|
|
||||||
Direction.Down => _startPosY + _Height + Tank.Step < _pictureHeight,
|
|
||||||
_ => false
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// Конструктор класса
|
// Конструктор класса
|
||||||
public DrawArmoVehicle(int speed, double weight, Color bodyColor, int width, int height)
|
public DrawArmoVehicle(int speed, double weight, Color bodyColor, int width, int height)
|
||||||
{
|
{
|
||||||
@ -57,6 +43,21 @@ namespace Tank
|
|||||||
Tank = new EntityBase(speed, weight, bodyColor);
|
Tank = new EntityBase(speed, weight, bodyColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CanMove(Direction direction)
|
||||||
|
{
|
||||||
|
if (Tank == null)
|
||||||
|
return false;
|
||||||
|
return direction switch
|
||||||
|
{
|
||||||
|
Direction.Left => _startPosX - Tank.Step > 0,
|
||||||
|
Direction.Up => _startPosY - Tank.Step > 0,
|
||||||
|
Direction.Right => _startPosX + _Width + Tank.Step < _pictureWidth,
|
||||||
|
Direction.Down => _startPosY + _Height + Tank.Step < _pictureHeight,
|
||||||
|
_ => false
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public void SetPosition(int x, int y)
|
public void SetPosition(int x, int y)
|
||||||
{
|
{
|
||||||
_startPosX = x;
|
_startPosX = x;
|
||||||
|
Loading…
Reference in New Issue
Block a user