Kargin D.E. Lab Work 2 #2

Merged
eegov merged 4 commits from LabWork02 into LabWork01 2022-10-07 09:10:55 +04:00
3 changed files with 90 additions and 0 deletions
Showing only changes of commit 7a919fc4d0 - Show all commits

View File

@ -188,5 +188,13 @@ namespace AirFighter
_startPosY = _pictureHeight.Value - _airFighterHeight;
}
}
/// <summary>
/// Получение текущей позиции объекта
/// </summary>
/// <returns></returns>
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
{
return (_startPosX, _startPosX + _airFighterWidth, _startPosY, _startPosY + _airFighterHeight);
}
}
}

View File

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirFighter
{
internal class DrawningObjectAirFighter : IDrawningObject
{
private DrawningAirFighter _airFighter = null;
public float Step => _airFighter?.AirFighter.Step ?? 0;
public DrawningObjectAirFighter(DrawningAirFighter airFighter)
{
_airFighter = airFighter;
}
void IDrawningObject.DrawningObject(Graphics g)
{
_airFighter.DrawAirFighter(g);
}
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
{
return _airFighter?.GetCurrentPosition() ?? default;
}
public void MoveObject(Direction direction)
{
_airFighter?.MoveTransport(direction);
}
public void SetObject(int x, int y, int width, int height)
{
_airFighter?.SetPosition(x, y, width, height);
}
}
}

View File

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirFighter
{
/// <summary>
/// Интерфейс для работы с объектом, прорисовываемым на форме
/// </summary>
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>
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();
}
}