40 lines
1.4 KiB
C#
40 lines
1.4 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
using ProjectSeaplane.MovementStrategy;
|
||
using ProjectSeaplane.DrawningObjects;
|
||
using static ProjectSeaplane.Direction;
|
||
|
||
|
||
namespace ProjectSeaplane.MovementStrategy
|
||
{
|
||
/// <summary>
|
||
/// Реализация интерфейса IDrawningObject для работы с объектом DrawningPlane (паттерн Adapter)
|
||
/// </summary>
|
||
public class DrawningObjectPlane : IMoveableObject
|
||
{
|
||
private readonly DrawningPlane? _drawningPlane = null;
|
||
public DrawningObjectPlane(DrawningPlane drawningPlane)
|
||
{
|
||
_drawningPlane = drawningPlane;
|
||
}
|
||
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);
|
||
}
|
||
}
|
||
|