40 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);
}
}