This commit is contained in:
Дима 2024-05-22 03:01:19 +04:00
parent 83c1b990fe
commit 9fb556bc07

View File

@ -10,36 +10,36 @@ namespace ProjectArtilleryUnit.MovementStrategy
/// <summary>
/// Поле-объект класса DrawningArtilleryUnit или его наследника
/// </summary>
private readonly DrawningArtilleryUnit? _cruiser = null;
private readonly DrawningArtilleryUnit? _artilleryUnit = null;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="cruiser">Объект класса DrawningArtilleryUnit</param>
public MoveableArtilleryUnit(DrawningArtilleryUnit cruiser)
/// <param name="artilleryUnit">Объект класса DrawningArtilleryUnit</param>
public MoveableArtilleryUnit(DrawningArtilleryUnit artilleryUnit)
{
_cruiser = cruiser;
_artilleryUnit = artilleryUnit;
}
public ObjectParameters? GetObjectPosition
{
get
{
if (_cruiser == null || _cruiser.EntityArtilleryUnit == null ||
!_cruiser.GetPosX.HasValue || !_cruiser.GetPosY.HasValue)
if (_artilleryUnit == null || _artilleryUnit.EntityArtilleryUnit == null ||
!_artilleryUnit.GetPosX.HasValue || !_artilleryUnit.GetPosY.HasValue)
{
return null;
}
return new ObjectParameters(_cruiser.GetPosX.Value,
_cruiser.GetPosY.Value, _cruiser.GetWidth, _cruiser.GetHeight);
return new ObjectParameters(_artilleryUnit.GetPosX.Value,
_artilleryUnit.GetPosY.Value, _artilleryUnit.GetWidth, _artilleryUnit.GetHeight);
}
}
public int GetStep => (int)(_cruiser?.EntityArtilleryUnit?.Step ?? 0);
public int GetStep => (int)(_artilleryUnit?.EntityArtilleryUnit?.Step ?? 0);
public bool TryMoveObject(MovementDirection direction)
{
if (_cruiser == null || _cruiser.EntityArtilleryUnit == null)
if (_artilleryUnit == null || _artilleryUnit.EntityArtilleryUnit == null)
{
return false;
}
return _cruiser.MoveTransport(GetDirectionType(direction));
return _artilleryUnit.MoveTransport(GetDirectionType(direction));
}
/// <summary>
/// Конвертация из MovementDirection в DirectionType