2023-10-31 15:28:54 +04:00

38 lines
1.2 KiB
C#

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