PIbd-22_Smirnov_A_A_RoadTra.../RoadTrain/RoadTrain/DrawingObjectTrain.cs

33 lines
1.2 KiB
C#

using RoadTrain.MovementStrategy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RoadTrain.DrawingObjects;
namespace RoadTrain.MovementStrategy
{
public class DrawingObjectTrain : IMoveableObject
{
private readonly DrawingRoadTrain? _drawingRoadTrain = null;
public DrawingObjectTrain(DrawingRoadTrain drawingRoadTrain)
{
_drawingRoadTrain = drawingRoadTrain;
}
public ObjectParameters? GetObjectPosition
{
get
{
if (_drawingRoadTrain == null || _drawingRoadTrain.EntityRoadTrain == null)
{
return null;
}
return new ObjectParameters(_drawingRoadTrain.GetPosX, _drawingRoadTrain.GetPosY, _drawingRoadTrain.GetWidth, _drawingRoadTrain.GetHeight);
}
}
public int GetStep => (int)(_drawingRoadTrain?.EntityRoadTrain?.Step ?? 0);
public bool CheckCanMove(DirectionType direction) => _drawingRoadTrain?.CanMove(direction) ?? false;
public void MoveObject(DirectionType direction) => _drawingRoadTrain?.MoveTransport(direction);
}
}