2023-10-06 21:35:14 +04:00
|
|
|
|
using RoadTrain.DrawningObjects;
|
|
|
|
|
using RoadTrain.MovementStrategy;
|
|
|
|
|
using RoadTrain;
|
|
|
|
|
|
|
|
|
|
namespace RoadTrain.MovementStrategy
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2023-10-24 18:58:46 +04:00
|
|
|
|
/// Реализация интерфейса IDrawningObject для работы с объектом DrawningRoadTrain (паттерн Adapter)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class DrawningObjectTrain : IMoveableObject
|
2023-10-06 21:35:14 +04:00
|
|
|
|
{
|
|
|
|
|
private readonly DrawningRoadTrain? _drawningRoadTrain = null;
|
|
|
|
|
public DrawningObjectTrain (DrawningRoadTrain drawningRoadTrain)
|
|
|
|
|
{
|
|
|
|
|
_drawningRoadTrain = drawningRoadTrain;
|
|
|
|
|
}
|
|
|
|
|
public ObjectParameters? GetObjectPosition
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_drawningRoadTrain == null || _drawningRoadTrain.EntityRoadTrain ==
|
|
|
|
|
null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new ObjectParameters(_drawningRoadTrain.GetPosX,
|
|
|
|
|
_drawningRoadTrain.GetPosY, _drawningRoadTrain.GetWidth, _drawningRoadTrain.GetHeight);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public int GetStep => (int)(_drawningRoadTrain?.EntityRoadTrain?.Step ?? 0);
|
|
|
|
|
public bool CheckCanMove(DirectionType direction) =>
|
|
|
|
|
_drawningRoadTrain?.CanMove(direction) ?? false;
|
|
|
|
|
public void MoveObject(DirectionType direction) =>
|
|
|
|
|
_drawningRoadTrain?.MoveTransport(direction);
|
|
|
|
|
}
|
|
|
|
|
}
|