44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
using WarmlyShip.DrawningObjects;
|
||
|
||
namespace WarmlyShip.MovementStrategy
|
||
{
|
||
/// <summary>
|
||
/// Реализация интерфейса IDrawningObject для работы с объектом DrawningShip (паттерн Adapter)
|
||
/// </summary>
|
||
public class DrawningObjectShip : IMoveableObject
|
||
{
|
||
private readonly DrawningShip? _drawningShip = null;
|
||
|
||
public DrawningObjectShip(DrawningShip drawningShip)
|
||
{
|
||
_drawningShip = drawningShip;
|
||
}
|
||
|
||
public ObjectParameters? GetObjectPosition
|
||
{
|
||
get
|
||
{
|
||
if (_drawningShip == null || _drawningShip.EntityShip == null)
|
||
{
|
||
return null;
|
||
}
|
||
return new ObjectParameters(_drawningShip.GetPosX,
|
||
_drawningShip.GetPosY, _drawningShip.GetWidth, _drawningShip.GetHeight);
|
||
}
|
||
}
|
||
|
||
public int GetStep => (int)(_drawningShip?.EntityShip?.Step ?? 0);
|
||
|
||
public bool CheckCanMove(DirectionType direction) =>
|
||
_drawningShip?.CanMove(direction) ?? false;
|
||
|
||
public void MoveObject(DirectionType direction) =>
|
||
_drawningShip?.MoveTransport(direction);
|
||
}
|
||
}
|