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