2023-09-25 14:04:52 +04:00
|
|
|
|
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
|
|
|
|
|
{
|
2023-09-25 14:25:04 +04:00
|
|
|
|
if (_drawingLiner == null || _drawingLiner.EntityLiner == null)
|
2023-09-25 14:04:52 +04:00
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
2023-09-25 14:04:52 +04:00
|
|
|
|
|
2023-09-25 14:04:52 +04:00
|
|
|
|
}
|