2023-11-24 12:46:13 +04:00

40 lines
1.3 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 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);
}
}