Реализован класс с интерфейсом IMoveableObject
This commit is contained in:
parent
b7a3f41598
commit
4b53105c7b
@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectStormtrooper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Реализация интерфейса IDrawningObject для работы с объектом DrawningPlane (паттерн Adapter)
|
||||||
|
/// </summary>
|
||||||
|
public class DrawingObjectPlane : IMoveableObject
|
||||||
|
{
|
||||||
|
private readonly DrawingPlane? _drawingPlane = null;
|
||||||
|
public DrawingObjectPlane(DrawingPlane drawingPlane)
|
||||||
|
{
|
||||||
|
_drawingPlane = drawingPlane;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObjectParameters? GetObjectPosition
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_drawingPlane == null || _drawingPlane.EntityPlane == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new ObjectParameters(_drawingPlane.GetPosX, _drawingPlane.GetPosY, _drawingPlane.GetWidth, _drawingPlane.GetHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetStep => (int)(_drawingPlane?.EntityPlane?.Step ?? 0);
|
||||||
|
|
||||||
|
public bool CheckCanMove(DirectionType direction) => _drawingPlane?.CanMove(direction) ?? false;
|
||||||
|
|
||||||
|
public void MoveObject(DirectionType direction) => _drawingPlane?.MoveTransport(direction);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user