Создание класса DrawningObjectBoat
This commit is contained in:
parent
810b4f70a6
commit
a52c951843
40
Sailboat/Sailboat/DrawingObjectBoat.cs
Normal file
40
Sailboat/Sailboat/DrawingObjectBoat.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Sailboat.DrawingObjects;
|
||||
|
||||
namespace Sailboat.MovementStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// Реализация интерфейса IDrawningObject для работы с объектом DrawningBoat (паттерн Adapter)
|
||||
/// </summary>
|
||||
public class DrawingObjectBoat : IMoveableObject
|
||||
{
|
||||
private readonly DrawingBoat? _drawingBoat = null;
|
||||
public DrawingObjectBoat(DrawingBoat drawingBoat)
|
||||
{
|
||||
_drawingBoat = drawingBoat;
|
||||
}
|
||||
public ObjectParameters? GetObjectPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_drawingBoat == null || _drawingBoat.EntityBoat ==
|
||||
null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ObjectParameters(_drawingBoat.GetPosX, _drawingBoat.GetPosY, _drawingBoat.GetWidth, _drawingBoat.GetHeight);
|
||||
}
|
||||
}
|
||||
public int GetStep => (int)(_drawingBoat?.EntityBoat?.Step ?? 0);
|
||||
public bool CheckCanMove(DirectionType direction) =>
|
||||
_drawingBoat?.CanMove(direction) ?? false;
|
||||
public void MoveObject(DirectionType direction) =>
|
||||
_drawingBoat?.MoveTransport(direction);
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user