using RoadTrain.DrawningObjects; using RoadTrain.MovementStrategy; using RoadTrain; namespace RoadTrain.MovementStrategy { /// /// Реализация интерфейса IDrawningObject для работы с объектом DrawningCar (паттерн Adapter) /// public class DrawningObjectTrain : IMoveableObject { 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); } }