Добавление интерфейса.
This commit is contained in:
parent
e51d851a32
commit
4356388162
40
WarmlyShip/WarmlyShip/DrawningObjectShip.cs
Normal file
40
WarmlyShip/WarmlyShip/DrawningObjectShip.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WarmlyShip
|
||||
{
|
||||
internal class DrawningObjectShip : IDrawningObject
|
||||
{
|
||||
private DrawningWarmlyShip _warmlyShip = null;
|
||||
|
||||
public DrawningObjectShip(DrawningWarmlyShip warmlyShip)
|
||||
{
|
||||
_warmlyShip = warmlyShip;
|
||||
}
|
||||
|
||||
public float Step => _warmlyShip?.warmlyShip?.Step ?? 0;
|
||||
|
||||
public void DrawningObject(Graphics g)
|
||||
{
|
||||
_warmlyShip?.DrawTransport(g);
|
||||
}
|
||||
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return _warmlyShip?.GetCurrentPosition() ?? default;
|
||||
}
|
||||
|
||||
public void MoveObject(Direction direction)
|
||||
{
|
||||
_warmlyShip?.MoveTransport(direction);
|
||||
}
|
||||
|
||||
public void SetObject(int x, int y, int width, int height)
|
||||
{
|
||||
_warmlyShip?.SetPosition(x, y, width, height);
|
||||
}
|
||||
}
|
||||
}
|
@ -114,5 +114,10 @@ namespace WarmlyShip
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return (_startPosX, _startPosY, _startPosX + _warmlyShipWidth, _startPosY + _warmlyShipHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
17
WarmlyShip/WarmlyShip/IDrawningObject.cs
Normal file
17
WarmlyShip/WarmlyShip/IDrawningObject.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WarmlyShip
|
||||
{
|
||||
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