PIbd-21_Anisin_R.S._DumpTru.../DumpTruck/MovementStrategy/DrawningObjectTruck.cs

37 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DumpTruck.DrawingObjects;
namespace DumpTruck.MovementStrategy
{
public class DrawningObjectTruck : IMoveableObject
{
private readonly DrawingTruck? _drawingTruck = null;
public DrawningObjectTruck(DrawingTruck drawningCar)
{
_drawingTruck = drawningCar;
}
public ObjectParameters? GetObjectPosition
{
get
{
if (_drawingTruck == null || _drawingTruck.EntityTruck ==
null)
{
return null;
}
return new ObjectParameters(_drawingTruck.GetPosX,
_drawingTruck.GetPosY, _drawingTruck.GetWidth, _drawingTruck.GetHeight);
}
}
public int GetStep => (int)(_drawingTruck?.EntityTruck?.Step ?? 0);
public bool CheckCanMove(Direction direction) =>
_drawingTruck?.CanMove(direction) ?? false;
public void MoveObject(Direction direction) =>
_drawingTruck?.MoveTransport(direction);
}
}