d
This commit is contained in:
parent
90da769265
commit
77141b976c
@ -10,36 +10,36 @@ namespace ProjectArtilleryUnit.MovementStrategy
|
||||
/// <summary>
|
||||
/// Поле-объект класса DrawningArtilleryUnit или его наследника
|
||||
/// </summary>
|
||||
private readonly DrawningArtilleryUnit? _tank = null;
|
||||
private readonly DrawningArtilleryUnit? _artilleryUnit = null;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="tank">Объект класса DrawningArtilleryUnit</param>
|
||||
public MoveableArtilleryUnit(DrawningArtilleryUnit tank)
|
||||
/// <param name="artilleryUnit">Объект класса DrawningArtilleryUnit</param>
|
||||
public MoveableArtilleryUnit(DrawningArtilleryUnit artilleryUnit)
|
||||
{
|
||||
_tank = tank;
|
||||
_artilleryUnit = artilleryUnit;
|
||||
}
|
||||
public ObjectParameters? GetObjectPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_tank == null || _tank.EntityArtilleryUnit == null ||
|
||||
!_tank.GetPosX.HasValue || !_tank.GetPosY.HasValue)
|
||||
if (_artilleryUnit == null || _artilleryUnit.EntityArtilleryUnit == null ||
|
||||
!_artilleryUnit.GetPosX.HasValue || !_artilleryUnit.GetPosY.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ObjectParameters(_tank.GetPosX.Value,
|
||||
_tank.GetPosY.Value, _tank.GetWidth, _tank.GetHeight);
|
||||
return new ObjectParameters(_artilleryUnit.GetPosX.Value,
|
||||
_artilleryUnit.GetPosY.Value, _artilleryUnit.GetWidth, _artilleryUnit.GetHeight);
|
||||
}
|
||||
}
|
||||
public int GetStep => (int)(_tank?.EntityArtilleryUnit?.Step ?? 0);
|
||||
public int GetStep => (int)(_artilleryUnit?.EntityArtilleryUnit?.Step ?? 0);
|
||||
public bool TryMoveObject(MovementDirection direction)
|
||||
{
|
||||
if (_tank == null || _tank.EntityArtilleryUnit == null)
|
||||
if (_artilleryUnit == null || _artilleryUnit.EntityArtilleryUnit == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return _tank.MoveTransport(GetDirectionType(direction));
|
||||
return _artilleryUnit.MoveTransport(GetDirectionType(direction));
|
||||
}
|
||||
/// <summary>
|
||||
/// Конвертация из MovementDirection в DirectionType
|
||||
|
Loading…
x
Reference in New Issue
Block a user