2023-11-25 12:44:21 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
using ContainerShip.DrawningObjects;
|
|
|
|
|
namespace ContainerShip.MovementStrategy
|
|
|
|
|
{
|
|
|
|
|
public class DrawingObjectShip : IMoveableObject
|
|
|
|
|
{
|
2023-12-16 11:10:10 +04:00
|
|
|
|
private readonly DrawningShip? _drawingShip = null;
|
|
|
|
|
public DrawingObjectShip(DrawningShip drawingShip)
|
2023-11-25 12:44:21 +04:00
|
|
|
|
{
|
2023-12-16 11:10:10 +04:00
|
|
|
|
_drawingShip = drawingShip;
|
2023-11-25 12:44:21 +04:00
|
|
|
|
}
|
|
|
|
|
public ObjectParameters? GetObjectPosition
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2023-12-16 11:10:10 +04:00
|
|
|
|
if (_drawingShip == null || _drawingShip.EntityShip == null)
|
2023-11-25 12:44:21 +04:00
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2023-12-16 11:10:10 +04:00
|
|
|
|
return new ObjectParameters(_drawingShip.GetPosX, _drawingShip.GetPosY, _drawingShip.GetWidth, _drawingShip.GetHeight);
|
2023-11-25 12:44:21 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-16 11:10:10 +04:00
|
|
|
|
public int GetStep => (int)(_drawingShip?.EntityShip?.Step ?? 0);
|
|
|
|
|
public bool CheckCanMove(DirectionType direction) => _drawingShip?.CanMove(direction) ?? false;
|
|
|
|
|
public void MoveObject(DirectionType direction) => _drawingShip?.MoveTransport(direction);
|
2023-11-25 12:44:21 +04:00
|
|
|
|
}
|
|
|
|
|
}
|