PIbd-22_Kurbanova_A.A.Warml.../WarmlyLocomotive/DrawningObjectWarmlyLocomotive.cs

32 lines
1.3 KiB
C#
Raw Permalink Normal View History

2023-11-03 21:51:37 +04:00
using WarmlyLocomotive.DrawningObjects;
2023-10-31 15:28:54 +04:00
namespace WarmlyLocomotive.MovementStrategy
{
internal class DrawningObjectWarmlyLocomotive : IMoveableObject
2023-10-31 15:28:54 +04:00
{
2023-11-03 21:51:37 +04:00
private readonly DrawningWarmlyLocomotive? _drawningWarmlyLocomotive = null;
public DrawningObjectWarmlyLocomotive(DrawningWarmlyLocomotive drawningWarmlylocomotive)
2023-10-31 15:28:54 +04:00
{
_drawningWarmlyLocomotive = drawningWarmlylocomotive;
2023-10-31 15:28:54 +04:00
}
public ObjectParameters? GetObjectPosition
{
get
{
2023-11-03 21:51:37 +04:00
if (_drawningWarmlyLocomotive == null || _drawningWarmlyLocomotive.EntityWarmlyLocomotive ==
2023-10-31 15:28:54 +04:00
null)
{
return null;
}
2023-11-03 21:51:37 +04:00
return new ObjectParameters(_drawningWarmlyLocomotive.GetPosX,
_drawningWarmlyLocomotive.GetPosY, _drawningWarmlyLocomotive.GetWidth, _drawningWarmlyLocomotive.GetHeight);
2023-10-31 15:28:54 +04:00
}
}
2023-11-03 21:51:37 +04:00
public int GetStep => (int)(_drawningWarmlyLocomotive?.EntityWarmlyLocomotive?.Step ?? 0);
2023-10-31 15:28:54 +04:00
public bool CheckCanMove(Direction direction) =>
2023-11-03 21:51:37 +04:00
_drawningWarmlyLocomotive?.CanMove(direction) ?? false;
2023-10-31 15:28:54 +04:00
public void MoveObject(Direction direction) =>
2023-11-03 21:51:37 +04:00
_drawningWarmlyLocomotive?.MoveTransport(direction);
2023-10-31 15:28:54 +04:00
}
}