Добавление интерфейса
This commit is contained in:
parent
0e40ea687b
commit
066f232018
@ -184,5 +184,13 @@
|
||||
_startPosY = _pictureHeight.Value - _shipHeight;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение текущей позиции объекта
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return (_startPosX, _startPosY, _startPosX + _carWidth, _startPosY + _carHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace WarmlyShip
|
||||
/// <param name="pipes">Признак наличия труб</param>
|
||||
/// <param name="fuelCompartment">Признак наличия топливного отсека</param>
|
||||
public DrawningWarmlyShip(int speed, float weight, Color bodyColor, Color dopColor, bool pipes, bool fuelCompartment) :
|
||||
base(speed, weight, bodyColor, 175, 65)
|
||||
base(speed, weight, bodyColor, 170, 95)
|
||||
{
|
||||
Ship = new EntityWarmlyShip(speed, weight, bodyColor, dopColor, pipes, fuelCompartment);
|
||||
}
|
||||
@ -43,10 +43,8 @@ namespace WarmlyShip
|
||||
|
||||
}
|
||||
|
||||
//_startPosX += 10;
|
||||
_startPosY += 30;
|
||||
base.DrawTransport(g);
|
||||
//_startPosX -= 10;
|
||||
_startPosY -= 30;
|
||||
|
||||
if (warmlyShip.FuelCompartment)
|
||||
|
40
WarmlyShip/WarmlyShip/DrwaningObjectShip.cs
Normal file
40
WarmlyShip/WarmlyShip/DrwaningObjectShip.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 DrwaningObjectShip : IDrawningObject
|
||||
{
|
||||
private DrawningShip _ship = null;
|
||||
|
||||
public DrwaningObjectShip(DrawningShip 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);
|
||||
}
|
||||
|
||||
void IDrawningObject.DrawningObject(Graphics g)
|
||||
{
|
||||
_ship.DrawTransport(g);
|
||||
}
|
||||
}
|
||||
}
|
40
WarmlyShip/WarmlyShip/IDrawningObject.cs
Normal file
40
WarmlyShip/WarmlyShip/IDrawningObject.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 interface IDrawningObject
|
||||
{
|
||||
/// <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>
|
||||
/// <returns></returns>
|
||||
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