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