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