Добавление интерфейса
This commit is contained in:
parent
760ccf3570
commit
0991e91205
@ -142,5 +142,10 @@ namespace Locomotive
|
|||||||
_startPosY = _pictureHeight.Value - _locomotiveHeight;
|
_startPosY = _pictureHeight.Value - _locomotiveHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Получение текущей позиции объекта
|
||||||
|
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||||
|
{
|
||||||
|
return (_startPosX, _startPosY, _startPosX + _locomotiveWidth, _startPosY + _locomotiveHeight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
40
Locomotive/Locomotive/DrawningObjectLocomotive.cs
Normal file
40
Locomotive/Locomotive/DrawningObjectLocomotive.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Locomotive
|
||||||
|
{
|
||||||
|
internal class DrawningObjectLocomotive : IDrawningObject
|
||||||
|
{
|
||||||
|
private DrawningLocomotive _locomotive = null;
|
||||||
|
|
||||||
|
public DrawningObjectLocomotive(DrawningLocomotive locomotive)
|
||||||
|
{
|
||||||
|
_locomotive = locomotive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float Step => _locomotive?.Locomotive?.Step ?? 0;
|
||||||
|
|
||||||
|
public void DrawningObject(Graphics g)
|
||||||
|
{
|
||||||
|
_locomotive?.DrawTransport(g);
|
||||||
|
}
|
||||||
|
|
||||||
|
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||||
|
{
|
||||||
|
return _locomotive?.GetCurrentPosition() ?? default;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MoveObject(Direction direction)
|
||||||
|
{
|
||||||
|
_locomotive?.MoveTransport(direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetObject(int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
_locomotive?.SetPosition(x, y, width, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
Locomotive/Locomotive/IDrawningObject.cs
Normal file
22
Locomotive/Locomotive/IDrawningObject.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Locomotive
|
||||||
|
{
|
||||||
|
internal interface IDrawningObject
|
||||||
|
{
|
||||||
|
/// Шаг перемещения объекта
|
||||||
|
public float Step { get; }
|
||||||
|
/// Установка позиции объекта
|
||||||
|
void SetObject(int x, int y, int width, int height);
|
||||||
|
/// Изменение направления перемещения объекта
|
||||||
|
void MoveObject(Direction direction);
|
||||||
|
/// Отрисовка объекта
|
||||||
|
void DrawningObject(Graphics g);
|
||||||
|
/// Получение текущей позиции объекта
|
||||||
|
(float Left, float Right, float Top, float Bottom) GetCurrentPosition();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user