Abazov A. A. LabWork02 #2
@ -222,5 +222,14 @@ namespace AirBomber
|
||||
_startPosY = _pictureHeight.Value - _airBomberHeight;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение текущей позиции объекта
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return (_startPosX, _startPosY, _startPosX + _airBomberWidth, _startPosY + _airBomberHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
48
AirBomber/AirBomber/DrawingObject.cs
Normal file
48
AirBomber/AirBomber/DrawingObject.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
internal class DrawingObject : IDrawingObject
|
||||
{
|
||||
private DrawingAirBomber _airBomber = null;
|
||||
|
||||
public DrawingObject(DrawingAirBomber airBomber)
|
||||
{
|
||||
_airBomber = airBomber;
|
||||
}
|
||||
|
||||
public float Step => _airBomber?.AirBomber?.Step ?? 0;
|
||||
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return _airBomber?.GetCurrentPosition() ?? default;
|
||||
}
|
||||
|
||||
public void MoveObject(Direction direction)
|
||||
{
|
||||
_airBomber?.MoveTransport(direction);
|
||||
}
|
||||
|
||||
public void SetObject(int x, int y, int width, int height)
|
||||
{
|
||||
_airBomber.SetPosition(x, y, width, height);
|
||||
}
|
||||
|
||||
void IDrawingObject.DrawingObject(Graphics g)
|
||||
{
|
||||
if (_airBomber == null) return;
|
||||
if (_airBomber is DrawingHeavyAirBomber heavyAirBomber)
|
||||
{
|
||||
heavyAirBomber.DrawTransport(g);
|
||||
}
|
||||
else
|
||||
{
|
||||
_airBomber.DrawTransport(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
43
AirBomber/AirBomber/IDrawingObject.cs
Normal file
43
AirBomber/AirBomber/IDrawingObject.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
/// <summary>
|
||||
/// Интерфейс для работы с объектом, прорисовываемым на форме
|
||||
/// </summary>
|
||||
internal interface IDrawingObject
|
||||
{
|
||||
/// <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 DrawingObject(Graphics g);
|
||||
/// <summary>
|
||||
/// Получение текущей позиции объекта
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
(float Left, float Right, float Top, float Bottom) GetCurrentPosition();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user