Добавление интерфейса
This commit is contained in:
parent
471887324e
commit
27127e27fa
34
Warship/Warship/DrawingObjectWarship.cs
Normal file
34
Warship/Warship/DrawingObjectWarship.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftCarrier
|
||||||
|
{
|
||||||
|
internal class DrawingObjectWarship : IDrawingObject
|
||||||
|
{
|
||||||
|
private DrawingWarship _ship = null;
|
||||||
|
public DrawingObjectWarship(DrawingWarship ship)
|
||||||
|
{
|
||||||
|
_ship = ship;
|
||||||
|
}
|
||||||
|
public float Step => _ship?.Ship?.Step ?? 0;
|
||||||
|
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||||
|
{
|
||||||
|
return _ship?.GetCurrentPosition() ?? default;
|
||||||
|
}
|
||||||
|
public void MoveObject(Direction direction)
|
||||||
|
{
|
||||||
|
_ship?.MoveTransport(direction);
|
||||||
|
}
|
||||||
|
public void SetObject(int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
_ship.SetPosition(x, y, width, height);
|
||||||
|
}
|
||||||
|
public void DrawningObject(Graphics g)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -185,6 +185,15 @@ namespace AircraftCarrier
|
|||||||
_startPosY = _pictureHeight.Value - _shipHeight;
|
_startPosY = _pictureHeight.Value - _shipHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Получение текущей позиции объекта
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||||
|
{
|
||||||
|
return (_startPosX, _startPosY, _startPosX + _shipWidth, _startPosY +
|
||||||
|
_shipHeight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
43
Warship/Warship/IDrawingObject.cs
Normal file
43
Warship/Warship/IDrawingObject.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftCarrier
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Интерфейс для работы с объектом, прорисовываемым на форме
|
||||||
|
/// </summary>
|
||||||
|
internal interface IDrawingObject
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Шаг перемещения объекта
|
||||||
|
/// </summary>
|
||||||
|
public float Step { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// Установка позиции объекта
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x">Координата X</param>
|
||||||
|
/// <param name="y">Координата Y</param>
|
||||||
|
/// <param name="width">Ширина полотна</param>
|
||||||
|
/// <param name="height">Высота полотна</param>
|
||||||
|
void SetObject(int x, int y, int width, int height);
|
||||||
|
/// <summary>
|
||||||
|
/// Изменение направления пермещения объекта
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="direction">Направление</param>
|
||||||
|
void MoveObject(Direction direction);
|
||||||
|
/// <summary>
|
||||||
|
/// Отрисовка объекта
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g"></param>
|
||||||
|
void DrawningObject(Graphics g);
|
||||||
|
/// <summary>
|
||||||
|
/// Получение текущей позиции объекта
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
(float Left, float Right, float Top, float Bottom)
|
||||||
|
GetCurrentPosition();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user