Добавление интерфейса
This commit is contained in:
parent
96d2bfbb8f
commit
6789fca1cb
39
Warship/Warship/DrawingObjectWarship.cs
Normal file
39
Warship/Warship/DrawingObjectWarship.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Warship
|
||||
{
|
||||
internal class DrawingObjectWarship : IDrawingObject
|
||||
{
|
||||
private DrawingWarship _warship=null;
|
||||
|
||||
public DrawingObjectWarship(DrawingWarship warship)
|
||||
{
|
||||
_warship= warship;
|
||||
}
|
||||
public float Step => _warship?.Warship?.Step ?? 0;
|
||||
|
||||
void IDrawingObject.DrawingObject(Graphics g)
|
||||
{
|
||||
_warship.DrawTransport(g);
|
||||
}
|
||||
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return _warship?.GetCurrentPosition() ?? default;
|
||||
}
|
||||
|
||||
public void MoveObject(Direction direction)
|
||||
{
|
||||
_warship?.MoveTransport(direction);
|
||||
}
|
||||
|
||||
public void SetObject(int x, int y, int width, int height)
|
||||
{
|
||||
_warship.SetPosition(x,y,width,height);
|
||||
}
|
||||
}
|
||||
}
|
@ -140,5 +140,9 @@ namespace Warship
|
||||
_startPosY = _pictureHeight.Value - _warshipHeight;
|
||||
}
|
||||
}
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return (_startPosX, _startPosY, _startPosX + _warshipWidth, _startPosY + _warshipHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
17
Warship/Warship/IDrawingObject.cs
Normal file
17
Warship/Warship/IDrawingObject.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Warship
|
||||
{
|
||||
internal interface IDrawingObject
|
||||
{
|
||||
public float Step { get; }
|
||||
void SetObject(int x, int y, int width, int height);
|
||||
void MoveObject(Direction direction);
|
||||
void DrawingObject(Graphics g);
|
||||
(float Left, float Right, float Top, float Bottom) GetCurrentPosition();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user